DiscordGIR / Bloo

The best Discord bot, created for r/Jailbreak
MIT License
36 stars 10 forks source link

Bloo

Bloo is a sophisticated moderation and miscellaneous utilities Discord bot created for the r/Jailbreak Discord server. It features:

Bloo is custom made for the r/Jailbreak server and therefore there is no publicly running bot you can invite to your own server. However, you can self-host it as is or fork the code and modify it to your own requirements!


Pre-setup instructions

These instructions should work on macOS, Windows and Linux.

Setting up the .env file

  1. Copy the .env.example to a file called .env
  2. Start filling in the values as you want it set up. Follow the comments for hints.
  3. For the DB_HOST variable:
    • If running the bot without Docker (not recommended), you can change DB_HOST to localhost instead.
    • If running Mongo without Docker, host.docker.internal works on macOS and Windows, on Linux you can use 172.17.0.1.
    • If running Mongo in Docker, set DB_HOST to mongo

NOT RECOMMENDED FOR PRODUCTION DUE TO POOR PERFORMANCE Optionally, you can use MongoDB Atlas instead of a local Mongo server, or you can ask SlimShadyIAm on Discord for access to the shared test database. In that case, you use: DB_CONNECTION_STRING=mongodb+srv://..... instead of DB_HOST and DB_PORT.

Setting up the bot

Production setup

This setup uses Docker for deployment. You will need the following:

Alternatively, you could set up the bot without Docker using PM2 but I won't provide instructions for that.

Steps

  1. Set up the .env. file. Keep in mind whether or not you want to use Mongo in Docker or not.
  2. Set up the database.
  3. Skip this step if running Mongo without Docker. If you want to run Mongo in Docker, you will need to edit docker-compose.yml slightly. Open it and follow the comments.
  4. Run the bot using docker-compose up -d --build.

If everything is successful, the bot should be online in a few seconds. Otherwise, check the container's logs: docker-compose logs bloo.

The bot can be updated in the future by running: git pull && docker-compose up -d --build --force-recreate


Development setup: with Docker (recommended!)

You will need the following installed:

Steps

  1. Clone the repository and open the folder in Visual Studio Code
  2. Install the Microsoft Remote Development plugin
  3. Make sure that Docker is running
  4. Open the Command Palette (CMD+Shift+P or CTRL+Shift+P) and run "Remote-Containers: Reopen In Container"
  5. VSCode should build the Docker image and open it automatically; this may take a couple of minutes as it has to install some extensions as well.
  6. Set up the .env file as shown here.
  7. Make sure the database is set up (see below).
  8. Open the integrated terminal in VSCode and run the bloo command to start the bot with hot reload!

Note that if you make changes to the Dockerfile, .devcontainer.json, or need to install a new requirement, you need to rebuild the Docker image. You can do this through the Command Palette again, run "Remote-Containers: Rebuild Container".


Development setup: without Docker (not recommended)

You will need the following installed:

Steps

  1. Inside the root folder of the project, run python3 -m venv venv/
  2. source venv/bin/activate
  3. pip3 install -r requirements.txt
  4. Set up the .env file as shown here.
  5. Make sure the database is set up (see below).
  6. python3 main.py

Database setup

If you have an existing dump of the database, make sure Mongo is running, then you can run mongorestore <dump foldername>. This can also be done if running Mongo in Docker by first copying the dump to the Mongo container with docker cp.

If setting up the database from scratch, follow these instructions:

  1. Make sure you filled out the right values for the .env file as explained above.
  2. Open up setup.py and fill in ALL the values. The bot's permissions, and as a result the bot itself, will not work without them.
  3. Run setup.py:
    • If running the bot without Docker, follow the first few setup instructions until you need to set up the database, activate the virtualenv and then run python3 setup.py. Then you can proceed with the rest of the setup instructions.
    • If running the bot with Docker in production, start the container then run: docker exec -it <Bloo container name> python3 setup.py (if you get an error about the container restarting, restart the container and try to run the command again immediately). You can find the container name by running docker container ls in the project folder. After it's setup, restart the container. Note: changes to setup.py won't be transferred until you rebuild the container. So build the container AFTER setup.py is set up how you want.
    • If running the bot with Docker in development, you can just run python3 setup.py in the integrated bash shell.

If you want to inspect or change database values:


Contributors


SlimShadyIAm

stekc

Ultra03

ja1dan

donato-fiore

m1stadev

mass1ve-err0r

sqlstatement

beerpsi

Special thanks

Special thanks to the following people for ideas, testing, or help: