Update README.md
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
# Lutz Bot
|
# Stan
|
||||||
Multipurpose Telegram Bot for Python group
|
Multipurpose Asynchronous Telegram Bot for Python group
|
||||||
|
|
||||||
### What does this project do?
|
### What does this project do?
|
||||||
* Send links on command (chat rules, FAQs, libraries etc.)
|
* Send links on command (chat rules, FAQs, libraries etc.)
|
||||||
@@ -13,19 +13,39 @@ Multipurpose Telegram Bot for Python group
|
|||||||
|
|
||||||
### Why is this project useful?
|
### Why is this project useful?
|
||||||
You can use this project as a pre-coded customizable bot.
|
You can use this project as a pre-coded customizable bot.
|
||||||
Original (and currently working example) bot Telegram username: @LutzPyBot
|
Original (and currently working example) bot's Telegram username: @LutzPyBot
|
||||||
|
|
||||||
### How to deploy it?
|
### How to deploy it?
|
||||||
1. Clone repository on your linux server into `lutzpybot` user's home directory.
|
1. Clone repository on your linux server into `Stan` user's home directory.
|
||||||
2. Create virtual environment, activate virtual environment, install required packages from `requirements.txt`.
|
2. Create virtual environment, activate virtual environment, install required packages from `requirements.txt`.
|
||||||
3. Create `.env` file in `lutzbot` directory with 3 variables: `LUTZPYBOT` (Bot Token), `whitelist` (White usernames, comma separated), `whiteids` (White IDs, comma separated)
|
3. Create `.env` file in `Stan` directory with 3 variables: `LUTZPYBOT` (Bot Token), `whitelist` (White usernames, comma separated), `whiteids` (White IDs, comma separated)
|
||||||
4. Install `gunicorn` package additionally with `pip install gunicorn`
|
4. Install `gunicorn` package with `pip install gunicorn`
|
||||||
5. Set webhook using Python interactive shell with `bot.set_webhook()` or manually according [Telegram Bot API Documentation](https://core.telegram.org/bots/api#setwebhook).
|
5. Set webhook using Python interactive shell with `bot.set_webhook()` or manually according [Telegram Bot API Documentation](https://core.telegram.org/bots/api#setwebhook).
|
||||||
6. Configure nginx as a reverse proxy.
|
6. Configure nginx as a reverse proxy. Example of Nginx config:
|
||||||
7. Configure the bot as a daemon.
|
```
|
||||||
|
server {
|
||||||
|
server_name rykov7.ru;
|
||||||
|
|
||||||
### How to configure bot as a daemon?
|
root /home/inferno/Stan;
|
||||||
1. Create daemon unit file in `/etc/systemd/system/lutz.service` with the content (replace `inferno` with your username):
|
index index.html index.htm index.nginx-debian.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# First attempt to serve request as file, then
|
||||||
|
# as directory, then fall back to displaying a 404.
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Stan Telegram Bot
|
||||||
|
location /[your_bot_token_must_be_here]/ {
|
||||||
|
include proxy_params;
|
||||||
|
proxy_pass http://127.0.0.1:8813;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Then install certbot SSL certificate for this config.
|
||||||
|
|
||||||
|
7. Configure the bot as a daemon:
|
||||||
|
* Create daemon unit file in `/etc/systemd/system/stan.service` with the next content (replace `inferno` with your username):
|
||||||
```
|
```
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=@Lutz Telegram Bot
|
Description=@Lutz Telegram Bot
|
||||||
@@ -36,21 +56,21 @@ User=inferno
|
|||||||
Group=inferno
|
Group=inferno
|
||||||
WorkingDirectory=/home/inferno/lutzpybot
|
WorkingDirectory=/home/inferno/lutzpybot
|
||||||
Environment="PATH=/home/inferno/lutzpybot/venv/bin"
|
Environment="PATH=/home/inferno/lutzpybot/venv/bin"
|
||||||
ExecStart=/bin/bash -c 'source /home/inferno/lutzpybot/venv/bin/activate; gunicorn --bind unix:/tmp/lutz.sock wsgi:app' #Restart=on-failure
|
ExecStart=/home/inferno/Stan/.venv/bin/gunicorn -k uvicorn.workers.UvicornWorker --bind 127.0.0.1:8813 wsgi:app
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
```
|
```
|
||||||
2. Enable and start with `systemctl enable lutz.service`, `systemctl start lutz.service`.
|
* Enable and start with `systemctl enable lutz.service`, `systemctl start lutz.service`.
|
||||||
|
|
||||||
|
|
||||||
### Where can I get more help, if I need it?
|
### Where can I get more help, if I need it?
|
||||||
Bot is easily understandable reading in-code comments of the handler functions, additionally read [PyTelegramBotAPI documentation](url=https://github.com/eternnoir/pyTelegramBotAPI) for library help.
|
You can read [PyTelegramBotAPI documentation](url=https://github.com/eternnoir/pyTelegramBotAPI) for more usage examples.
|
||||||
|
|
||||||
|
|
||||||
### How do I read logs of running Lutz bot daemon?
|
### How do I read logs of running Stan bot?
|
||||||
Continuous log reading on Linux:
|
Continuous log reading on Linux:
|
||||||
|
```# journalctl --unit=stan.service -f```
|
||||||
```# journalctl --unit=lutz.service -f```
|
|
||||||
|
|
||||||
|
|
||||||
### How to interact with Lutz bot?
|
### How to interact with Lutz bot?
|
||||||
|
|||||||
Reference in New Issue
Block a user