All posts
3 min read

Phrase moderation and punishment chains

A builder for phrase rules with connectors, distance and exceptions, rule sets, punishment chains, and two simple blocks — text length and duplicates.

The most common request after the dashboard launched was a simple one: "let us delete messages by words". We built a rule builder rather than a stop-word list, because a list of words either misses half the spam or starts taking out real conversation.

The rule builder#

A rule is assembled from parts connected to each other. A part is a phrase, a number, or a whole group of other parts. Between any two parts there is a connector: OR, or AND with a maximum distance.

This rule fires when "swap" or "p2p" appears no further than forty characters from "usdt" — and stays quiet when the words simply happen to share one long message.

What else the builder can do:

  • exceptions — a part with a minus sign cancels the match: "buying" &10 "account" & -"buying from you";
  • strict order — with it, parts must appear in exactly the order written;
  • groups — brackets let you nest conditions as deep as you need;
  • numbers — {n} catches any number, from "500 USD" to "t.me/+15550123456".

While you edit a rule, the dashboard highlights the matches in your test string. You see the mistake before it reaches the chat.

Phrase rule sets in the dashboard

Every connector explained, with "catches / lets through" examples, is in the guide How to set up a word filter in a Telegram group.

Rule sets#

Rules live inside sets that you create and name however you like — by topic, by source of spam, whatever fits. The split is not cosmetic: the punishment chain belongs to the set. Some things can earn an immediate ban, others only a warning, and the violation counters of those sets never mix.

Every rule and every set can be switched on and off separately, so you can mute a whole set for a while without deleting its settings.

Punishment chains#

A chain describes what the bot does on a first violation, what on a second, and so on. You get as many steps as you need: one is fine, or build a ladder of "warning → one-hour mute → one-day mute → ban". When there are more violations than steps, the last step repeats — so a chain without a ban at the end does not quietly turn into an amnesty.

Each step has its own settings: whether to delete the message, where to send the warning — to the chat, to direct messages or as a message only the offender sees — and how long the mute lasts. Every rule set has its own chain. The set's card shows that chain in full, with a hint about which step a given member is on, so you do not have to keep the logic in your head.

Text length and duplicates#

Two simple blocks arrived alongside phrases, and they take out a noticeable share of the noise before it ever gets to word matching:

  • Text length — cuts off empty messages, one-word spam and walls of text;
  • Duplicates — catches both one member repeating themselves and the same text sent at once by different accounts.

Read next