A simple Twitter bot made with Python
- Looks for tweets that mention a user.
- Scans through the last 20 mentions for #HelloWorld
- If the mention contains #TeamSeas, it replies to the mention with the pounds of trash removed by #TeamSeas
- If the mention contains #HelloWorld, it replies to that tweet with
hi
For this to work, you need to have a Twitter developer account.
- To get a developer account, follow this tutorial.
- After getting a developer account, you need to create a project and an app
- To generate the keys, go to the app you created and go to
Keys and tokens
pip install -r requirements.txt
Create a file in the same folder as hello-twitter.py
named .env
and configure it as follows, then run the program (or you can use enviroment variables)
CONSUMER_KEY = "Your consumer key"
CONSUMER_SECRET = "Your consumer secret"
ACCESS_KEY = "Your access key"
ACCESS_SECRET = "Your access secret"
If you want to run this as a service edit the configuration of hello-twitter.service
to your needs
Then copy to /etc/systemd/system/
- Instead of storing keys in
config.py
store inJSONenviroment variables and.env
- Allow bot to scrape webpages and answer questions
For example, getting the amount of pounds of trash removed by #TeamSeas.DONE! (not with webscraping, downloading json instead) - Have a help command
If you find any bugs, please create a Github issue to report the bug so it can be fixed.