VahterBanBot: ephemeral warning on spam auto-deletion (flag off by default) - #395
Merged
Conversation
…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
marked this pull request as ready for review
August 19, 2026 09:55
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
SpamWarningEnabledis true (read viaIOptions<BotConfiguration>.Valueat call time, never captured).CheckAndAutoBanreturnedfalsefor this deletion (the user was NOT just total-banned — a ban notice, not a warning, is the right signal there).reasonisMlSpam,LlmSpam, orContentFilterSpam. Explicitly excluded:InvisibleMention,SpamTextCacheHit,ReactionSpam— these are near-zero-false-positive spammer signatures, and warning there would only educate spammers.Uses
CallIgnore(neverCallExn) — a delivery failure never fails the deletion, matching the existingconfirm//vahter_reportephemeral 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 callDeleteSpamat 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)
After running,
POST /reload-settingsto pick it up without a redeploy.SPAM_WARNING_TEXTis also bot_setting-backed (defaults to the bilingual RU/EN text baked intoProgram.fs) if the wording ever needs tuning live.Tests (
tests/VahterBanBot.Tests/SpamWarningTests.fs, all green)sendMessage(receiver_user_id= sender,chat_id= chat, warning text).CheckAndAutoBan→ true) → no warning.SpamTextCacheHitdeletion (ban-seeded cache, enforce mode) → no warning.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 buildclean 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