Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add :setcookie, grabbing cookie from file #3

Merged
merged 4 commits into from
Dec 8, 2021

Conversation

Matthew-D12
Copy link

Hello, I'm that guy you were talking to yesterday, I did some other changes to my cookie from file code, so if the system can't get the AoC cookie automatically with os.Getenv("AOC_TOKEN") when running :setday, it grabs from a file cookie.txt instead.
When using :setday and the cookie file doesn't exist, it creates an empty file to prevent reading errors (there may be a better way to do this though)
To use :setcookie the user needs to get the AoC cookie using the guide wimglenn/advent-of-code-wim#1 and type :setcookie <cookievalue>, the being everything between session= and the first ; on that string:

:setcookie 53616c2457214f5fd61f09acd05afad5e48ace27ae4917cfd0863c706cd508be236b52e3d2f4e2f90a252cb
(not a real cookie, just an example)

main.go Outdated
@@ -143,6 +143,16 @@ func main() {
eval = evaluator.New()
prev.eval = eval

case ":setcookie":
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if a command is really necessary here. Telling the user to put their token in AOC_TOKEN or token.txt seems good enough.

Maybe later we can try to automatically load the cookie from the browser, like some other AoC helpers do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, let me remove it then, just a moment

@Matthew-D12
Copy link
Author

Removed :setcookie, user has the option to add token to AOC_SESSION or cookie.txt (please feel free to rename it as you see fit)

@Matthew-D12
Copy link
Author

Also removed createCookieFile(), as now it will only be used from a single place

@lukechampine lukechampine merged commit 2cec92c into lukechampine:master Dec 8, 2021
@lukechampine
Copy link
Owner

thanks!

@lukechampine
Copy link
Owner

(I renamed cookie -> token)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants