diff --git a/10-systems/bots/mardisbot.md b/10-systems/bots/mardisbot.md index 1fbd88d..e622658 100644 --- a/10-systems/bots/mardisbot.md +++ b/10-systems/bots/mardisbot.md @@ -3,7 +3,7 @@ description: Telegram bot for Mardis group host: tg_bots-vm status: active -last_reviewed: 2026-09-10 +last_reviewed: 2026-09-12 owner: gmikcon confidence: 100 review_interval: 90 @@ -14,7 +14,7 @@ Telegram bot for the Mardis group. -> **STATUS 2026-09-10: ACTIVE** on VM `tg_bots` (192.168.1.254, libvirt VM on +> **STATUS 2026-09-12: ACTIVE** on VM `tg_bots` (192.168.1.254, libvirt VM on > hypervisor bserv 192.168.1.130). Verified live via SSH: process running > since 2026-08-13, systemd service active. > @@ -25,7 +25,7 @@ > VPS; after the VPS was rebuilt ~2026-08-27 the bot was believed missing, > but it had actually been (re)deployed to the VM. -## Live deployment (verified 2026-09-10) +## Live deployment (verified 2026-09-12) - **Host**: VM `tg_bots`, 192.168.1.254 (libvirt on bserv, disk /mnt/main/vm_main/tg_bots, bridge br0, MAC 52:54:00:94:4b:e0) - **User**: `ubuntu` (password in gnexus-creds secret "tgbots") @@ -33,13 +33,30 @@ - **Main Script**: `bot.py` (venv: `/home/ubuntu/bots/MardisBot/venv`, Python 3.10) - **Config**: `.env` in project dir (bot token, not documented here) -- **Dependencies**: python-telegram-bot[job-queue], python-dotenv +- **Dependencies**: python-telegram-bot[job-queue] 22.7, python-dotenv (requirements.txt) +## Poll schedule (changed 2026-09-12) +- Weekly training poll ("Хто буде на тренуванні?") is sent + **Wednesday and Friday at 19:00 Europe/Kyiv**. +- Implementation: `app.job_queue.run_daily(..., days=(3, 5), + name="weekly_poll_wednesday_friday")` in `bot.py` (~line 174). + PTB 22.7 day convention: **0 = Sunday … 6 = Saturday** (verified against + the installed library source and its `_CRON_MAPPING`). +- Time is configured via `.env`: `POLL_HOUR=19`, `POLL_MINUTE=0` + (defaults in code are 10:00 if unset). +- Before 2026-09-12 the poll ran Thursday+Saturday at 08:00 (env-driven). +- There is **no catch-up logic**: a poll is never sent on bot start/restart; + missed slots are skipped silently. +- Startup `print` lines in `bot.py` state the configured time and days. + ## systemd service - **Service Name**: `mardisbot.service` — active (running), enabled - **Unit File**: `/etc/systemd/system/mardisbot.service` -- **Running since**: 2026-08-13 08:51:30 UTC +- **Unit change 2026-09-12**: added `Environment=PYTHONUNBUFFERED=1` + (stdout was block-buffered under systemd, hiding startup logs in + journalctl until process exit). Unit backup: + `/home/ubuntu/backups/mardisbot.service.bak_20260912`. - **Memory**: ~40 MB ### Service management @@ -49,6 +66,12 @@ sudo systemctl restart mardisbot.service ``` +## Backups (2026-09-12) +- Full code+config backup before the schedule change: + `/home/ubuntu/backups/MardisBot_backup_20260912_155039.tar.gz` + (bot.py, .env, requirements.txt; venv excluded). Rollback: extract + bot.py/.env from the archive, `sudo systemctl restart mardisbot.service`. + ## Remote ops (added 2026-09-10, extended 2026-09-10) The bot owner can manage this service remotely via the companion ops bot **MardisOpsBot** (`@MardisOps_bot`) — see @@ -60,7 +83,7 @@ users who press /start (user_ids persisted in `admins.json` on the VM). No SSH or inbound network access is required or granted. -## Health notes (2026-09-10) +## Health notes (2026-09-12) - Occasional `telegram.error.NetworkError: Bad Gateway` in journal (transient Telegram API/network blips; network_retry_loop recovers automatically). No error handlers registered in bot.py — cosmetic only. diff --git a/90-maintenance/pending-changes/20260912155435-5b1b55bb.json b/90-maintenance/pending-changes/20260912155435-5b1b55bb.json new file mode 100644 index 0000000..76cce34 --- /dev/null +++ b/90-maintenance/pending-changes/20260912155435-5b1b55bb.json @@ -0,0 +1,19 @@ +{ + "id": "20260912155435-5b1b55bb", + "kind": "doc", + "target": "10-systems/bots/mardisbot.md", + "summary": "MardisBot: poll schedule moved to Wed+Fri 19:00 Kyiv, PYTHONUNBUFFERED added to unit, backups documented", + "reason": "Расписание голосовалок MardisBot изменено 2026-09-12: чт+сб 08:00 → ср+пт 19:00 (days=(3,5), POLL_HOUR=19). Добавлен PYTHONUNBUFFERED=1 в юнит. Бэкапы на VM.", + "payload": { + "content": "---\ntitle: MardisBot\ndescription: Telegram bot for Mardis group\nhost: tg_bots-vm\nstatus: active\nlast_reviewed: 2026-09-12\nowner: gmikcon\nconfidence: 100\nreview_interval: 90\nsource_of_truth: live_system\n---\n\n# MardisBot\n\nTelegram bot for the Mardis group.\n\n> **STATUS 2026-09-12: ACTIVE** on VM `tg_bots` (192.168.1.254, libvirt VM on\n> hypervisor bserv 192.168.1.130). Verified live via SSH: process running\n> since 2026-08-13, systemd service active.\n>\n> **Naming warning:** there are TWO similarly named hosts. The bot lives on\n> the **VM `tg_bots` (192.168.1.254, hostname `tgbots`)** — NOT on the\n> external VPS `tgbots` (192.168.1.178, hostname `vmk`), which hosts only the\n> marginator web stack. Earlier documentation wrongly placed the bot on the\n> VPS; after the VPS was rebuilt ~2026-08-27 the bot was believed missing,\n> but it had actually been (re)deployed to the VM.\n\n## Live deployment (verified 2026-09-12)\n- **Host**: VM `tg_bots`, 192.168.1.254 (libvirt on bserv, disk\n /mnt/main/vm_main/tg_bots, bridge br0, MAC 52:54:00:94:4b:e0)\n- **User**: `ubuntu` (password in gnexus-creds secret \"tgbots\")\n- **Project Path**: `/home/ubuntu/bots/MardisBot`\n- **Main Script**: `bot.py` (venv: `/home/ubuntu/bots/MardisBot/venv`,\n Python 3.10)\n- **Config**: `.env` in project dir (bot token, not documented here)\n- **Dependencies**: python-telegram-bot[job-queue] 22.7, python-dotenv\n (requirements.txt)\n\n## Poll schedule (changed 2026-09-12)\n- Weekly training poll (\"Хто буде на тренуванні?\") is sent\n **Wednesday and Friday at 19:00 Europe/Kyiv**.\n- Implementation: `app.job_queue.run_daily(..., days=(3, 5),\n name=\"weekly_poll_wednesday_friday\")` in `bot.py` (~line 174).\n PTB 22.7 day convention: **0 = Sunday … 6 = Saturday** (verified against\n the installed library source and its `_CRON_MAPPING`).\n- Time is configured via `.env`: `POLL_HOUR=19`, `POLL_MINUTE=0`\n (defaults in code are 10:00 if unset).\n- Before 2026-09-12 the poll ran Thursday+Saturday at 08:00 (env-driven).\n- There is **no catch-up logic**: a poll is never sent on bot start/restart;\n missed slots are skipped silently.\n- Startup `print` lines in `bot.py` state the configured time and days.\n\n## systemd service\n- **Service Name**: `mardisbot.service` — active (running), enabled\n- **Unit File**: `/etc/systemd/system/mardisbot.service`\n- **Unit change 2026-09-12**: added `Environment=PYTHONUNBUFFERED=1`\n (stdout was block-buffered under systemd, hiding startup logs in\n journalctl until process exit). Unit backup:\n `/home/ubuntu/backups/mardisbot.service.bak_20260912`.\n- **Memory**: ~40 MB\n\n### Service management\n```bash\nsudo systemctl status mardisbot.service\nsudo journalctl -u mardisbot.service -f\nsudo systemctl restart mardisbot.service\n```\n\n## Backups (2026-09-12)\n- Full code+config backup before the schedule change:\n `/home/ubuntu/backups/MardisBot_backup_20260912_155039.tar.gz`\n (bot.py, .env, requirements.txt; venv excluded). Rollback: extract\n bot.py/.env from the archive, `sudo systemctl restart mardisbot.service`.\n\n## Remote ops (added 2026-09-10, extended 2026-09-10)\nThe bot owner can manage this service remotely via the companion ops bot\n**MardisOpsBot** (`@MardisOps_bot`) — see\n`10-systems/bots/mardisopsbot.md`. Commands: `/status`, `/restart`,\n`/logs [N]`, `/backup` (download current MardisBot code as ZIP), and\nZIP-upload update (send a .zip with bot.py to update the code on the VM —\nauto-backup before apply, auto-rollback if the service fails after\nrestart; `.env` and `venv` are never touched). Access: first 3 Telegram\nusers who press /start (user_ids persisted in `admins.json` on the VM).\nNo SSH or inbound network access is required or granted.\n\n## Health notes (2026-09-12)\n- Occasional `telegram.error.NetworkError: Bad Gateway` in journal\n (transient Telegram API/network blips; network_retry_loop recovers\n automatically). No error handlers registered in bot.py — cosmetic only." + }, + "status": "applied", + "created_at": "2026-09-12T15:54:35Z", + "updated_at": "2026-09-12T15:54:36Z", + "applied_at": "2026-09-12T15:54:36Z", + "validation": { + "status": "ok", + "issue_count": 0, + "issues": [] + } +}