This is a Twitter bot written in Python using the Tweepy library that automatically retweets any tweet containing the hashtag #LFC (Liverpool Football Club). It uses the Twitter API to authenticate and interact with the Twitter platform.
Before running the bot, make sure you have the following:
- Python 3.x installed on your machine
- Tweepy library installed (
pip install tweepy
) - Twitter API credentials (consumer key, consumer secret, access token, and access token secret) obtained from the Twitter Developer Portal.
-
Clone this repository to your local machine:
git clone [repository_url]
-
Navigate to the project directory:
cd [project_directory]
-
Install the required dependencies using pip:
pip install -r requirements.txt
To configure the Twitter API credentials, you have two options:
-
Create a
.env
file in the project directory. -
Open the
.env
file and add the following lines:consumer_key=[your_consumer_key] consumer_secret=[your_consumer_secret] access_token=[your_access_token] access_token_secret=[your_access_token_secret]
-
Replace
[your_consumer_key]
,[your_consumer_secret]
,[your_access_token]
, and[your_access_token_secret]
with your actual Twitter API credentials.
Alternatively, you can directly modify the create_api()
function in the code and replace the corresponding variables with your Twitter API credentials:
consumer_key = 'your_consumer_key'
consumer_secret = 'your_consumer_secret'
access_token = 'your_access_token'
access_token_secret = 'your_access_token_secret'
To run the bot, execute the following command:
python bot.py
The bot will start streaming tweets with the given keywords and automatically retweet any tweet that contains the hashtag #LFC. It will also mark those tweets as Liked.
To customize the keywords, modify the main()
function in the code and provide a list of desired keywords:
if __name__ == "__main__":
main(["#LFC", "#Liverpool", "#YNWA"])
To deploy the Twitter bot to Heroku, follow these steps:
-
Create a new Heroku app either through the Heroku website or using the Heroku CLI.
-
Set the required environment variables (
consumer_key
,consumer_secret
,access_token
, andaccess_token_secret
) in your Heroku app's settings. -
Push the code to your Heroku app's repository:
git push heroku main
-
Scale up the worker dyno:
heroku ps:scale worker=1
Your bot will now be deployed on Heroku and start retweeting tweets with the specified keywords.
Note: Make sure your Heroku account is verified to use the worker dyno.
[Include license information for your project, if applicable.]