cheran-senthil / TLE

🤖 Discord Bot for Competitive Programming
https://discordapp.com/invite/2CJ6qvY
MIT License
318 stars 202 forks source link
codeforces discord discord-bot python

TLE

TLE is a Discord bot centered around Competitive Programming.

Features

The features of the bot are split into a number of cogs, each handling their own set of commands.

Codeforces cogs

CSES cog

Other cogs

Installation

If you want to run the bot inside a docker container follow these instructions

Clone the repository

git clone https://github.com/cheran-senthil/TLE

Optional: venv

If you want to isolate the TLE python environment from your system one, now would be the time to do it. See the venv documentation for details.

If you decide to use a venv there is some convenience logic in the startup script to automatically active your venv when running the bot. See Environment Variables for details.

Dependencies

Now all dependencies need to be installed. TLE uses Poetry to manage its python dependencies. After installing Poetry navigate to the root of the repo and run

poetry install

:warning: TLE requires Python 3.7 or later!

If you are using Ubuntu with older versions of python, then do the following:

apt-get install python3.7-venv libpython3.7-dev
python3.7 -m pip install poetry
python3.7 -m poetry install

On some systems, Poetry is not able to install TLE's dependencies correctly. If you are unable to run poetry install without errors after completing the steps below, see the note at the end of the final steps section.


Library dependencies

TLE also depends on cairo and pango for graphics and text rendering, which you need to install. For Ubuntu, the relevant packages can be installed with:

apt-get install libcairo2-dev libgirepository1.0-dev libpango1.0-dev pkg-config python3-dev gir1.2-pango-1.0

Additionally TLE uses pillow for graphics, which requires the following packages:

apt-get install libjpeg-dev zlib1g-dev

Final steps

You will need to setup a bot on your server before continuing, follow the directions here. Following this, you should have your bot appearing in your server and you should have the Discord bot token. Finally, go to the Bot settings in your App's Developer Portal (in the same page where you copied your Bot Token) and enable the Server Members Intent.

Create a new file environment.

cp environment.template environment

Fill in appropriate variables in new "environment" file.

Environment Variables

To start TLE just run:

./run.sh

On some systems, Poetry is unable to correctly install TLE's dependencies even after completing the above steps. In this case, using Pip to manage the dependencies instead may work. Note that Poetry still must be installed.

To install dependencies in a virtual environment using Pip and start TLE, just run:

./run-pip.sh

Notes

Usage

In order to run bot commands you can either ping the bot at the beginning of the command or prefix the command with a semicolon (;), e.g. ;handle pretty.

In order to find available commands, you can run ;help which will bring a list of commands/groups of commands which are available. To get more details about a specific command you can type ;help <command-name>.

Contributing

Pull requests are welcome. For major changes please open an issue first to discuss what you would like to change.

Before submitting your PR, consider running some code formatter on the lines you touched or added. This will help reduce the time spent on fixing small styling issues in code review. Good options are yapf or autopep8 which likely can be integrated into your favorite editor.

Please refrain from formatting the whole file if you just change some small part of it. If you feel the need to tidy up some particularly egregious code, then do that in a separate PR.

License

MIT