Skip to content

VahterBanBot: ephemeral warning on spam auto-deletion (flag off by default) - #395

Merged
Szer merged 1 commit into
mainfrom
vahter-spam-warning
Aug 19, 2026
Merged

VahterBanBot: ephemeral warning on spam auto-deletion (flag off by default)#395
Szer merged 1 commit into
mainfrom
vahter-spam-warning

Conversation

@Szer

@Szer Szer commented Aug 19, 2026

Copy link
Copy Markdown
Owner

What/why

A newcomer whose message gets auto-deleted as spam currently gets zero feedback — they don't understand what happened, repost, and after ~4 deletions the karma auto-ban (CheckAndAutoBan) bans them in all monitored chats. This adds a best-effort ephemeral Bot API 10.2 message (visible only to that user, in the same chat), sent right after a qualifying auto-deletion, warning them not to repost. Text is deliberately fixed/generic (no scores, no ML/LLM distinction, no strike counts) so it can't be used to reverse-engineer detection. Off by default (SPAM_WARNING_ENABLED=false).

Gating rules (Bot.fs's DeleteSpam, locked design)

Warning is sent only when ALL of:

  1. SpamWarningEnabled is true (read via IOptions<BotConfiguration>.Value at call time, never captured).
  2. CheckAndAutoBan returned false for this deletion (the user was NOT just total-banned — a ban notice, not a warning, is the right signal there).
  3. reason is MlSpam, LlmSpam, or ContentFilterSpam. Explicitly excluded: InvisibleMention, SpamTextCacheHit, ReactionSpam — these are near-zero-false-positive spammer signatures, and warning there would only educate spammers.

Uses CallIgnore (never CallExn) — a delivery failure never fails the deletion, matching the existing confirm//vahter_report ephemeral patterns.

Already-banned path finding

The "already banned" fast-delete path (BotService.JustMessage, ~Bot.fs:1401) has its own inline deletion code — it does not call DeleteSpam at all. So it's structurally excluded from ever producing a warning; no additional guard was needed there. Locked in as a regression test (SpamWarningAlreadyBannedTests).

Enable SQL (hand-run only — settings are never Flyway-seeded)

INSERT INTO bot_setting (key, value) VALUES ('SPAM_WARNING_ENABLED', 'true')
ON CONFLICT (key) DO UPDATE SET value = EXCLUDED.value;

After running, POST /reload-settings to pick it up without a redeploy. SPAM_WARNING_TEXT is also bot_setting-backed (defaults to the bilingual RU/EN text baked into Program.fs) if the wording ever needs tuning live.

Tests (tests/VahterBanBot.Tests/SpamWarningTests.fs, all green)

  1. Flag ON + ML spam deletion of a non-banned user → exactly one ephemeral sendMessage (receiver_user_id = sender, chat_id = chat, warning text).
  2. Flag OFF (default) + same scenario → no warning.
  3. Flag ON + deletion that triggers the karma auto-ban (CheckAndAutoBan → true) → no warning.
  4. Flag ON + SpamTextCacheHit deletion (ban-seeded cache, enforce mode) → no warning.
  5. Flag ON + late message from an already-banned user (JustMessage's fast-delete path) → no warning.

dotnet test tests/VahterBanBot.Tests -c Release: 258 passed, 0 failed (includes the 5 new tests above, individually re-verified green as well). dotnet build clean for both touched projects.

🤖 Generated with Claude Code

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Wi7gKmshkHfVtSB3tA4gmJ

…fault)

Sends a best-effort ephemeral Bot API 10.2 message to a user whose message
was just auto-deleted as ML/LLM/content-filter spam, so newcomers stop
reposting and tripping the karma auto-ban blind. Gated by SPAM_WARNING_ENABLED
(default false); never sent when CheckAndAutoBan just banned the user, or for
InvisibleMention/SpamTextCacheHit/ReactionSpam deletions (near-zero-false-
positive spammer signatures that shouldn't be taught to spammers).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Wi7gKmshkHfVtSB3tA4gmJ
@Szer
Szer marked this pull request as ready for review August 19, 2026 09:55
@Szer
Szer merged commit dd4c94c into main Aug 19, 2026
4 checks passed
@Szer
Szer deleted the vahter-spam-warning branch August 19, 2026 09:56
Szer added a commit that referenced this pull request Aug 19, 2026
…efault 3.0) (#396)

Restricts the PR #395 ephemeral spam-deletion warning to low-score (likely
false-positive) deletions: MlSpam/LlmSpam/ContentFilterSpam all carry a score,
warn only when score < SpamWarningMaxScore (strict, bot_setting-backed since
the ML score scale drifts under daily retraining). Prod data: at the 3.0
default, 93.8% of ham-marked deletions still warn while warned-spammer volume
drops from 100% to 57%.


Claude-Session: https://claude.ai/code/session_01Wi7gKmshkHfVtSB3tA4gmJ

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant