Best Flask open-source libraries and packages

RapLyricsBot

A Twitter Bot that tweets random rap lyrics made with Python and Tweepy.
Updated 1 year ago

RapLyricsBot 🤖

Language Framework hosted hosted Twitter Docker Gitpod reposize tests CodeQL

About 💬

A Twitter Bot that tweets Rap lyrics made with Python, Tweepy and Flask and deployed with RailWay.

Twitter: https://twitter.com/__RapLyrics

Contents 📃

Features 🌟

The bot works by reading and parsing a text file containing the lyrics. The text file can be found here. The code can be found in the src folder.

Repository File Structure 📁

├───.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 💥

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.
  3. Create a twitter app. Make sure to give it Read and Write permissions.
  4. Set up a Railway or Heroku Account.

How to run the Application ❓

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=<YOUR_ACCESS_TOKEN_HERE>
ACCESS_TOKEN_SECRET=<YOUR_ACCESS_TOKEN_SECRET_HERE>
CONSUMER_KEY=<YOUR_CONSUMER_KEY_HERE>
CONSUMER_SECRET=<YOUR_CONSUMER_SECRET_HERE>
  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:
git clone https://github.com/Nneji123/RapLyricsBot.git
  1. Change the directory:
cd RapLyricsBot
  1. Edit the .envexample file and store your keys there.

  2. Run the docker compose command

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:

Open in Gitpod

Tests ⌨️

Test Bot

To test the API functions do the following:

  1. Clone the repository:
git clone https://github.com/Nneji123/RapLyricsBot.git
  1. Change the working directory and install the requirements and pytest:
cd Raplyricsbot
pip install -r requirements.txt
  1. Move to the tests folder and run the tests
pip install pytest
pytest tests

Deployment 💻

Deploying the Bot to Heroku

Click the button below to deploy the application.

Deploy

Deploy the Bot to Railway Click the button below to deploy the bot to railway

Deploy on Railway

Todo 📑

License 📃

MIT

Tags bot docker