https://github.com/nneji123/raplyricsbot
A Twitter Bot that tweets random rap lyrics made with Python and Tweepy.
https://github.com/nneji123/raplyricsbot
bot docker fastapi flask gitpod heroku python railway tests twitter twitter-api
Last synced: about 1 year ago
JSON representation
A Twitter Bot that tweets random rap lyrics made with Python and Tweepy.
- Host: GitHub
- URL: https://github.com/nneji123/raplyricsbot
- Owner: Nneji123
- License: mit
- Created: 2022-08-04T17:13:07.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-21T18:32:51.000Z (almost 4 years ago)
- Last Synced: 2025-05-04T21:57:11.612Z (about 1 year ago)
- Topics: bot, docker, fastapi, flask, gitpod, heroku, python, railway, tests, twitter, twitter-api
- Language: Python
- Homepage: https://twitter.com/__Raplyrics
- Size: 2.06 MB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# RapLyricsBot :robot:
[](https://www.python.org)
[](https://github.com/Nneji123/Raplyricsbot)


[](https://twitter.com/__RapLyricsBot)

[](https://gitpod.io/#https://github.com/Nneji123/RapLyricsBot)

[](https://github.com/Nneji123/RapLyricsBot/actions/workflows/test.yml)
[](https://github.com/Nneji123/RapLyricsBot/actions/workflows/codeql.yml)
## About :speech_balloon:
>A Twitter Bot that tweets Rap lyrics made with Python, Tweepy and Flask and deployed with RailWay.
Twitter: https://twitter.com/__RapLyrics
## Contents :page_with_curl:
* [About :speech_balloon:](#about--speech-balloon-)
* [Contents :page_with_curl:](#contents--page-with-curl-)
* [Features :star2:](#features--star2-)
* [Repository File Structure :file_folder:](#repository-file-structure--file-folder-)
* [Pre-requisites :boom:](#pre-requisites--boom-)
* [How to run the Application :question:](#how-to-run-the-application--question-)
* [Tests :keyboard:](#tests--keyboard-)
* [Deployment :computer:](#deployment--computer-)
- [Todo :bookmark_tabs:](#todo--bookmark-tabs-)
- [License :page_with_curl:](#license--page-with-curl-)
## Features :star2:
The bot works by reading and parsing a text file containing the lyrics. The text file can be found [here.](https://github.com/Nneji123/Raplyricsbot/data/Rap_lyrics.txt) The code can be found in the [src](https://github.com/Nneji123/Raplyricsbot/src) folder.
## Repository File Structure :file_folder:
```bash
├───.github # Github Workflows
│ └───workflows
├── app.json # For Deploying to Heroku
├── data
│ └── Rap_lyrics.txt # lyrics file
├── docker-compose.yml # For Containerization with Docker
├── Dockerfile
├── LICENSE
├── README.md
├── Procfile # For deploying to Heroku and Railway
├── requirements.txt
├── src
│ ├── bot.py # Tweet bot
│ ├── __init__.py
│ ├── server.py # flask server
├── tests # Tests folder
├── __init__.py
└── test_bot.py
```
## Pre-requisites :boom:
To build and use the bot, you'll need to:
1. Create a new Twitter account to act as the bot.
2. Register for a [twitter developer account.](https://developer.twitter.com/en)
3. Create a [twitter app](https://developer.twitter.com/en/portal/projects-and-apps). Make sure to give it **Read and Write** permissions.
4. Set up a [Railway](https://railway.app/) or [Heroku Account.](https://heroku.com)
## How to run the Application :question:
How to Run the application locally.
To make your own bot follow these steps:
1. Clone this repository on your local machine
2. Create a virtual environment in your project's root directory: `python3 -m venv environment && source environment/bin/activate`
3. Install the required libraries using pip: `pip install -r requirements.txt`
4. Create a file called `.env` in the root directory of your project. Put your twitter App keys there (and any other keys required for scraping data if needed).
* THIS IS JUST FOR TESTING. Once everything is tested and ready to deploy, you'll move these to environment variables.
* ADD THIS FILE(`.env`) TO THE .gitignore so you're not putting your api keys publicly on github!
```
ACCESS_TOKEN=
ACCESS_TOKEN_SECRET=
CONSUMER_KEY=
CONSUMER_SECRET=
```
1. Make changes in the logic of the bot by modyifing `src/bot.py`
2. Test your changes locally by running `python src/bot.py` from the root directory of your project
Running on Local Machine with Docker Compose
**You can also run the application in a docker container using docker compose(if you have it installed)**
1. Clone the repository:
```bash
git clone https://github.com/Nneji123/RapLyricsBot.git
```
2. Change the directory:
```
cd RapLyricsBot
```
3. Edit the `.envexample` file and store your keys there.
4. Run the docker compose command
```docker
docker compose up -d --build
```
And then the lyrics should be tweeted.
Running in a Gitpod Cloud Environment
**Click the button below to start a new development environment:**
[](https://gitpod.io/#https://github.com/Nneji123/RapLyricsBot)
## Tests :keyboard:
Test Bot
To test the API functions do the following:
1. Clone the repository:
```
git clone https://github.com/Nneji123/RapLyricsBot.git
```
2. Change the working directory and install the requirements and pytest:
```
cd Raplyricsbot
pip install -r requirements.txt
```
3. Move to the tests folder and run the tests
```
pip install pytest
pytest tests
```
## Deployment :computer:
Deploying the Bot to Heroku
Click the button below to deploy the application.
[](https://heroku.com/deploy)
Deploy the Bot to Railway
Click the button below to deploy the bot to railway
[](https://railway.app/new/template/k_WXDI?referralCode=ZYOf2M)
# Todo :bookmark_tabs:
- [x] Add more lyrics
- [x] Change this from a Rap lyrics bot to a general rap bot
- [x] Get more lyrics using this library https://github.com/johnwmillr/LyricsGenius
- [x] Update Readme.
- [x] Update tests
# License :page_with_curl:
[MIT](https://github.com/Nneji123/RapLyricsBot/LICENSE.md)