Skip to content

evgfilim1/spin_everyday_bot

Repository files navigation

SpinEverydayBot v2

Codacy badge wakatime badge Crowdin badge Requirements badge Code style: black License badge

Telegram bot for everyday raffles. HIGHLY EXPERIMENTAL! WORK IN PROGRESS!

Setting up

Requirements

  • Python 3.9+
  • PostgreSQL 13+

Older versions might work, but not tested. If they do work, submit an issue.

Steps

  1. (Optional.) Create and set up new virtualenv for the project.
  2. Install requirements from requirements.txt by running pip install -Ur requirements.txt.
  3. Create config.yaml in current directory or in ~/.config/spin_everyday_bot/2.x/.
  4. Open your config.yaml and edit it to match your setup.
    telegram:
      token: ...
      superuser_id: ...
    db:
      host: 127.0.0.1
      port: 5432
      user: ...
      database: ...
      password: ...
  5. Migrate database by running alembic upgrade head

Running

Polling

It's as easy as python -m spin_everyday_bot

Webhooks

  1. Make sure you've got HTTPS certificate. Please note that self-signed ones are not yet supported, go and create one with Let's Encrypt. If you don't have a domain name, but you have static IP, use nip.io to create "fake" domain.
  2. Set up a reverse-proxy like nginx with above certificate and pointing to http://localhost:8880/.
  3. Install additional requirements: pip install -U "FastAPI~=0.68.0" uvicorn.
  4. Run python -m spin_everyday_bot webhook -u "<WEBHOOK_URL>", where <WEBHOOK_URL> is the URL for Telegram to make requests to.

Updating

Before you run a new version after updating, make sure your database is up-to-date by running migrations and check whether your config matches (see Setting up section for more info).

Contributing

Oh, you wanna contribute? That's nice!

  1. Make sure the project is set up and up-to-date.
  2. Install additional requirements from dev-requirements.txt.
  3. Make changes to the code.
  • If you made any changes to db, make sure you created a migration by running alembic revision --autogenerate -m '<description>' and verified it.
  • If you made any changes which require translation changes, make sure you generated a new translation template by running
    pybabel extract \
       --msgid-bugs-address="evgfilim1@yandex.ru" \
       --copyright-holder="Evgeniy Filimonov <evgfilim1@yandex.ru>" \
       --project=spin_everyday_bot --version=2.0.0-alpha.0 \
       -o spin_everyday_bot/lang/spin_everyday_bot.pot -w 99 \
       spin_everyday_bot
  1. Run some tools to make code style better
    isort --py 39 -p spin_everyday_bot --profile black -l 100 --tc --gitignore spin_everyday_bot
    black -l 100 -t py39 spin_everyday_bot
  2. Commit and push changes to your branch/fork.
  3. Create a pull request.

License

Licensed under GNU AGPL v3, see LICENSE.