-
Notifications
You must be signed in to change notification settings - Fork 41
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
refactor main to use YAML parser and test with personal twitter bot #50
base: main
Are you sure you want to change the base?
refactor main to use YAML parser and test with personal twitter bot #50
Conversation
We can't use tweepy.API, because the twitter bot account is only allowed to use twitter API v2, which is compatible with tweepy.Client(). Also the loadenv file needed to be refactored because it wasn't working. Also changed the logic in main.py to suit the new reminders.txt format. Also created an example .env-example file to show the shape of what the .env files needs to be, and added .env to .gitignore.
With bearer token, I attempted to run this, and the error was: |
main.py
Outdated
# Select a random line from the reminders file. | ||
lines = [line[1:] for line in lines if line[0] == "-"] | ||
lines = [line[3:] for line in lines if len(line) > 2 and line[2] == "-"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like there might be a better solution here.
Maybe check if the first non-whitespace character is the hyphen or not, and if it is, remove all the whitespaces around it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So strip the line of white space and then check if the first character is a hyphen? That would work. But I'm not sure what you mean by "remove all the whitespaces around it". Still, I'll try making an edit.
Alternately, would it be better to use Python's yaml parser?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it might be better to use Python's YAML parser!
I will refactor this using the Python yaml parser. |
The bot does send tweets, with my personal bot credentials. See here: |
π¨βπ» Changes proposed
factor main and load_env plus just print for now
We can't use tweepy.API, because the twitter bot
account is only allowed to use twitter API v2,
which is compatible with tweepy.Client().
Also the loadenv file needed to be refactored
because it wasn't working.
Also changed the logic in main.py to suit the
new reminders.txt format.
Also created an example .env-example file to
show the shape of what the .env files needs
to be, and added .env to .gitignore.
mentions #40
βοΈ Check List (Check all the applicable boxes)
π Note to reviewers
We need a bearer-token to authenticate with the V2 Twitter API.
π· Screenshots