This commit is contained in:
Evgeny Zinoviev 2021-05-16 02:15:15 +03:00
parent d268a3ddfa
commit 3b1aab5451

View File

@ -15,23 +15,26 @@ It requires Python 3.6+ or so.
## Configuration ## Configuration
Configuration is stored in `config.ini` file in `~/.config/inverter-bot`. The bot accepts following parameters:
Config example: * ``--token`` — your telegram bot token (required)
``` * ``--users-whitelist`` — space-separated list of IDs of users who are allowed
token=YOUR_TOKEN to use the bot (required)
admins= * ``--inverterd-host`` (default is `127.0.0.1`)
123456 ; admin id * ``--inverterd-port`` (default is `8305`)
000123 ; another admin id
isv_bin=/path/to/isv
use_sudo=0
```
Only users in `admins` are allowed to use the bot.
## Launching with systemd ## Launching with systemd
Create a service file `/etc/systemd/system/inverter-bot.service` with the following content (changing stuff like paths): This is tested on Debian 10. Something might differ on other systems.
Create environment configuration file `/etc/default/inverter-bot`:
```
TOKEN="YOUR_TOKEN"
USERS="ID ID ID ..."
OPTS="" # here you can pass other options such as --inverterd-host
```
Create systemd service file `/etc/systemd/system/inverter-bot.service` with the following content (changing stuff like paths):
```systemd ```systemd
[Unit] [Unit]
@ -39,10 +42,11 @@ Description=inverter bot
After=network.target After=network.target
[Service] [Service]
EnvironmentFile=/etc/default/inverter-bot
User=user User=user
Group=user Group=user
Restart=on-failure Restart=on-failure
ExecStart=python3 /home/user/inverter-bot/main.py ExecStart=python3 /home/user/inverter-bot/inverter-bot --token $TOKEN --users-whitelist $USERS $PARAMS
WorkingDirectory=/home/user/inverter-bot WorkingDirectory=/home/user/inverter-bot
[Install] [Install]
@ -51,7 +55,6 @@ WantedBy=multi-user.target
Then enable and start the service: Then enable and start the service:
``` ```
systemctl daemon-reload
systemctl enable inverter-bot systemctl enable inverter-bot
systemctl start inverter-bot systemctl start inverter-bot
``` ```