A simple Telegram bot to handle Docker containers
and images
, also providing basic information about the status of
local servers.
The bot operates synchronously. It does not use webhooks.
The bot was written using the pyTelegramBotAPI. Use psutil and docker-py libraries for gather information.
- Information about containers (even those that have finished work)
- The ability to view container logs
- Information about images
- Load average information
- Summary memory usage information (with swap)
- Sensors information
- Summary process information
- Uptime information
- File system base information
- Basic information about the network connection
- The "About Me" section, which allows users to check for updates regarding the bot:
/check_bot_updates
- The
Jinja2
templating engine is used to generate the responses. - The bot logs are accessible in the Docker log aggregator.
- And of course we use emoji π
Screenshots are available here: screenshots.md.
Initially, I designed the bot to run only inside a Docker container. However, this method has some limitations, so from version 0.9.0 onward, it is possible to install the bot locally outside the container. At the same time, the bot will still be able to function and receive information about Docker containers.
Full list of Python dependencies see in requirements.txt
. List of Python dependencies for self setup bot see
in setup_req.txt
- See installation.md
An authorization mechanism has been built into the pyTMbot management system. To describe the principle of its operation in the most concise way, we can say the following:
- At the initial stage of configuration, we set the unique identifiers of users who are allowed to access the
bot (
ALLOWED_USER_IDS
), regardless of which official method is used. - With each new request for the bot, the middleware
AccessControl
is activated first. It checks whether the variablefrom_user.id
matches the values specified in the settings. If a match is found, the request is sent to the appropriate handler. - In all other cases, a mechanism is triggered that informs the user that they do not have access to the bot and stops processing.
In the alpine-dev
build (and the next release 0.1.2
), this mechanism has been expanded:
- The bot now reacts to incoming requests by reporting the lack of access twice, then completely stops processing messages.
- All failed attempts to authorize are logged with an
DENIED
andBLOCKED
flag.
For stable version, failed attempts to authorize are logged with an ERROR
flag.
In addition to button navigation, the bot also supports commands. Below is a list of commands and their details:
# | Command | Keyboard button | Note |
---|---|---|---|
1 | /start |
None | - |
2 | /help |
None | - |
3 | /docker |
π³ Docker | - |
4 | /containers |
π§° Containers | Button available in the Docker section |
5 | /images |
πΌοΈ Images | Button available in the Docker section |
6 | /back |
π Back to main menu | Button available in the Docker section |
7 | /check_bot_updates |
None | - |
- See bot_tree.md
- See roadmap.md
- pyTMbot repo on Docker Hub: https://hub.docker.com/r/orenlab/pytmbot
I am a novice Python developer. This is my first publicly available project in this great programming language.