Skip to content
ericthelemur edited this page Dec 31, 2022 · 4 revisions

Documentation

Apollo is a Discord bot for the University of Warwick Computing Society. It is designed to augment our Discord server with a few of the user services available on our website.

Installation

  1. Create a new virtual environment python -m venv venv.
  2. Activate the virtual environment
    • On Linux and macOS: source venv/bin/activate.
    • On Windows: .\venv\Scripts\activate
  3. Install dependencies pip install -r requirements.txt
  4. Copy config.example.yaml to config.yaml and configure the fields.
  5. Copy alembic.example.ini to alembic.ini.
  6. Set up the database by running migrations with alembic upgrade head.
    • In production, Postgres is recommended instead of SQLite.
  7. On the Discord Developer Portal, create your bot and give it member and message content intents.
  8. Run python apollo.py.

Contributing

Contributor Notes

  • TODO Update

  • When writing anything that needs to reply to a specific username, please do from utils import get_name_string and get the display string using this function, with the discord Message object as the argument (e.g. display_name = get_name_string(ctx.message)). This will return either a discord username, formatted correctly, or an irc nickname depending on the source of the message. Finally, this can be used as normal in a format string e.g. await ctx.send(f'Sorry {display_name}, that won't work.').

  • When writing a new command, please read in the rest of the message using *args: clean_content (see cogs/commands/flip.py as an example), and if you need it as one large string, use " ".join(args). This is instead of reading the whole message content, which will likely break the irc bridging (unless you know what you're doing).

  • This project uses the Black Python formatter. Before submitting your code for a PR, run black . on the root directory of this project to bring all of your up to spec for the code style guide.

  • For testing CI locally, use act-cli.

  • The current production database engine is PostgreSQL. You may wish to use another database engine such as MySQL or SQLite for local testing.

  • To create a DB migration:

    1. Create model in /models
    2. Import in /models/__init__.py
    3. Run alembic revision --autogenerate -m "<change description>"
    4. Check the newly created upgrade and downgrade is correct
    5. Upgrade your database with alembic upgrade head
Clone this wiki locally