windkh/node-red-contrib-telegrambot

Failed to call /setMyCommands to catch as reply message

nkgiovannivl opened this issue · 5 comments

Hi all,

Using the functionality 'Register at telegram server' on 'command node' to register a command as reply get a error:

image

This kind of command it's called when in my group the boot as mentioned in reply of a message answer:

image

image

But if in node configuration set without @, it works (I need to use update de bot config option to take this kind on changes not just change de command node options)

So, the steps to reproduce:

  1. On telegram add the bot to a group.
  2. On telegram select any message and select reply to message.
  3. On telegram select any bot command palette (/) and reply.
  4. On node red edit 'command node' and set ''Register at telegram server'' option and type the command (/command@bot_name_bot)
  5. Press the pencil to edit the bot and press update to take the changes.
  6. Deploy the flow.
windkh commented

well adding @ to a command is not allowed by telegram.
Maybe there is a misunderstanding here. If you use the bot in groups you should enable the strict in groups option.

windkh commented

https://core.telegram.org/bots/api#botcommand

Text of the command; 1-32 characters. Can contain only lowercase English letters, digits and underscores

well adding @ to a command is not allowed by telegram. Maybe there is a misunderstanding here. If you use the bot in groups you should enable the strict in groups option.

well, I'm still stuck, I'm already set your suggestion in "command node" (error disappear):

image

But I'm not catch the command requested to my bot using "command node"

image

image

I see the command using "receiver node"

image

Need I use "command node" to configure the command bot and the "receiver node" to check the content and verify if it is a command? or am I'm missing something to filter the command on "command node" to include @botName in the command filter?

Thanks for your support!

windkh commented

The command node receives messages like a receiver node but it only passes the message to its output if the message starts with the configured command. The receiver node receives everything. But there is an option in the receiver node to filter away all commands that are already handled by all other command nodes.

image

Now you have two options:

  1. Only use a receiver node and do the filtering in a function node after the receiver node
  2. or just use command nodes and the receiver node with filtering on

The command node checks if a message:

  • starts with /
  • if the command is from a group chat (<0) or a private chat (>0) --> strict mode
  • if the command ends with @botName
    if so then the message is passed through

The command node receives messages like a receiver node but it only passes the message to its output if the message starts with the configured command. The receiver node receives everything. But there is an option in the receiver node to filter away all commands that are already handled by all other command nodes.

image

Now you have two options:

  1. Only use a receiver node and do the filtering in a function node after the receiver node
  2. or just use command nodes and the receiver node with filtering on

The command node checks if a message:

  • starts with /
  • if the command is from a group chat (<0) or a private chat (>0) --> strict mode
  • if the command ends with @botName
    if so then the message is passed through

OK I found my problem, in the config node, I was using my Bot-Name (as guide explains), but I need to use Bot-UserName (ends with _bot and without @) to get command node work properly, so the 3th point of your explanation take sense.

Thanks!