Repository navigation
fix: require_mention falls through to default agent instead of dropping message #376
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
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -858,7 +858,24 @@ fn build_metadata( | |||||
| metadata.insert("telegram_bot_username".into(), bot_username.clone().into()); | ||||||
| } | ||||||
|
|
||||||
| // Compute combined mentions-or-replies-to-bot flag for require_mention. | ||||||
| // Matches the pattern used by Discord/Slack/Twitch adapters. | ||||||
| let mut mentions_or_replies_to_bot = false; | ||||||
|
|
||||||
| // Check text-based @mention (Telegram sends mentions as entities) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Small nit: this comment says mentions come via entities, but the implementation is a case-insensitive substring search on extracted text/caption. Either parse entities, or tweak the comment to match what’s happening.
Suggested change
|
||||||
| if let Some(bot_username) = bot_username { | ||||||
| let bot_lower = bot_username.to_lowercase(); | ||||||
| if let Some(text) = extract_text(message) { | ||||||
| let text_lower = text.to_lowercase(); | ||||||
| let mention = format!("@{bot_lower}"); | ||||||
| if text_lower.contains(&mention) { | ||||||
| mentions_or_replies_to_bot = true; | ||||||
| } | ||||||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Reply-to context for threading | ||||||
| let mut reply_to_is_bot_match = false; | ||||||
| if let Some(reply) = message.reply_to_message() { | ||||||
| metadata.insert( | ||||||
| "reply_to_message_id".into(), | ||||||
|
|
@@ -884,10 +901,25 @@ fn build_metadata( | |||||
| ); | ||||||
| if let Some(username) = &from.username { | ||||||
| metadata.insert("reply_to_username".into(), username.clone().into()); | ||||||
| // Check if reply is to our bot specifically | ||||||
| if from.is_bot | ||||||
| && let Some(bot_username) = bot_username | ||||||
| && username.to_lowercase() == bot_username.to_lowercase() | ||||||
| { | ||||||
| reply_to_is_bot_match = true; | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| if !mentions_or_replies_to_bot && reply_to_is_bot_match { | ||||||
| mentions_or_replies_to_bot = true; | ||||||
| } | ||||||
| metadata.insert( | ||||||
| "telegram_mentions_or_replies_to_bot".into(), | ||||||
| serde_json::Value::Bool(mentions_or_replies_to_bot), | ||||||
| ); | ||||||
|
|
||||||
| (metadata, formatted_author) | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contains_key("discord_guild_id")treatsnullas present, so a DM could get misclassified and blocked whenrequire_mentionis on. Safer to mirror the oldas_u64().is_some()behavior.