Repository navigation
fix(telegram): ignore forum topic root when detecting replies to the bot - #23
Open
ibrahimsaleem wants to merge 1 commit into
Open
ibrahimsaleem wants to merge 1 commit into
ibrahimsaleem wants to merge 1 commit into
Conversation
…the bot Telegram sets reply_to_message on every plain message in a forum topic to the topic's forum_topic_created service message. When the bot created the topic, that message is authored by the bot, so all chatter in the topic passed the reply-to-bot addressing check. Ignore replies to the topic creation message; explicit replies to the bot's ordinary messages remain addressed.
Contributor
|
@ibrahimsaleem can you add screenshots of it working |
Author
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
In forum supergroups, Telegram sets
reply_to_messageon every ordinary message in atopic to the topic's
forum_topic_createdservice message. When the bot created thetopic (for example via
createForumTopic), that service message is authored by the bot.As a result,
normalizetreats every message in the topic as a reply to the bot, and agroup bot responds to all conversation in that topic instead of only to messages
addressed to it.
Change
normalizenow ignores a reply whose target is the topic's creation message. Explicitreplies to the bot's regular messages are still treated as addressed, and mention and
command handling are unchanged. The Python binding uses the same Rust function, so both
are covered.
Testing
bot_created_forum_topic_root_is_not_a_reply_to_the_bot) and aPython event test (
test_topic_chatter_under_a_bot_created_topic_is_not_addressed).Both fail before this change and pass after it.
cargo test --workspace,cargo clippy -- -D warnings,cargo fmt --check,pytest(529 passed),ruffandmypyall pass locally.References
Other agent frameworks have reported and fixed the same behaviour: