SpinEverydayBot v2
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
- (Optional.) Create and set up new virtualenv for the project.
- Install requirements from
requirements.txt
by runningpip install -Ur requirements.txt
. - Create
config.yaml
in current directory or in~/.config/spin_everyday_bot/2.x/
. - 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: ...
- Migrate database by running
alembic upgrade head
Running
Polling
It's as easy as python -m spin_everyday_bot
Webhooks
- 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.
- Set up a reverse-proxy like nginx with above certificate and pointing to
http://localhost:8880/
. - Install additional requirements:
pip install -U "FastAPI~=0.68.0" uvicorn
. - 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!
- Make sure the project is set up and up-to-date.
- Install additional requirements from
dev-requirements.txt
. - 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="[email protected]" \ --copyright-holder="Evgeniy Filimonov <[email protected]>" \ --project=spin_everyday_bot --version=2.0.0-alpha.0 \ -o spin_everyday_bot/lang/spin_everyday_bot.pot -w 99 \ spin_everyday_bot
- 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
- Commit and push changes to your branch/fork.
- Create a pull request.
License
Licensed under GNU AGPL v3, see LICENSE.