Skip to content

Add keyboard detection to spam filters #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2025
Merged

Conversation

umputun
Copy link
Owner

@umputun umputun commented Mar 5, 2025

Summary

  • Add ability to detect and flag messages with attached keyboards (buttons) as spam
  • Add --meta.keyboard configuration flag for enabling keyboard detection
  • Implement KeyboardCheck meta check function
  • Update internal data structures to track keyboards in messages

Fixes #258

This implementation adds the ability to detect and flag messages with attached keyboards (buttons) as spam.

- Add HasKeyboard field to MetaData struct
- Update Message struct with WithKeyboard flag
- Detect keyboards in the transform function
- Add KeyboardCheck meta check function
- Add configuration option in main.go
- Update webapi settings
- Add tests for keyboard detection

Fixes #258
Copy link

Deploying tg-spam with  Cloudflare Pages  Cloudflare Pages

Latest commit: aa94af6
Status: ✅  Deploy successful!
Preview URL: https://ccae0396.tg-spam.pages.dev
Branch Preview URL: https://feature-keyboard-detection.tg-spam.pages.dev

View logs

@umputun umputun requested a review from Copilot March 5, 2025 23:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR adds keyboard detection to spam filters by implementing a new KeyboardCheck meta check function and updating related data structures, configuration, and tests.

  • Implements KeyboardCheck in the meta checks framework.
  • Adds configuration flags, request field propagation, and tests for keyboard detection.
  • Updates event handling and settings to support the new keyboard detection feature.

Reviewed Changes

File Description
lib/tgspam/metachecks_test.go Adds tests for the new KeyboardCheck meta check
lib/tgspam/metachecks.go Implements the KeyboardCheck meta check function
app/main.go Updates configuration to include a new keyboard flag
app/events/events.go Adds keyboard detection logic based on attached button markups
lib/spamcheck/spamcheck.go Updates Request string formatting to include the has_keyboard flag
app/bot/bot.go Adds WithKeyboard field to the bot message struct
app/bot/spam.go Propagates the keyboard flag from bot messages to the spam check request
lib/spamcheck/spamcheck_test.go Updates tests to verify proper handling of the keyboard field
app/webapi/webapi.go Updates Settings struct to include the MetaKeyboard flag

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

@umputun umputun merged commit 2e07614 into master Mar 5, 2025
5 checks passed
@umputun umputun deleted the feature/keyboard-detection branch March 5, 2025 23:35
umputun added a commit that referenced this pull request Mar 6, 2025
- Display keyboard detection setting in the Meta Checks section of the settings page
- The feature was added in PR #259 but was missing from the UI
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.

messages with attached keyboards
1 participant