Giter VIP home page Giter VIP logo

twitter-bot-bootstrap's Introduction

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.

Requirements

  • python
    • Install Twython (pip install Twython): for generating/posting tweets in python app
  • heroku

Instructions

  1. Fork and pull this repo.

  2. In your local repo, create a new heroku app.

    • heroku create --stack cedar
    • heroku apps:rename YOUR_APP_NAME
    • Your heroku app will now keep the python script app.py running as often as possible.
  3. Create a new twitter account.

  4. From your main twitter account (not the one you just created, unless this is your first twitter account!) create a new twitter app.

    • Under Settings / Application Type:
      • Enable "Read and Write"
      • Check "Allow this application to be used to Sign in with Twitter"
    • Under Details:
      • Click "Create My Access Token"
    • Connect this app to your bot's twitter acount (help here)
      • $ gem install twurl
      • $ twurl authorize --consumer-key "REPLACE_THIS" --consumer-secret "REPLACE_THIS"
    • When twurl asks you to go to a url to log-in, now use the bot account you just created.
  5. Create an .env file containing your twitter keys.

    • twurl generated some keys for your new bot account. You can find these in ~/.twurlrc.
    • In your local repo, create a file called .env that contains these twitter app keys, one per line:
      • TWITTER_CONSUMER_KEY=replace_this
      • TWITTER_CONSUMER_SECRET=replace_this
      • TWITTER_OAUTH_TOKEN=replace_this
      • TWITTER_OAUTH_TOKEN_SECRET=replace_this
    • For heroku, use heroku-config to copy contents of .env to your heroku app.
      • Install heroku-config: heroku plugins:install heroku-config.
      • Now run heroku config:push.
        • NOTE: To update heroku environment variables later, run heroku config:push --overwrite
        • Alternatively, add heroku environment variables manually using heroku config:set YOUR_ENV_VAR=replace_this

Okay, now here's the fun part:

  1. Update the function get_message() in app.py to create your bot's tweets.

  2. Test your bot locally.

    • Running foreman start should generate your tweets once every minute, or at whatever rate you set in app.py.
  3. Commit and push local changes to heroku and github.

    • git push heroku master pushes all commits to heroku and starts up your app.
    • Your bot should now tweet as long as your heroku app is running (via the worker dyno).

twitter-bot-bootstrap's People

Contributors

mobeets avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

twitter-bot-bootstrap's Issues

License

What's the license (public domain, ASL 2.0, GPL 2.0, etc.) for this code?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.