April 14, 2023: This project is no longer maintained and @xkcd_bot
will no longer be updated. As of now an alternative on twitter is @xkcd_rss. On Mastodon a good option is @xkcdbot@botsin.space.
This is the code that reads the rss feed from xkcd and posts to @xkcd_bot.
I made this when I noticed @xkcdbot hasn't updated in a while. Afterwards I realized there's @xkcdrss. Still leaving this around since I spent an entire, like, hour doing this and may be useful for people that want to do their own twitter bot of some sort.
- setup virtualenv if you haven't yet. I like virtualenv-burrito to get up and going quick
- run
mkvirtualenv -r requirements.txt xkcd-twitter-bot
- copy
config-sample.ini
toconfig.ini
- go to http://dev.twitter.com and create an app for yourself. Make sure it has read/write access
- put the app api keys (
consumer_key
andconsumer_secret
) inconfig.ini
. - run
get_user_credentials.py
which will get you the user api keys (or you can generate on website if app is registered to same user that's posting) - put those values in
config.ini
- run
update_twitter.py -v
and it may actually work
For the upgrade from python2 to python3 the cache file will likely complain it's corrupt. While deleting the cache file and running update should cause twitter to complain about duplicate updates apparently it doesn't always. Best bet is to just have it post to a throwaway twitter account then change it back once the cache is updated.