GitXplorerGitXplorer
a

codres-bot

public
0 stars
0 forks
0 issues

Commits

List of commits on branch main.
Verified
12d9c37e252790b46fe678dec35ae9e4a196a53d

Update README.md

aaerfanr committed 3 years ago
Unverified
546b561771b9ea4f3d74ebec4599a7bfd5c2c2c4

Added regex filtering

aaerfanr committed 3 years ago
Unverified
f0d979cb4f129a73ac838fac9083748e2b3c7d5a

Seperated defination of constants

aaerfanr committed 3 years ago
Unverified
286dfa7969eb09d53d93ce73d0cf72d95ef8340a

Changed event limits

aaerfanr committed 3 years ago
Unverified
580845c6a47c2deed4dc2544e2348bdd6faf861e

reformated code

aaerfanr committed 3 years ago
Verified
79bc2bbb1e899f72912777d517a96aeb55c07126

Create .gitignore

aaerfanr committed 3 years ago

README

The README file for this repository.

codres-bot

A telegram bot for sending Competetive Programming contest notifications to channels.

TODO for next release:

  • [x] Regex filtering support

Manual deployment

  1. Deploy a redis server
  2. Clone the repository
git clone https://github.com/aerfanr/codres-bot.git
  1. Install python requirements
pip install -r requirements.txt
  1. Modify launch.sh file. You may need to change CODRES_DB_HOST and CODRES_DB_PORT fields.
  2. Execute launch.sh.
./launch.sh

Deployment using docker-compose

  1. Set up Docker and Docker Compose
  2. 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/

  1. Modify docker-compose.yaml.example and env.example to your need
  2. Copy files to their correct names
cp docker-compose.yaml.example docker-compose.yaml
cp env.example .env
  1. Deploy the project
docker-compose up -d

You can also deploy the bot using other tools (Docker without compose, podman etc.)

Configuration

Configuration is available using environment variables and files in config directory.

Changing environment variables

You can change environment variables by editing launch.sh file or in docker, using -e run option or specifying them in docker-compose.yaml.

List of environment variables

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']

Changing config files

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
                ...

Message templates

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

Changing resources

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/

Using proxy with docker-compose

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