Repository navigation
fix: ignore commands for other bots, end commands at line breaks, key FSM by sender chat - #47
Merged
Merged
Conversation
… FSM by sender chat - "/start@other_bot" no longer reaches HandleCommand, FilterCommand or Context.Command: in a group with several bots an admin bot answered commands meant for the others. The username comes from Client.Me, fetched once on the first @-addressed command; if it cannot be fetched the command is accepted as before. - A command ends at any whitespace: "/start\npayload" is routed to /start, and Message.Payload/CallbackQuery.Payload split at a line break or tab as Args already did. - The FSM state of a message sent on behalf of a chat (anonymous group administrators, users writing as a channel, automatic forwards) is keyed by that chat: they all come from one service user, so every such sender shared one state. Callback queries keep the presser's id. - FuzzEntityText guards EntityText against out-of-range entities. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
darxnet
force-pushed
the
fix/command-addressing-fsm-sender
branch
from
November 12, 2026 10:51
5084a24 to
c1c8dd6
Compare
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.
Three routing/FSM bugs found while checking the issues competitors fixed this week (aiogram#1997, go-telegram/bot#304, node-telegram-bot-api#1382, python-telegram-bot#5398).
Changes
/start@other_botno longer reachesHandleCommand,FilterCommandorctx.Command(): in a group with several bots, an admin bot (or one with privacy mode off) answered commands meant for the others. The username comes fromClient.Me, fetched once on the first @-addressed command; ifgetMefails, the command is accepted as before. A command for another bot is an ordinary message for this one (HandleOnMessagestill sees it)./start\npayloadis routed to/start;Message.PayloadandCallbackQuery.Payloadsplit at a line break or tab, asArgsalready did.GroupAnonymousBot,Channel_Bot), so every such sender shared one state. The state is now keyed bysender_chat; callback queries keep the presser's id. States previously stored under those service users are no longer found.FuzzEntityTextguardsEntityTextagainst out-of-range entity offsets and lengths (2.6M execs, no panic).Checked and left as is: the per-chat
Throttlewaits before the globalWithRPStoken is taken in the transport, so throttled chats do not consume global slots (the node-telegram-bot-api#1390 bug).Testing
make lintandmake testpass locally; new tests inaddressing_test.go, the existing@bottests now use a cannedgetMeinstead of the network.