This repository holds the source code of a bot that utilizes Twitter API V2.
The bot will constantly search through the Twitter timeline for tweets containing
your specified keywords, which can be edited in the track.json
file.
Note: Due to recent changes in Twitter Developer accounts, Free plan is not able to search tweets or retweet them. You should have a Basic or Pro account to use this bot.
First you should (or it is recommended to) install Poetry for package management:
pip install poetry
Install all the required packages based on poetry.lock
using this command:
poetry install
To update all packages to their latest versions you can use this command:
poetry update
python src/main.py
This bot simply uses keywords in this file to find desired tweets. This file consists of two parts:
include
: All keywords, hashtags, and mentions that should exist in the tweets bot is looking for.exclude
: All keywords, hashtags, and mentions that should NOT exist in the tweets.
This is the entry point of the program. It Gets keywords from src/track.json
and processes them and
generates valid search rules for out Twitter bot. It also runs a Flask web server to monitor or control
the bot's activity. Finally it runs the bot's main application.
This file defines the application and behavior of this Twitter bot. It is using Twitter API v2 StreamingClient to monitor Twitter live steam of tweets based on the rules defined for it.
Currently the bot only likes and retweets the tweets that match the rules.
A Flask web server is run to monitor or control the bots activity.
This file is a independent utility to generate user-specific access tokens for the bot's Twitter API app and the bot's functionality is not related to this file.
- Read key-value pairs from a .env file and set them as environment variables
- Hello Tweepy
- Post tweet with tweepy
- Obtaining Access Tokens using 3-legged OAuth flow
- tweepy.Stream — Stream Reference
- How to Make a Twitter Bot in Python With Tweepy
- Getting Started With Flask, A Python Microframework
- A hello world app in Flask for deploying to Heroku.
- Tweet Quote Bot
- tweepy unauthorized 401 error when retweeting
- Relative imports - ModuleNotFoundError: No module named x
- Heroku: The Procfile
- Twitter Retweet Bot using Python & Tweepy
- Wake my Dyno!
- How do I allow a file to be viewed?
- Filter realtime Tweets
- Building a Discord Bot with Python and Repl.it
- GitHub Webhooks
- Verify GitHub webhook request sha256 in PHP
- Stream encountered HTTP error: 403
- PIN-based authorization
- Twitter API V2 Programming with Python and Tweepy
- POST /2/tweets/search/stream/rules
- Invalid Rules Problem
- Deploy on Fly.io