Twitter bot for Agrippa's Three Books of Occult Philosophy, translated by John French. This project was inspired by another similiar project by Nneji123, to whom I am grateful.
- About
- Contents
- Features
- Repository file structure
- Pre-requisites
- How to run the application
- Tests
The bot tweets a random line from previously sanitized text file containing all three volumes from John French's translation of Agrippa's Occult Philosophy. The text file can be found here. The code is located in the src folder.
├───.github # Github Workflows
│ └───workflows
├── data
│ └── agrippa.txt # book file
├── docker-compose.yml # for containerization with docker
├── Dockerfile
├── LICENSE
├── README.md
├── requirements.txt
├── src
│ ├── bot.py # bot file
| ├── utils.py # Helper functions
│ ├── __init__.py
│ ├── server.py # flask server
├── tests # Tests folder
├── __init__.py
└── conftest.py # pytest fixtures
└── test_utils.py # Test for the helper functions and environment files
In order to use the bot, you'll need to:
- Create a new Twitter account to act as the bot.
- Register for a twitter developer account.
- Create a twitter app. Make sure to give it Read and Write permissions.
- Host it locally by running a Flask server or upload the Docker image to an environment of your choice.
How to run the application locally.
- Clone this repository on your local machine
- Create a virtual environment in your project's root directory:
python3 -m venv environment && source environment/bin/activate
- Install the required libraries using pip:
pip install -r requirements.txt
- Create a file called
.env
in the root directory of your project. Put your twitter App keys there. You can also change the path to the text file. Once everything is tested, ready to deploy, you'll move these to environment variables. Make sure to add ".env" to the .gitignore!
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>
TEXT_PATH=data/agrippa.txt
- You can play around with the bot in
src/bot.py
- 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)
- Clone the repository:
git clone https://github.com/lombrosidade/agrippa.git
- Change to the directory:
cd agrippa
-
Edit the
.envexample
file and store your keys there. -
Run the docker compose command
docker compose up -d --build
The text should be tweeted then.
Test helper functions
To test the helper functions, do the following:
- Clone the repository:
git clone https://github.com/lombrosidade/agrippa.git
- Change the working directory and install the requirements and pytest:
cd agrippa
pip install -r requirements.txt
- Move to the tests folder and run the tests
pip install pytest
pytest tests