This repository helps to run tle directly in the heroku. For more information about TLE, check the main repository.
- Download the heroku CLI from here
- Now after installing the CLI, open up the CLI if you are on windows or open up a terminal if you are on linux.
- Now enter the command
heroku login
and it will open up a link in the browser for login. Login using your credentials. - Now clone this repository from the terminal using the command
git clone https://github.com/fishy15/TLE.git
. - After cloning move into the TLE directory using
cd TLE
. - Now enter
heroku create
command in the terminal and hit enter. It will create a new app for you. Remember the name. - Now you need to add two buildpacks to deploy. The APT buildpack to install essential APT files and Python buildpack to install essential packages.
- To add APT buildpack type the following command
heroku buildpacks:add heroku-community/apt
. - To add Python buldpack type the following command
heroku buildpacks:add heroku/python
.Note: the order of adding the buildpacks is important.
- Now go to the personal dashboard page of heroku on your browser.
- Next click on the app you created in step 6.
- Now, go to resources and click on Find more add-ons and find Heroku Postgres.
- Click to install the database on the Hobby Dev plan and set the app to the one that hosts the bot.
- Go to settings tab and you will see a section called Config Vars. Click on the reveal config vars button.
- Now you need to create a config var called
BOT_TOKEN
and paste your bot token created using discord and hit add. - Make sure that the name of the config var that contains the database url is named
DATABASE_URL
. - Now you are almost done. Type the following command
git push heroku master
and press enter. - It will take few minutes to build and deploy
- After successful build open the heroku app in your browser. The same step as 10.
- Go to Resources tab and turn on the worker. You are not charged for doing this its completely free.
- That's it Enjoy!
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
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.
- BOT_TOKEN: the Discord Bot Token for your bot.
- LOGGING_COG_CHANNEL_ID: the Discord Channel ID of a Discord Channel where you want error messages sent to.
- ALLOW_DUEL_SELF_REGISTER: boolean value indicating if self registration for duels is enabled.
- TLE_ADMIN: the name of the role that can run admin commands of the bot. If this is not set, the role name will default to "Admin".
- TLE_MODERATOR: the name of the role that can run moderator commands of the bot. If this is not set, the role name will default to "Moderator".
To start TLE just run:
./run.sh
- In order to run admin-only commands, you need to have the
Admin
role, which needs to be created in your Discord server and assign it to yourself/other administrators. - In order to prevent the bot suggesting an author's problems to the author, a python file needs to be run (since this can not be done through the Codeforces API) which will save the authors for specific contests to a file. To do this run
python extra/scrape_cf_contest_writers.py
which will generate a JSON file that should be placed in thedata/misc/
folder. - In order to display CJK (East Asian) characters for usernames, we need appropriate fonts. Their size is ~36MB, so we don't keep in the repo itself and it is gitignored. They will be downloaded automatically when the bot is run if not already present.
- One of the bot's features is to assign roles to users based on their rating on Codeforces. In order for this functionality to work properly, the following roles need to exist in your Discord server
- Newbie
- Pupil
- Specialist
- Expert
- Candidate Master
- Master
- International Master
- Grandmaster
- International Grandmaster
- Legendary Grandmaster
- One of the bot's commands require problemsets to be cached. Run
;cache problemsets all
at the very first time the bot is used. The command may take around 10 minutes to run.
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>
.
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.