Repository navigation
Conversation
has_suspicious_bio_links now accepts the bio owner's username and treats t.me/<own-username> links and @<own-username> mentions as self-references instead of promo links. Fixes false positives for users whose bio links to their own profile.
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.
Problem
A user was hit by a false positive from the bio-link spam detector: their Telegram profile bio contained a link to their own profile (
t.me/<their-username>), andhas_suspicious_bio_linksflagged it as a promo link because the function never knew whose bio it was checking.Fix
Dynamic per-user self-whitelist in
src/bot/handlers/bio_bait.py:has_suspicious_bio_links(bio)now accepts an optionalusernameparameter (the bio owner's Telegram username).t.me/<own-username>/telegram.me/<own-username>links (any scheme, case-insensitive) are treated as self-references and skipped.@<own-username>mentions are excluded from the suspicious-mention count.handle_bio_bait_spampassesuser.usernamefrom the message sender through to the check.WHITELISTED_TELEGRAM_PATHS,is_url_whitelisted) are untouched — the self-whitelist is dynamic per user and applies only to the bio check.Edge cases preserved
username=None): behavior unchanged.t.me/+hash): always flagged — they can never be a self-reference.@own-username+ promo hint word: no longer flagged (mention count drops to 0).Verification
ruff check: cleanmypy src/bot/handlers/bio_bait.py: cleanpytest tests/test_bio_bait.py: 112 passed (10 new tests for the self-whitelist)