Bot simply can be installed by running code on machine using required variables in .env file
If you're using webhooks, you should set up reverse proxy. You can start with aiogram documentation or read tutorial on webhooks (the tutorial is in ukrainian🇺🇦). Both use nginx and tutorial uses certbot.
- Requirements
- Clone project
git clone https://github.com/RoLO0u/sticker-bot.git
- Install python requirements
pip install -r requirements.txt
⚠️ when having problems installing psycopg2: try runningon debian:
sudo apt-get install libpq-devon arch:
sudo pacman -Sy postgresql-libson Amazon Linux:
sudo yum -y install gcc python-setuptools python-devel postgresql-devel
- Set environment variables
Environment variables can be seen in Required variables part or in .env.example file
- Run programm
To run programm use simple command depending on your configuration:
python main.py
If you want to save logs in main.log
, you can use --log-file
arg
python main.py --log-file
Or use virtual environment variables AND docker
- DB - db name, which will be used for bot to store users info.
In current version either "mongodb" or "postgresql"
- MONGO_URI ─ uri to your mongo database
⚠️ mongodb isn't being tested: try on your own risk
- PGDATABASE - database information will be stored in. e.g. aiogram, to create use
CREATE DATABASE aiogram; -- or another database name
- PGHOST - your address to the postgresql. On local machines should be 127.0.0.1
- PGPORT - port to your postgresql server. Most likely 5432
- PGUSER - user who will be used to execute commands with (e.g. postgres).
- PGPASSWORD - password to user
- BOT_TOKEN ─ token bot will use to interact with telegram API
Use @BotFather to get bot token
- Just setting DEBUG to
True
allows the bot to use long polling
Additionally, this mode shows
DEBUG
level of logs
- Setting DEBUG to
False
tells the bot to use webhooks
Additionally, this mode shows
WARNING
level of logs
- WEBHOOK_SECRET ─ a string of random characters
- BASE_WEBHOOK_URL ─ an URL to which telegram will send updates to
If you're using self-signed certificate you should add certificate file to
set_webhook
method inlaunch.py
file
- WEBHOOK_SSL_CERT ─ path to your public sertificate
- WEBHOOK_SSL_PRIV ─ path to your private/secret sertificate
Make sure your user can read the file, otherwise the PermissionError will be raised
If you're encountering issues, read aiogram documentation or official telegram documentation
Run db_cli.py script to execute sql from "sql_queries" folder.
When using choose script to execute by entering its number or quit by entering "q"