Skip to content

fix: match commands addressed to the bot by username - #320

Merged
negasus merged 1 commit into
go-telegram:mainfrom
INKCR0W:fix-command-bot-username
Nov 23, 2026
Merged

negasus merged 1 commit into
go-telegram:mainfrom
INKCR0W:fix-command-bot-username

Conversation

@INKCR0W

@INKCR0W INKCR0W commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #174.

In groups, a command picked from the menu arrives with the bot's username appended, like /start@my_bot. Command handlers compare the whole start@my_bot with the pattern, so a handler for start never gets it. This affects every command, not just /start.

GetMe now records the bot's username, and MatchTypeCommand and MatchTypeCommandStartOnly handlers also match commands addressed to it, comparing the username case-insensitively. /start@other_bot still doesn't match. New already calls GetMe, so this works by default. With WithSkipGetMe, call GetMe yourself to enable it. SetToken with another bot's token clears the username.

Behavior change: if a start handler is registered before another handler for /start@my_bot, that command now goes to the start handler.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.41%. Comparing base (d23f36c) to head (23a492b).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
+ Coverage   63.16%   63.41%   +0.25%     
==========================================
  Files          40       40              
  Lines        3404     3428      +24     
==========================================
+ Hits         2150     2174      +24     
- Misses       1195     1196       +1     
+ Partials       59       58       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@negasus
negasus merged commit 4b50daf into go-telegram:main Nov 23, 2026
3 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.

Group-like syntax commands

3 participants