pytmbot

pyTMBot self build guide

🔌 Installation

So, to install this project:

git clone https://github.com/orenlab/pytmbot.git
cd ./pytmbot

🧪 Configure bot

  1. Activate the virtual environment and install the dependencies for the bot configuration script using your preferred package manager. The following instructions provide an example using pip. (mandatory stage):
python -m venv .venv
source ~/pytmbot/.venv/bin/activate
pip install -r setup_req.txt
  1. Run the CLI Setup Wizard (mandatory stage):
python3 ./setup_bot.py

And follow the wizard’s instructions.

This wizard will generate the necessary configuration file for you:

Files Assignment
.pytmbotenv To store bot settings, including tokens, allowed user ID and paths to the Docker and Podman socket

You can leave the steps with the default settings by simply pressing “Enter”.

đź’° Run bot

To launch a Docker container:

sudo docker run -d -m 100M \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /root/.pytmbotenv:/opt/pytmbot/.pytmbotenv:ro \
--env TZ="Asia/Yekaterinburg" \
--restart=always \
--name=pytmbot \
--pid=host \
--security-opt=no-new-privileges \
orenlab/pytmbot:latest \
/venv/bin/python3 app/main.py --log-level=DEBUG --mode=prod
sudo docker run -d -m 100M \
-v /var/run/docker.sock:/var/run/docker.sock:ro \
-v /root/.pytmbotenv:/opt/pytmbot/.pytmbotenv:ro \
--env TZ="Asia/Yekaterinburg" \
--restart=always \
--name=pytmbot \
--pid=host \
--security-opt=no-new-privileges \
orenlab/pytmbot:latest \
--log-level=INFO --mode=prod

Supported logging levels:

# Logging levels Note Args
1 INFO Balanced logging mode: only the most important information + a short description of errors and exceptions. --log-level=INFO
2 ERROR Only errors and exceptions are shown. This can be considered a “quiet” mode. --log-level=ERROR
3 DEBUG The most detailed level of logs provides all the information displayed in the previous levels, plus additional details, such as traces and all debugging information. --log-level=DEBUG

Note #1:

Please don’t forget to specify your time zone! You can find a list of available time zones, for example, here

Note #2:

Please don’t forget to specify Tag version!

Now everything is ready for you to use the bot. All you need to do is run the /start command in your Telegram app.

🚀 Bot logs

sudo docker logs pytmbot

Alternatively, if the container is running on your workstation, you can use Docker Desktop.