Skip to content

Updated CommandHandler

Pre-release
Pre-release
Compare
Choose a tag to compare
@givip givip released this 20 Feb 06:38
· 36 commits to master since this release
a6b8878

In a group chat, Telegram allows specifying the bot to receive commands sent by a user by appending "@BotUsername" in the command, while this feature is not working as expected currently in Telegrammer:

If the user specifies the bot, the CommandHandler considers it a different command with "@" in the command name. We need to manually add a new command "/originalCommand@botUsername" to support it, which could be somehow misleading since most users (at least me) of this package would normally consider this automatically handled.

Using the workaround in 1. would cause each command to be coded twice, which can be tedious and inelegant in cases where there are many commands in a CommandHandler.
Therefore, I added the ability of checking the bot specified to the CommandHandler. This change does not break the existing API but only asks the username of the bot in the initializer optionally, and should then handle things correctly as intended.