{
"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": []
}
}