- Nov 3, 2026
- 2 min read
A Telegram Community Bot That Runs Itself
The FOSS Engineer Telegram group is about self-hosting, homelabs, Docker and open-source software. The topic is narrow, and that’s exactly why spam stands out: crypto “opportunities”, affiliate links, the odd political rant, and adult bots that join just to post once.
I didn’t want to moderate it by hand every day, and I didn’t want a SaaS bot reading everything either. So I wrote a short spec, gave it to a coding agent, and two evenings later had a bot running on my homelab that:
- Approves join requests automatically, unless the user is on the ban list.
- Scores every text message and caption (new and edited) against five policies with TypeSafe’s Jev classifier.
- Deletes clear violations, sends borderline ones to me with Keep / Delete buttons, and leaves the rest alone.
- Bans on the second deletion, permanently, with a one-line command to undo it.
- Posts one quiet digest at 21:00 with new fossengineer.com articles, or nothing at all.
- Records every decision and action in SQLite, and survives crashes without deleting or banning twice.
Principles
- Spec before code. A Problem–Integrations–Outcome (PIO) doc was the only input to the build.
- A cheap classifier, not a chatbot. Five yes/no probabilities, thresholds in code, a human for the grey zone.
- When unsure, leave the message. Uncertain or unscored messages stay visible; only confident ones are deleted.
- Write it down before acting. No Telegram action happens without a database record.
- Boring infra. Standard library Python, SQLite, long polling, Docker Compose. No open ports.
The series
- From brainstorm to PIO to a one-shot build
- System-1 moderation with Jev
- Exactly-once (almost) on Telegram long polling
- Two strikes, edits and the owner exemption
- A quiet nightly RSS digest
- Homelab deploy, gotchas and lessons
Stack: Python 3.12 (standard library only), SQLite (WAL), Telegram Bot API, TypeSafe AI Jev, Docker Compose. 550 lines of bot, 190 lines of offline tests (12 behavior tests), one Makefile.
Next in this series: From Brainstorm to PIO to a One-Shot Agent Build