dipinknair / LFC_twitter_bot

This is a Twitter bot made to retweet #LFC tagged tweets. Written in python and running on Hiroku cloud platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Twitter Bot: Auto Retweet with #LFC

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.

Prerequisites

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.

Installation

  1. Clone this repository to your local machine:

    git clone [repository_url]
  2. Navigate to the project directory:

    cd [project_directory]
  3. Install the required dependencies using pip:

    pip install -r requirements.txt

Configuration

To configure the Twitter API credentials, you have two options:

Option 1: Environment Variables

  1. Create a .env file in the project directory.

  2. 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]
    
  3. Replace [your_consumer_key], [your_consumer_secret], [your_access_token], and [your_access_token_secret] with your actual Twitter API credentials.

Option 2: Direct Configuration

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'

Usage

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"])

Deploying to Heroku

To deploy the Twitter bot to Heroku, follow these steps:

  1. Create a new Heroku app either through the Heroku website or using the Heroku CLI.

  2. Set the required environment variables (consumer_key, consumer_secret, access_token, and access_token_secret) in your Heroku app's settings.

  3. Push the code to your Heroku app's repository:

    git push heroku main
  4. 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.

License

[Include license information for your project, if applicable.]

About

This is a Twitter bot made to retweet #LFC tagged tweets. Written in python and running on Hiroku cloud platform

License:MIT License


Languages

Language:Python 98.6%Language:Procfile 1.4%