Marketing · Community management

Moderation across hundreds of Telegram groups

One ban propagates network-wide; ad partners are cut off the moment their quota runs out.

20252 monthsAlexA network of Telegram communities

The problem

Running a network of large Telegram communities meant paying humans to watch chats around the clock, and still losing to spam that hid text inside images. Bans didn't carry across groups, so a scammer removed from one community simply moved to the next. Separately, advertising partners routinely posted past their paid quota, and nobody was counting.

What we built

A moderation engine that treats the whole network as one system. User behavior syncs across all groups, an OCR module reads text inside images so image spam stops working, and ad posts are counted automatically against each partner's paid quota.

What it changed

01

Round-the-clock human moderation is no longer required

Detection and removal are instant and continuous.

02

Ads stop when the quota does

Partner posts are counted automatically and posting rights are restricted the moment the paid allowance is used up — no free inventory given away by accident.

03

A ban anywhere is a ban everywhere

A scammer detected in one group is removed across the entire network immediately.

How it worksthe engineering detail

Written for the person your CTO forwards this to.

1

O(n) text scanning

Aho-Corasick with hash-based caching means detection speed is independent of stop-word dictionary size — the dictionary can grow without CPU cost growing with it.

2

Modular monolith with sidecars

Core logic lives in a Spring Boot modular monolith; Python/FastAPI sidecars handle MTProto-specific tasks and CAPTCHA flows, keeping concerns separated without a full microservice sprawl.

3

Escalating punishment across a sliding window

Cross-group violations are tracked over time in Redis (90-day TTL keys), with recent-message deduplication that survives server restarts.

4

Atomic album handling

Telegram delivers media groups as separate asynchronous messages. An aggregator collects them by mediaGroupId and deletes the whole album atomically if any single image or caption trips OCR or the text scanner.

5

Rate limiting

Atomic limiters (AtomicLong + synchronized) hold third-party AI calls inside their quotas — Yandex OCR at 1 req/sec.

Patterns — FSM for dialogs · Sidecar / API gateway · Flyweight (trie caching) · Sliding window rate limiter

Stack

Java 21 / Spring Boot 3Python — FastAPI, aiogramMongoDBRedisYandex Cloud OCR