refactor: remove dead code and duplication across plugins, handlers, config#20
Merged
Conversation
…config Deletes unused plugin protocol/facade classes, dead metrics and DB helpers, and consolidates duplicated admin-guard, registration, and spam-handling boilerplate into shared helpers. No behavior change; coverage held at 99%.
rezhajulio
commented
Jul 4, 2026
| return message.forward_origin is not None | ||
|
|
||
|
|
||
| def has_link(message: Message) -> bool: |
Owner
Author
There was a problem hiding this comment.
Zero callers anywhere in src or tests — grepped the whole repo to confirm. Actual link/URL spam detection lives lower in this same file (entity-by-entity check against the whitelist), so has_link was a coarser, unused duplicate nothing ever called.
rezhajulio
commented
Jul 4, 2026
| _get_user_bio_cache(context).pop(user_id, None) | ||
|
|
||
|
|
||
| def _get_bio_bait_metrics(context: ContextTypes.DEFAULT_TYPE) -> dict[str, int]: |
Owner
Author
There was a problem hiding this comment.
do we no longer use any metrics for bio bait spam/scam?
Owner
Author
There was a problem hiding this comment.
Confirmed via repo-wide grep: these were write-only counters in bot_data, incremented but never read anywhere — no /stats command, no export, no log line, no test asserting on them. Not wired to any consumer, so no metrics were actually lost.
…fig state Docs had drifted from code: stale file line counts, a bypass_for/enabled_plugins API that no longer exists, missing bio_bait.py handler/plugin, and undocumented duplicate-spam/bio-bait/PLUGINS_DEFAULT env vars and GroupConfig fields.
Diagram predated the bio_bait.py handler; wire it in parallel to contact-card spam, covering admin/trusted bypass and monitor-only mode.
Old diagram treated topic_guard, contact/inline/probation spam, and profile checks as one sequential function; they're actually independent PTB handlers at groups -1..5, each able to stop propagation. Rebuilt the diagram around that real group order and added every branch that was missing: inline_keyboard_spam, duplicate_spam, bio_bait, /check, /trust, /untrust, /trusted, their button callbacks, the admin-refresh job, and the accurate DM multi-group unrestriction loop. Also flags a real registration bug found while verifying this: duplicate_spam and bio_bait_spam are both registered at group=4 with the identical filter (GROUPS & not COMMAND). PTB checks handlers in registration order and stops after the first match (block defaults to True), and duplicate_spam is listed before bio_bait_spam in MANIFEST_ORDER, so bio_bait_spam's handler never actually runs.
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.
Summary
PluginProtocol/facade classes,ADMIN_COMMANDS, write-only bio-bait metrics, unreferencedis_monitored/is_plugin_enabled/get_warnings_past_time_threshold, per-group trustNotImplementedErrorbranches that were never exercised.Test plan
uv run ruff check .— cleanuv run mypy src/bot/ tests/— no issues in 68 source filesuv run pytest --cov=bot --cov-report=term-missing— 99% coverage maintained, all tests passing