A telegram bot for sending Competetive Programming contest notifications to channels.
- Regex filtering support
- Deploy a redis server
- Clone the repository
git clone https://github.com/aerfanr/codres-bot.git
- Install python requirements
pip install -r requirements.txt
- Modify
launch.sh
file. You may need to changeCODRES_DB_HOST
andCODRES_DB_PORT
fields. - Execute
launch.sh
.
./launch.sh
- Set up Docker and Docker Compose
- Clone the repository
git clone https://github.com/aerfanr/codres-bot.git
or you can just download docker-compose.yaml.example
, env.example
and (optionally) config/
- Modify
docker-compose.yaml.example
andenv.example
to your need - Copy files to their correct names
cp docker-compose.yaml.example docker-compose.yaml
cp env.example .env
- Deploy the project
docker-compose up -d
You can also deploy the bot using other tools (Docker without compose, podman etc.)
Configuration is available using environment variables and files in config
directory.
You can change environment variables by editing launch.sh
file or in docker, using -e
run option or specifying them in docker-compose.yaml
.
environment variable | default value | description |
---|---|---|
CODRES_APIKEY | Clist API Key | |
CODRES_TELEGRAM_KEY | Telegram bot API Token | |
CODRES_TELEGRAM_ID | Telegram channel ID (prefixed with '@' or '-') | |
CODRES_DB_HOST | localhost | Redis database hostname |
CODRES_DB_PORT | 6379 | Redis database port |
CODRES_DATETIME_FORMAT | %Y-%m-%d %H:%M | Date and time output format |
CODRES_TIMEZONE | UTC | Output Timezone, example: 'Asia/Tehran' |
CODRES_CALENDAR | gregorian | Calendar to use, options: ['gregorian', 'jalali'] |
If you are using docker, you should mount a volume on /usr/src/app/config
and add your templates there. For docker-compose, you can add this to codres
service in docker-compose.yaml
:
codres:
...
volumes:
- ./config:/usr/src/app/config
...
The bot sends two kinds of messages. You can edit config/message1
and config/message2
to change message template. Basic HTML formatting is supported.
You can use these variables in your templates:
variable | description |
---|---|
{name} | Title of the contest |
{href} | Link to the contest page |
{start} | Start time of the contest |
You can add resources to config/resources
file. Each resource in a single line. Here is a list of available resources: https://clist.by/resources/
If you need a proxy, you can add http_proxy
and https_proxy
to the environments section in docker-compose.
...
codres:
...
environment:
...
- http_proxy
- https_proxy
...
and add a proxy server in .env
http_proxy=http://X.X.X.X:Y
https_proxy=http://X.X.X.X:Y