My first project working with tweepy, and was very satisfying! Is very easy to use and the possibilities are huge. Now I understand why 15% of the Twitter users are bots. And I want to be part of this too!
-
You will need the credentials for authentication on API's Twitter, you can check this to know how to get the credentials.
-
If you will only uses the bots locally, just ignore the files
Procfile
andruntime.txt
, they are for deploy on Heroku only. -
But if you want to deploy on Heroku, here is a tutorial for this.
- Clone this repo to your local machine using
https://github.com/willy-r/twitter-bots.git
- Go to
twitter-bots
directory:
$ cd twitter-bots
- I highly recommend you to setup a virtual environment first:
$ python3 -m venv env
- With your credentials, you need to configurate this enviroment variables:
$ export ACCESS_TOKEN='your_access_token'
$ export ACCESS_TOKEN_SECRET='your_access_token_secret
'
$ export CONSUMER_KEY='your_consumer_key'
$ export CONSUMER_SECRET='your_consumer_secret'
- Now activate the virtual environment and install the dependencies:
$ source env/bin/activate
(env) $ pip install -r requirements.txt
Go to bots/
directory and use:
change
bot_name.py
with the bot name you want. To stop the bot useCTRL + C
.
(env) $ python3 bot_name.py
To add more just follow the code on this bots:
Bot name | Description |
---|---|
bots/fav_mention.py |
Automatically favorites a tweet when mentioned. |
bots/tweet_pi_time.py |
Tweets the pi time of a day. |
Reach out to me at one of the following places!
- Twitter at
@lliw_r