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.
- 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.
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.
git clone https://github.com/dantealegria1/Twitter-Bot.git
cd Twitter-BotCreate a .env file in the root directory and add the following:
API_KEY = ""
API_SECRET_KEY = ""
ACCESS_TOKEN = ""
ACCESS_TOKEN_SECRET = ""
GAMES_API_KEY = ""Ensure your .env file is ignored by Git to keep your credentials secure. The repository already includes .env in the .gitignore.
Use pip to install the required packages:
pip install -r requirements.txt-
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.
-
Tweet Posting:
- The script uses the Twitter API to post tweets composed from the fetched data.
-
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.
- The bot is configured to run at regular intervals using a GitHub Actions workflow (
You can run the script locally for testing:
python main.py or python main_Games.py-
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
-
Workflow File:
- The
.github/workflows/news.ymland.github/workflows/games.ymlfiles defines the schedule for running the script.
- The
-
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.
Contributions are welcome! If you have ideas to enhance the bot, feel free to fork the repository, make changes, and submit a pull request.
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!