# tg-spam

> A self-hosted, open-source Telegram anti-spam bot with a Bayesian detector, LLM checks, CAS lookups, Lua plugins, an HTTP spam-check API and a web admin UI.

- **Category:** Anti-Spam
- **Licence:** MIT
- **Latest version:** v1.29.1
- **Open source:** oss
- **Languages:** Go
- **Platforms:** Docker Compose, Linux, Homebrew
- **Tags:** PostgreSQL, Docker, Anti-Spam, Telegram bot, Self Hosted, Cas, Spam detection, Spam Filter, Spam Classification, Group Moderation, Bayesian Classifier, LLM Moderation, Lua Plugins, Web Admin UI

## Description

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.

## Links

- [Homepage](https://github.com/umputun/tg-spam)
- [Website](https://tg-spam.umputun.dev)
- [Docker](umputun/tg-spam)
- [Go library package docs](https://pkg.go.dev/github.com/umputun/tg-spam/lib)

---
Source: https://selfhost.directory/project/tg-spam