Loading repository data…
Loading repository data…
mobeets / repository
Template for creating a twitter bot using python (twython) and heroku
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
This is a template for creating your own twitter bot using python and heroku. The only programming necessary is to update the function get_message() in app.py to create your bot's tweets.
Also, if you'd like to randomly favorite other users' tweets by keyword search, uncoment the call to random_favoriting() in main(), and change the keywords to those you'd like to search for.
Confused? Try reading this. Or contact me @jehosafet.
pip install Twython): for generating/posting tweets in python appFork and pull this repo.
In your local repo, create a new heroku app.
heroku create --stack cedarheroku apps:rename YOUR_APP_NAMEapp.py running as often as possible.Create a new twitter account.
From your main twitter account (not the one you just created, unless this is your first twitter account!) create a new twitter app.
$ gem install twurl$ twurl authorize --consumer-key "REPLACE_THIS" --consumer-secret "REPLACE_THIS"twurl asks you to go to a url to log-in, now use the bot account you just created.Create an .env file containing your twitter keys.
twurl generated some keys for your new bot account. You can find these in ~/.twurlrc..env that contains these twitter app keys, one per line:
TWITTER_CONSUMER_KEY=replace_thisTWITTER_CONSUMER_SECRET=replace_thisTWITTER_OAUTH_TOKEN=replace_thisOkay, now here's the fun part:
Update the function get_message() in app.py to create your bot's tweets.
Test your bot locally.
foreman start should generate your tweets once every minute, or at whatever rate you set in app.py.Commit and push local changes to heroku and github.
git push heroku master pushes all commits to heroku and starts up your app.TWITTER_OAUTH_TOKEN_SECRET=replace_thisheroku-config to copy contents of .env to your heroku app.
heroku plugins:install heroku-config.heroku config:push.
heroku config:push --overwriteheroku config:set YOUR_ENV_VAR=replace_this