Skip to content

fix: move spam handlers to separate groups to fix anti-spam regression#5

Merged
rezhajulio merged 1 commit intomainfrom
fix/anti-spam-handler-group-regression
Feb 28, 2026
Merged

fix: move spam handlers to separate groups to fix anti-spam regression#5
rezhajulio merged 1 commit intomainfrom
fix/anti-spam-handler-group-regression

Conversation

@rezhajulio
Copy link
Owner

In PTB v20+, only the first matching handler per group runs. handle_inline_keyboard_spam (group=0) consumed all group messages, preventing handle_new_user_spam and handle_duplicate_spam from ever executing — introduced in 02d0967.

Changes:

  • Move each spam handler to its own group (1, 2, 3) so they all independently process every group message
  • Move handle_message (profile check) to group=4
  • Add ApplicationHandlerStop to handle_new_user_spam on violations to prevent later groups from processing deleted spam
  • Use >= instead of == for violation threshold to handle edge cases with concurrent updates or DB race conditions

In PTB v20+, only the first matching handler per group runs.
handle_inline_keyboard_spam (group=0) consumed all group messages,
preventing handle_new_user_spam and handle_duplicate_spam from ever
executing — introduced in 02d0967.

Changes:
- Move each spam handler to its own group (1, 2, 3) so they all
  independently process every group message
- Move handle_message (profile check) to group=4
- Add ApplicationHandlerStop to handle_new_user_spam on violations
  to prevent later groups from processing deleted spam
- Use >= instead of == for violation threshold to handle edge cases
  with concurrent updates or DB race conditions
@rezhajulio rezhajulio merged commit c06342f into main Feb 28, 2026
5 checks passed
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