telegram-bot-control 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- telegram_bot_control-0.5.1/AUTHORS.md +7 -0
- telegram_bot_control-0.5.1/LICENSE +21 -0
- telegram_bot_control-0.5.1/MANIFEST.in +16 -0
- telegram_bot_control-0.5.1/PKG-INFO +121 -0
- telegram_bot_control-0.5.1/README.md +232 -0
- telegram_bot_control-0.5.1/README.pypi.md +86 -0
- telegram_bot_control-0.5.1/README.ru.md +208 -0
- telegram_bot_control-0.5.1/THIRD_PARTY_NOTICES.md +30 -0
- telegram_bot_control-0.5.1/docs/architecture.md +36 -0
- telegram_bot_control-0.5.1/docs/assets/README.md +28 -0
- telegram_bot_control-0.5.1/docs/case-study.md +66 -0
- telegram_bot_control-0.5.1/docs/diagnostics.ru.md +125 -0
- telegram_bot_control-0.5.1/docs/getting-started.ru.md +175 -0
- telegram_bot_control-0.5.1/docs/process-control.md +116 -0
- telegram_bot_control-0.5.1/docs/project-wizard.ru.md +28 -0
- telegram_bot_control-0.5.1/docs/publishing.ru.md +29 -0
- telegram_bot_control-0.5.1/docs/pypi.ru.md +66 -0
- telegram_bot_control-0.5.1/docs/releases/v0.3.0.md +39 -0
- telegram_bot_control-0.5.1/docs/releases/v0.3.1.md +20 -0
- telegram_bot_control-0.5.1/docs/releases/v0.3.2.md +14 -0
- telegram_bot_control-0.5.1/docs/releases/v0.4.0.md +15 -0
- telegram_bot_control-0.5.1/docs/releases/v0.5.0.md +18 -0
- telegram_bot_control-0.5.1/docs/releases/v0.5.1.md +17 -0
- telegram_bot_control-0.5.1/docs/releasing.md +70 -0
- telegram_bot_control-0.5.1/docs/roadmap.md +45 -0
- telegram_bot_control-0.5.1/docs/size-report.md +37 -0
- telegram_bot_control-0.5.1/docs/specification.md +20 -0
- telegram_bot_control-0.5.1/docs/transport.md +59 -0
- telegram_bot_control-0.5.1/docs/validation.md +121 -0
- telegram_bot_control-0.5.1/docs/web-panel.ru.md +57 -0
- telegram_bot_control-0.5.1/examples/bots.example.toml +38 -0
- telegram_bot_control-0.5.1/examples/complex_bot/complex_aiogram_bot/__init__.py +1 -0
- telegram_bot_control-0.5.1/examples/complex_bot/complex_aiogram_bot/__main__.py +137 -0
- telegram_bot_control-0.5.1/examples/complex_bot/launch-workflow.ps1 +10 -0
- telegram_bot_control-0.5.1/examples/complex_bot/main.py +6 -0
- telegram_bot_control-0.5.1/examples/complex_bot/prepare.py +13 -0
- telegram_bot_control-0.5.1/examples/settings.example.json +7 -0
- telegram_bot_control-0.5.1/examples/test_bot/main.py +79 -0
- telegram_bot_control-0.5.1/pyproject.toml +57 -0
- telegram_bot_control-0.5.1/requirements-dev.lock +51 -0
- telegram_bot_control-0.5.1/scripts/backup.py +45 -0
- telegram_bot_control-0.5.1/scripts/benchmark.py +81 -0
- telegram_bot_control-0.5.1/scripts/control_fixture.py +82 -0
- telegram_bot_control-0.5.1/scripts/create_desktop_shortcut.ps1 +21 -0
- telegram_bot_control-0.5.1/scripts/portfolio_fixture.py +85 -0
- telegram_bot_control-0.5.1/scripts/prepare_release.py +126 -0
- telegram_bot_control-0.5.1/scripts/publish_github.ps1 +104 -0
- telegram_bot_control-0.5.1/scripts/release_check.py +169 -0
- telegram_bot_control-0.5.1/scripts/write_checksums.py +12 -0
- telegram_bot_control-0.5.1/setup.cfg +4 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/__init__.py +22 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/__main__.py +6 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/bridge.py +204 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/cli.py +141 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/config.py +85 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/launch_output.py +94 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/monitor.py +415 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/privacy.py +37 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/processes.py +621 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/projects.py +140 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/runner.py +194 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/store.py +515 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/telemetry.py +80 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/testing.py +133 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web.py +303 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/INTER-LICENSE.txt +93 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/WEB-LIBRARY-LICENSES.txt +67 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/assets/index--AZnpYML.css +1 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/assets/index-daaqjWEj.js +269 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_assets/index.html +17 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control/web_manager.py +80 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/PKG-INFO +121 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/SOURCES.txt +83 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/dependency_links.txt +1 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/entry_points.txt +2 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/requires.txt +14 -0
- telegram_bot_control-0.5.1/src/telegram_bot_control.egg-info/top_level.txt +1 -0
- telegram_bot_control-0.5.1/tests/test_diagnostics.py +320 -0
- telegram_bot_control-0.5.1/tests/test_integration.py +137 -0
- telegram_bot_control-0.5.1/tests/test_processes.py +394 -0
- telegram_bot_control-0.5.1/tests/test_release_check.py +33 -0
- telegram_bot_control-0.5.1/tests/test_storage.py +225 -0
- telegram_bot_control-0.5.1/tests/test_web.py +125 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Дмитрий Варг
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
include LICENSE README.md README.ru.md README.pypi.md THIRD_PARTY_NOTICES.md AUTHORS.md
|
|
2
|
+
include requirements-dev.lock
|
|
3
|
+
recursive-include src *.py
|
|
4
|
+
recursive-include src/telegram_bot_control/web_assets *.html *.js *.css *.woff2 *.png *.svg *.txt
|
|
5
|
+
recursive-include examples *.py *.ps1 *.json *.toml
|
|
6
|
+
recursive-include scripts *.py *.ps1
|
|
7
|
+
recursive-include tests *.py
|
|
8
|
+
recursive-include docs *.md
|
|
9
|
+
prune .git
|
|
10
|
+
prune .local-tools
|
|
11
|
+
prune .test-data
|
|
12
|
+
prune .venv
|
|
13
|
+
prune .pnpm-store
|
|
14
|
+
prune desktop
|
|
15
|
+
prune release
|
|
16
|
+
global-exclude __pycache__ *.py[cod] *.sqlite3 *.sqlite3-wal *.sqlite3-shm *.db .env .env.* *.log
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: telegram-bot-control
|
|
3
|
+
Version: 0.5.1
|
|
4
|
+
Summary: Embedded bot telemetry with desktop and optional authenticated web dashboards.
|
|
5
|
+
Author: Дмитрий Варг
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/olegoleg1111121/telegram-bot-control
|
|
8
|
+
Project-URL: Repository, https://github.com/olegoleg1111121/telegram-bot-control
|
|
9
|
+
Project-URL: Documentation, https://github.com/olegoleg1111121/telegram-bot-control/blob/main/README.ru.md
|
|
10
|
+
Project-URL: Issues, https://github.com/olegoleg1111121/telegram-bot-control/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/olegoleg1111121/telegram-bot-control/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: telegram,aiogram,monitoring,desktop,sqlite
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
18
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
19
|
+
Classifier: Topic :: System :: Monitoring
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: psutil<8,>=7
|
|
24
|
+
Provides-Extra: aiogram
|
|
25
|
+
Requires-Dist: aiogram<4,>=3.20; extra == "aiogram"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: aiogram<4,>=3.20; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest<10,>=8; extra == "dev"
|
|
29
|
+
Requires-Dist: pytest-asyncio<2,>=0.25; extra == "dev"
|
|
30
|
+
Requires-Dist: ruff<1,>=0.14; extra == "dev"
|
|
31
|
+
Provides-Extra: release
|
|
32
|
+
Requires-Dist: build<2,>=1.2; extra == "release"
|
|
33
|
+
Requires-Dist: twine<7,>=6; extra == "release"
|
|
34
|
+
Dynamic: license-file
|
|
35
|
+
|
|
36
|
+
# Telegram Bot Control
|
|
37
|
+
|
|
38
|
+
Monitoring and process control for existing aiogram bots. One owner, one Windows
|
|
39
|
+
or Linux server, many bots. Includes an embedded Python SDK, an optional browser
|
|
40
|
+
dashboard and a separately distributed desktop application.
|
|
41
|
+
|
|
42
|
+
## Install
|
|
43
|
+
|
|
44
|
+
For an aiogram bot:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
python -m pip install "telegram-bot-control[aiogram]"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For the lightweight web dashboard or stdio/SSH reader:
|
|
51
|
+
|
|
52
|
+
```sh
|
|
53
|
+
python -m pip install telegram-bot-control
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Requires Python 3.11+. The base package depends only on psutil. The wheel includes
|
|
57
|
+
the web UI and local Latin/Cyrillic fonts; Node.js and Electron are not required
|
|
58
|
+
for browser mode. Windows setup and Linux AppImage are distributed through
|
|
59
|
+
[GitHub Releases](https://github.com/olegoleg1111121/telegram-bot-control/releases).
|
|
60
|
+
|
|
61
|
+
## Connect your bot
|
|
62
|
+
|
|
63
|
+
After creating your existing Bot and Dispatcher, add this inside your startup
|
|
64
|
+
function, before polling:
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from telegram_bot_control import start
|
|
68
|
+
|
|
69
|
+
monitor = start(
|
|
70
|
+
bot=bot,
|
|
71
|
+
dispatcher=dp,
|
|
72
|
+
data_dir="/srv/bot-control/data", # choose your own absolute directory
|
|
73
|
+
)
|
|
74
|
+
dp.update.outer_middleware(monitor.middleware())
|
|
75
|
+
|
|
76
|
+
await dp.start_polling(bot)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Use the same data directory for all connected bots and the dashboard. On Windows,
|
|
80
|
+
an example is `data_dir=r"C:\BotControl\data"`. Keep your existing handlers,
|
|
81
|
+
routers, environment loader and polling call. The SDK writes bounded batches to
|
|
82
|
+
per-bot SQLite WAL files without opening a listening port in the bot.
|
|
83
|
+
|
|
84
|
+
Start the optional browser dashboard:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
tgbots web --port 8765 --data-dir /srv/bot-control/data
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
The terminal displays a loopback URL and a separate dashboard access key.
|
|
91
|
+
For network access and Termux, see the
|
|
92
|
+
[web dashboard guide](https://github.com/olegoleg1111121/telegram-bot-control/blob/main/docs/web-panel.ru.md).
|
|
93
|
+
The default mode is local HTTP; use an HTTPS proxy or SSH tunnel for untrusted networks.
|
|
94
|
+
|
|
95
|
+
## Features
|
|
96
|
+
|
|
97
|
+
- Bot status, message/command/button counters and retained error history.
|
|
98
|
+
- Existing Python logging and optional Loguru adapters, search and secret redaction.
|
|
99
|
+
- CPU, RSS and thread history for each bot's Python process.
|
|
100
|
+
- Explicit launch profiles: arguments, working directory, preparation steps and optional env-file.
|
|
101
|
+
- Start, graceful stop, restart and bounded on-failure automatic restarts.
|
|
102
|
+
- Detailed startup stderr/stdout, including failures before SDK initialization.
|
|
103
|
+
- Russian/English interfaces and configurable retention.
|
|
104
|
+
|
|
105
|
+
Optional integration with an already configured logger:
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
monitor.capture_logs() # standard logging; existing handlers are preserved
|
|
109
|
+
# For Loguru, use logger.add(monitor.loguru_sink, level="INFO") instead.
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
This is an early preview for a single trusted owner. Process control verifies PID,
|
|
113
|
+
creation time and owner. Multiple bots sharing one Python process share resource
|
|
114
|
+
measurements and cannot be stopped independently. It does not install an OS boot
|
|
115
|
+
service or import historical log files.
|
|
116
|
+
|
|
117
|
+
Created by [Дмитрий Варг](https://github.com/olegoleg1111121). MIT license.
|
|
118
|
+
|
|
119
|
+
[Source and documentation](https://github.com/olegoleg1111121/telegram-bot-control)
|
|
120
|
+
· [Russian walkthrough](https://github.com/olegoleg1111121/telegram-bot-control/blob/main/docs/getting-started.ru.md)
|
|
121
|
+
· [Issues](https://github.com/olegoleg1111121/telegram-bot-control/issues)
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img src="desktop/assets/icon.svg" width="88" alt="Telegram Bot Control icon">
|
|
3
|
+
<h1>Telegram Bot Control</h1>
|
|
4
|
+
<p>Desktop monitoring and process control for aiogram bots.</p>
|
|
5
|
+
<p>Python · aiogram · Electron · React · TypeScript · SQLite</p>
|
|
6
|
+
<p><a href="README.ru.md">Русская инструкция</a> · <a href="docs/process-control.md">Launch profiles</a> · <a href="docs/case-study.md">Engineering notes</a> · <a href="docs/releasing.md">Release guide</a></p>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
**v0.5.1 · Preview · MIT**
|
|
10
|
+
|
|
11
|
+
Startup failures now show retained command stdout/stderr, including errors before
|
|
12
|
+
SDK initialization, with secret redaction and bounded output history.
|
|
13
|
+
|
|
14
|
+
New in 0.5.0: existing logging/Loguru streams, per-process CPU/RSS history, bounded
|
|
15
|
+
on-failure restarts and a guided existing-project connector. Available in both
|
|
16
|
+
desktop and web modes. [Diagnostics](docs/diagnostics.ru.md) · [Project wizard](docs/project-wizard.ru.md).
|
|
17
|
+
|
|
18
|
+
One owner, one server, many bots. Connect a small Python SDK to existing aiogram
|
|
19
|
+
applications, inspect activity and exceptions, and control their processes from a
|
|
20
|
+
dark desktop interface. Local transport uses SQLite WAL and standard input/output.
|
|
21
|
+
Remote Linux access uses the same bridge over SSH.
|
|
22
|
+
|
|
23
|
+
An optional authenticated web dashboard serves the same interface on a chosen port,
|
|
24
|
+
including headless hosts and Termux. It is disabled by default. Run
|
|
25
|
+
`tgbots web --port 8765 --data-dir /srv/bot-control/data`, or enable it under desktop
|
|
26
|
+
Settings → Web dashboard. The terminal/settings show a separate browser access key.
|
|
27
|
+
[Web/Termux guide](docs/web-panel.ru.md).
|
|
28
|
+
|
|
29
|
+
[Measured distribution size and packaging changes](docs/size-report.md).
|
|
30
|
+
|
|
31
|
+
<img src="docs/assets/overview.png" alt="Server overview with activity charts and three demonstration bots" width="1200">
|
|
32
|
+
|
|
33
|
+
_All screenshots use synthetic demo data and anonymous server labels._
|
|
34
|
+
|
|
35
|
+
## Install a release
|
|
36
|
+
|
|
37
|
+
Download desktop installers or the portable Windows ZIP from
|
|
38
|
+
[GitHub Releases](https://github.com/olegoleg1111121/telegram-bot-control/releases).
|
|
39
|
+
The Python wheel includes the web dashboard and can be installed without Node.js:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
python -m pip install "telegram-bot-control[aiogram] @ https://github.com/olegoleg1111121/telegram-bot-control/releases/download/v0.5.1/telegram_bot_control-0.5.1-py3-none-any.whl"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
A PyPI Trusted Publishing workflow is included. Once the PyPI project is published,
|
|
46
|
+
the equivalent command is `python -m pip install "telegram-bot-control[aiogram]"`.
|
|
47
|
+
[PyPI setup and publication](docs/pypi.ru.md).
|
|
48
|
+
|
|
49
|
+
## What it does
|
|
50
|
+
|
|
51
|
+
- Registers bots automatically and keeps their history across restarts.
|
|
52
|
+
- Shows heartbeat state separately from user activity.
|
|
53
|
+
- Counts messages, commands, callbacks and distinct users over a selected range.
|
|
54
|
+
- Groups handler exceptions and expands sanitized technical details.
|
|
55
|
+
- Starts, gracefully stops and restarts bots with their configured launch profile.
|
|
56
|
+
- Preserves arguments, working directory, preparation steps and environment-file paths.
|
|
57
|
+
- Checks process identity using PID and creation time before termination.
|
|
58
|
+
- Keeps collecting while the desktop window is closed.
|
|
59
|
+
- Supports Russian and English, time zones and configurable retention.
|
|
60
|
+
- Includes a first-run guide, close-to-tray behavior and Windows installation shortcuts.
|
|
61
|
+
- Optional browser access, responsive phone layout and locally bundled Inter fonts.
|
|
62
|
+
|
|
63
|
+
[First-run walkthrough (Russian)](docs/getting-started.ru.md). Reopen the in-app guide
|
|
64
|
+
from the sidebar or system tray. Closing the window hides it; use the tray menu to quit.
|
|
65
|
+
|
|
66
|
+
<details>
|
|
67
|
+
<summary>First-run guide</summary>
|
|
68
|
+
|
|
69
|
+
<img src="docs/assets/onboarding.png" alt="Russian first-run guide with connection, aiogram integration and system tray instructions" width="1100">
|
|
70
|
+
|
|
71
|
+
</details>
|
|
72
|
+
|
|
73
|
+
## Try it locally
|
|
74
|
+
|
|
75
|
+
Requirements: **Python 3.11+**, **Node.js 24**, and **pnpm 11.25.0**.
|
|
76
|
+
Run these commands from a source checkout or extracted source archive:
|
|
77
|
+
|
|
78
|
+
```powershell
|
|
79
|
+
python -m venv .venv
|
|
80
|
+
.\.venv\Scripts\python.exe -m pip install -e '.[dev]'
|
|
81
|
+
pnpm install --dir desktop --frozen-lockfile
|
|
82
|
+
pnpm --dir desktop run build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
For Linux, use `.venv/bin/python` and `.venv/bin/tgbots`.
|
|
86
|
+
Install pnpm with `npm install --global pnpm@11.25.0` if needed.
|
|
87
|
+
|
|
88
|
+
Start an explicit offline analytics demo in one terminal:
|
|
89
|
+
|
|
90
|
+
```powershell
|
|
91
|
+
.\.venv\Scripts\tgbots.exe demo --bots 3 --data-dir .bot-control
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Open the desktop from another terminal in the same folder:
|
|
95
|
+
|
|
96
|
+
```powershell
|
|
97
|
+
.\.venv\Scripts\tgbots.exe open --data-dir .bot-control
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The demo uses real aiogram dispatchers with a network-free session. It generates
|
|
101
|
+
messages, commands, button events and a controlled exception. No Telegram account
|
|
102
|
+
or bot token is required.
|
|
103
|
+
|
|
104
|
+
For the independent Start/Stop/Restart walkthrough, use the complex fixture:
|
|
105
|
+
|
|
106
|
+
```powershell
|
|
107
|
+
.\.venv\Scripts\python.exe scripts/control_fixture.py --data-dir .bot-control/workflow --project-dir '.test-data/Workflow Bot'
|
|
108
|
+
.\.venv\Scripts\tgbots.exe open --data-dir .bot-control/workflow
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Select the bot card and press **Start**. This fixture includes nested routers,
|
|
112
|
+
FSM, a preparation command, arguments with spaces and a separate environment file.
|
|
113
|
+
|
|
114
|
+
## Connect an existing bot
|
|
115
|
+
|
|
116
|
+
Install this Python package into the bot's environment, then add:
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from telegram_bot_control import start
|
|
120
|
+
|
|
121
|
+
monitor = start(
|
|
122
|
+
bot=bot,
|
|
123
|
+
dispatcher=dp,
|
|
124
|
+
data_dir=r"C:\BotControl\data",
|
|
125
|
+
actions={"catalog:open": "catalog.open"},
|
|
126
|
+
)
|
|
127
|
+
dp.update.outer_middleware(monitor.middleware())
|
|
128
|
+
|
|
129
|
+
await dp.start_polling(bot)
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
All bots and the desktop must use the same local data directory. On Linux, choose
|
|
133
|
+
an absolute path such as `/srv/bot-control`. The import performs no registration
|
|
134
|
+
or network request; recording begins during aiogram startup.
|
|
135
|
+
|
|
136
|
+
For webhook or custom runtimes, connect the dispatcher lifecycle and provide a
|
|
137
|
+
`shutdown` callback. See the [Russian integration guide](README.ru.md) and
|
|
138
|
+
[process-control reference](docs/process-control.md).
|
|
139
|
+
|
|
140
|
+
## Process control and complex launches
|
|
141
|
+
|
|
142
|
+
The SDK records the actual Python arguments and working directory. Configure an
|
|
143
|
+
explicit profile for wrappers, preparation or tools such as PowerShell:
|
|
144
|
+
|
|
145
|
+
```json
|
|
146
|
+
{
|
|
147
|
+
"command": ["/opt/bots/.venv/bin/python", "-u", "-m", "shop_bot", "--config", "config/prod config.json"],
|
|
148
|
+
"cwd": "/opt/bots/shop",
|
|
149
|
+
"pre_start": [["/opt/bots/.venv/bin/python", "prepare.py"]],
|
|
150
|
+
"env_file": "/opt/bots/shop/.env",
|
|
151
|
+
"environment": {"BOT_MODE": "production"},
|
|
152
|
+
"required_env": ["BOT_TOKEN"]
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Arguments are passed with `shell=False`. Secrets belong in an environment file or
|
|
157
|
+
an environment-variable reference. A failed preflight keeps an existing bot running.
|
|
158
|
+
Graceful shutdown is attempted first; forced termination requires a separate action.
|
|
159
|
+
|
|
160
|
+
<details>
|
|
161
|
+
<summary>Process controls and grouped exceptions</summary>
|
|
162
|
+
|
|
163
|
+
<img src="docs/assets/processes.png" alt="Start, Stop and Restart controls exercised on an offline aiogram workflow" width="1100">
|
|
164
|
+
<img src="docs/assets/errors.png" alt="Grouped demonstration exceptions with expandable details" width="1100">
|
|
165
|
+
|
|
166
|
+
</details>
|
|
167
|
+
|
|
168
|
+
## Architecture
|
|
169
|
+
|
|
170
|
+
```mermaid
|
|
171
|
+
flowchart LR
|
|
172
|
+
SDK[aiogram bot + SDK] -->|events and heartbeat|DB[(Per-bot SQLite WAL)]
|
|
173
|
+
DB -->|addressed stop request|SDK
|
|
174
|
+
UI[Electron desktop] <-->|JSON lines over stdio or SSH|Bridge[Python bridge]
|
|
175
|
+
Bridge -->|queries and settings|DB
|
|
176
|
+
Bridge -->|launch profile|Runner[Detached launcher]
|
|
177
|
+
Runner -->|argv, cwd, environment|SDK
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
The reader is a child process of the desktop. Each bot owns its recorder and file,
|
|
181
|
+
so collection continues independently of the window. SSH runs the reader on the
|
|
182
|
+
server; SQLite is always accessed on that machine's local disk.
|
|
183
|
+
|
|
184
|
+
[Design decisions](docs/case-study.md) · [Implementation overview](docs/architecture.md)
|
|
185
|
+
|
|
186
|
+
## Verification
|
|
187
|
+
|
|
188
|
+
```powershell
|
|
189
|
+
.\.venv\Scripts\python.exe -m pytest -q
|
|
190
|
+
pnpm --dir desktop run test
|
|
191
|
+
pnpm --dir desktop run format:check
|
|
192
|
+
pnpm --dir desktop run build
|
|
193
|
+
.\.venv\Scripts\python.exe scripts/release_check.py
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
The suite covers genuine aiogram handling, distinct-user aggregation, deduplication,
|
|
197
|
+
retention, backups, process identity, concurrent starts, complex launch profiles,
|
|
198
|
+
PowerShell, failed preparation and graceful/forced shutdown. Electron smoke tests
|
|
199
|
+
press the real controls and inspect the resulting state.
|
|
200
|
+
|
|
201
|
+
[Recorded validation and remaining platform checks](docs/validation.md).
|
|
202
|
+
Windows was exercised locally. GitHub Actions are configured for Windows and Linux;
|
|
203
|
+
hosted CI results will be available after this repository is published.
|
|
204
|
+
|
|
205
|
+
## Release and installation
|
|
206
|
+
|
|
207
|
+
A release contains the Python wheel, Python source distribution, full source archive,
|
|
208
|
+
Windows installer, portable Windows folder archive and SHA256 checksums. The tag
|
|
209
|
+
workflow also builds a Linux AppImage. Python is installed separately and selected
|
|
210
|
+
in desktop connection settings.
|
|
211
|
+
|
|
212
|
+
The desktop binaries are unsigned preview builds. Review the release notes and
|
|
213
|
+
verify checksums before use. Local preparation and later GitHub publication are
|
|
214
|
+
separate steps: [release guide](docs/releasing.md).
|
|
215
|
+
|
|
216
|
+
## Scope
|
|
217
|
+
|
|
218
|
+
- One owner and one server, with separate OS processes for independently controlled bots.
|
|
219
|
+
- No Docker or multi-user account/role system. Web access is owner-only.
|
|
220
|
+
- No systemd, Windows-service or external-supervisor adapter yet.
|
|
221
|
+
- Raw updates, message bodies and full callback payloads are excluded from telemetry.
|
|
222
|
+
- User identifiers are pseudonymized per bot for distinct counts.
|
|
223
|
+
- Abrupt shutdown or storage failure can lose queued telemetry; loss counters are exposed.
|
|
224
|
+
- Retention defaults: statistics 365 days, errors 30 days, diagnostics 7 days.
|
|
225
|
+
|
|
226
|
+
[Security model](SECURITY.md) · [Contributing](CONTRIBUTING.md) · [Changelog](CHANGELOG.md)
|
|
227
|
+
|
|
228
|
+
## Author and license
|
|
229
|
+
|
|
230
|
+
Created and maintained by the repository owner. Original project code and assets
|
|
231
|
+
are available under the [MIT license](LICENSE). Third-party components retain their
|
|
232
|
+
respective licenses; see [notices](THIRD_PARTY_NOTICES.md).
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Telegram Bot Control
|
|
2
|
+
|
|
3
|
+
Monitoring and process control for existing aiogram bots. One owner, one Windows
|
|
4
|
+
or Linux server, many bots. Includes an embedded Python SDK, an optional browser
|
|
5
|
+
dashboard and a separately distributed desktop application.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
For an aiogram bot:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
python -m pip install "telegram-bot-control[aiogram]"
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
For the lightweight web dashboard or stdio/SSH reader:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
python -m pip install telegram-bot-control
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Requires Python 3.11+. The base package depends only on psutil. The wheel includes
|
|
22
|
+
the web UI and local Latin/Cyrillic fonts; Node.js and Electron are not required
|
|
23
|
+
for browser mode. Windows setup and Linux AppImage are distributed through
|
|
24
|
+
[GitHub Releases](https://github.com/olegoleg1111121/telegram-bot-control/releases).
|
|
25
|
+
|
|
26
|
+
## Connect your bot
|
|
27
|
+
|
|
28
|
+
After creating your existing Bot and Dispatcher, add this inside your startup
|
|
29
|
+
function, before polling:
|
|
30
|
+
|
|
31
|
+
```python
|
|
32
|
+
from telegram_bot_control import start
|
|
33
|
+
|
|
34
|
+
monitor = start(
|
|
35
|
+
bot=bot,
|
|
36
|
+
dispatcher=dp,
|
|
37
|
+
data_dir="/srv/bot-control/data", # choose your own absolute directory
|
|
38
|
+
)
|
|
39
|
+
dp.update.outer_middleware(monitor.middleware())
|
|
40
|
+
|
|
41
|
+
await dp.start_polling(bot)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Use the same data directory for all connected bots and the dashboard. On Windows,
|
|
45
|
+
an example is `data_dir=r"C:\BotControl\data"`. Keep your existing handlers,
|
|
46
|
+
routers, environment loader and polling call. The SDK writes bounded batches to
|
|
47
|
+
per-bot SQLite WAL files without opening a listening port in the bot.
|
|
48
|
+
|
|
49
|
+
Start the optional browser dashboard:
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
tgbots web --port 8765 --data-dir /srv/bot-control/data
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The terminal displays a loopback URL and a separate dashboard access key.
|
|
56
|
+
For network access and Termux, see the
|
|
57
|
+
[web dashboard guide](https://github.com/olegoleg1111121/telegram-bot-control/blob/main/docs/web-panel.ru.md).
|
|
58
|
+
The default mode is local HTTP; use an HTTPS proxy or SSH tunnel for untrusted networks.
|
|
59
|
+
|
|
60
|
+
## Features
|
|
61
|
+
|
|
62
|
+
- Bot status, message/command/button counters and retained error history.
|
|
63
|
+
- Existing Python logging and optional Loguru adapters, search and secret redaction.
|
|
64
|
+
- CPU, RSS and thread history for each bot's Python process.
|
|
65
|
+
- Explicit launch profiles: arguments, working directory, preparation steps and optional env-file.
|
|
66
|
+
- Start, graceful stop, restart and bounded on-failure automatic restarts.
|
|
67
|
+
- Detailed startup stderr/stdout, including failures before SDK initialization.
|
|
68
|
+
- Russian/English interfaces and configurable retention.
|
|
69
|
+
|
|
70
|
+
Optional integration with an already configured logger:
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
monitor.capture_logs() # standard logging; existing handlers are preserved
|
|
74
|
+
# For Loguru, use logger.add(monitor.loguru_sink, level="INFO") instead.
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
This is an early preview for a single trusted owner. Process control verifies PID,
|
|
78
|
+
creation time and owner. Multiple bots sharing one Python process share resource
|
|
79
|
+
measurements and cannot be stopped independently. It does not install an OS boot
|
|
80
|
+
service or import historical log files.
|
|
81
|
+
|
|
82
|
+
Created by [Дмитрий Варг](https://github.com/olegoleg1111121). MIT license.
|
|
83
|
+
|
|
84
|
+
[Source and documentation](https://github.com/olegoleg1111121/telegram-bot-control)
|
|
85
|
+
· [Russian walkthrough](https://github.com/olegoleg1111121/telegram-bot-control/blob/main/docs/getting-started.ru.md)
|
|
86
|
+
· [Issues](https://github.com/olegoleg1111121/telegram-bot-control/issues)
|