Skip to content

An automated Twitter bot that posts updates about the latest trends and news in the tech world

Notifications You must be signed in to change notification settings

dantealegria1/Twitter-Bot

Repository files navigation

Twitter Bot

This repository contains a Python script that retrieves data from the RAWG API and the News API to compose and post tweets. The script is designed to be run at scheduled intervals using GitHub Actions.

Features

  • Retrieves game-related data from the RAWG API.
  • Fetches news articles from the News API.
  • Composes and posts tweets with the fetched data.
  • Scheduled execution using GitHub Actions.

Prerequisites

Before using this bot, ensure you have the following:

  • API Keys:
    • RAWG API Key.
    • News API Key.
    • Twitter Developer API keys (API key, API secret, Access token, and Access token secret).
  • A GitHub account with access to create and manage repositories.

Installation and Setup

1. Clone the Repository

git clone https://github.com/dantealegria1/Twitter-Bot.git
cd Twitter-Bot

2. Configure Environment Variables

Create a .env file in the root directory and add the following:

API_KEY = ""
API_SECRET_KEY = ""
ACCESS_TOKEN = ""
ACCESS_TOKEN_SECRET = ""
GAMES_API_KEY = ""

3. Add .env to .gitignore

Ensure your .env file is ignored by Git to keep your credentials secure. The repository already includes .env in the .gitignore.

4. Install Dependencies

Use pip to install the required packages:

pip install -r requirements.txt

How It Works

  1. Data Retrieval:

    • The script fetches data from the RAWG API and News API.
    • It processes the data to create meaningful tweets about trending games or news.
  2. Tweet Posting:

    • The script uses the Twitter API to post tweets composed from the fetched data.
  3. Scheduling with GitHub Actions:

    • The bot is configured to run at regular intervals using a GitHub Actions workflow (.github/workflows/twitter-bot.yml).
    • The workflow triggers the Python script to execute on a predefined schedule.

Usage

Run Locally

You can run the script locally for testing:

python main.py or python main_Games.py

Automate with GitHub Actions

  1. Secrets Configuration:

    • Add the required API keys as GitHub Actions secrets in your repository:
    • API_KEY
    • API_SECRET_KEY
    • ACCESS_TOKEN
    • ACCESS_TOKEN_SECRET
    • GAMES_API_KEY
  2. Workflow File:

    • The .github/workflows/news.yml and .github/workflows/games.yml files defines the schedule for running the script.
  3. Enable GitHub Actions:

    • Ensure GitHub Actions is enabled for your repository.
    • The workflow will automatically execute based on the schedule defined in the YAML file.

Contributing

Contributions are welcome! If you have ideas to enhance the bot, feel free to fork the repository, make changes, and submit a pull request.

License

This project is licensed under the MIT License. See the LICENSE file for more details.


Let me know if you want me to help craft or refine specific sections, such as the GitHub Actions workflow file!

About

An automated Twitter bot that posts updates about the latest trends and news in the tech world

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages