Self-host tg-spam
v1.29.1Bayesian anti-spam bot and API server for Telegram groups
- Stars
- 453
- Port
- 8080 (webapi server and WEB UI, only when the server is enabled with --server.enabled)
umputun/tg-spamWhat is tg-spam?
A Go-based bot that guards a Telegram group chat: it inspects each post and, when spam is recognised, removes the message and bans the poster. Judgement comes from a stack of checks - a Bayes classifier over spam and ham samples, a similarity comparison against those samples, a stop-phrase list, counters for emoji, links, mentions and media-only posts, abnormal spacing, repeated messages and reaction floods, plus a lookup in the public Combot Anti-Spam database. Optional calls to OpenAI, Google Gemini or the jev decision model can add evidence or veto the outcome, and Lua scripts extend detection without touching the codebase. Admins keep teaching it by forwarding spam into an admin chat or unbanning a false positive, while dry, training and soft-ban settings allow careful tuning on a live group. The same engine can also run headless as an HTTP endpoint for other tools, behind a basic-auth web panel for editing samples, dictionaries and approved users, or as a Go library. Deployment is a single Docker container (or one of the release binaries) needing only a bot token and a group id, with data kept in SQLite by default or PostgreSQL; each instance covers one group.
Should you self-host tg-spam?
tg-spam scores 52/100 on selfhost.directory (how scoring works) and ranks #3 of 4 in Anti-Spam. It has 453 GitHub stars.
It shipped 15 stable releases in the past year. The latest, v1.29.1, came out on 27 October 2026. New versions land roughly every 3 weeks.
Setup is easy: most people get it running in one sitting. An official Docker image is available. It is MIT-licensed and written mostly in Go.
Its closest alternative on selfhost.directory is Rspamd (65/100, 2 559 stars). It scores higher overall, so compare the two before you pick. See tg-spam vs Rspamd side by side.
Features
- Admin chat with inline moderation buttons
- Automated message moderation
- Automatic backup on upgrade
- Bayesian spam classificationactive only when both ham and spam samples are present
- Crowdsourced user spam reporting
- Custom Lua plugins
- Dry-run, training and soft-ban modes
- Learning from admin feedback
- LLM spam analysisdisabled until an API token is set
- Metadata checks (links, emoji, media)
- REST APIdisabled by default, enable with --server.enabled
- Spam similarity check
- Stop words filtering
- Web admin UIserved by the same optional web server, behind basic auth
tg-spam README
More in Anti-Spam
altchaSelf-hosted, open-source CAPTCHA alternative that swaps image puzzles for a silent proof-of-work widget plus MIT-licensed server libraries for 10+ languages.
boxwatchrboxwatchr is a self-hosted, open-source email filtering daemon for IMAP mailboxes with rspamd spam scoring, custom rules, and a web dashboard.
cactusdcactusd is an open-source, self-hosted daemon that aggregates and serves domain/IP blocklists for DNS-based ad-blocking, updating every 12 hours with a built-in web UI.
capjsSelf-hosted, open-source CAPTCHA that replaces reCAPTCHA with invisible proof-of-work and browser instrumentation: no puzzles, no trackers, a ~20 kB widget.
docker-mailserverSelf-hosted, open-source mail server image (Postfix, Dovecot, Rspamd, ClamAV, Fail2ban) with SMTP, IMAP, LDAP and OAuth2 login, configured by files only.
HarakaA self-hosted, open-source Node.js SMTP server with a JavaScript plugin system: filtering MTA or submission host with DKIM signing, DNSBL checks and virus scanning.
mCaptchaSelf-hosted, open-source CAPTCHA server where visitors' browsers do SHA256 proof-of-work instead of image puzzles; the Rust backend runs with Postgres and Redis.
RspamdOpen-source, self-hosted spam filtering daemon with Milter support for Postfix and Exim, Bayesian, DNSBL and SPF/DKIM/DMARC checks plus a web dashboard.



0 comments