skip to Main Content

I have created and deployed a telegram bot which can perform some simple chat and analytics functions.

I have set a couple of / commands via botfathers /setcommands functionality and they all work fine.

However in group chats I have a problem, when I add the bot he works normally however the set commands that you can execute via the menu always include an @bot_name at the end of each command which invalidates them.

If I type in the command myself and remove the @mention, the commands work normally.

How can I tackle this issue, is it something I need to set in my code or in botfather?

2

Answers


  1. if ($cmd == "/command" || $cmd == "/command@BOT_USERNAME") {
      // handle scenario
    }
    
    Login or Signup to reply.
  2. My suggestion is to modify your code and replace the '@your_bot' with an empty string '' from the command before processing it. That way you automatically handle both scenarios for each of the available commands.

    Sadly, Telegram had a bug once or twice where it wouldn’t register the @your_bot messages sent to it. Luckily that bug was live for a very short period of time.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search