edisonchee / slimbot

Telegram Bot API for Node.js
MIT License
223 stars 37 forks source link

bot_command handling #31

Closed suntong closed 3 years ago

suntong commented 5 years ago

Hi All,

When sending commands to bots, there are two cases -

In both case, the

"entities":[{"offset":x,"length":y,"type":"bot_command"}]

part will be the same (for the /start command; however, the message.text part will be different, with the @bot in group containing that @ mention part, which pointed out by {"offset":7,"length":12,"type":"mention"}.

In summary, bot command can be of the form /help or /help @botname in message.text. Is there any builtin helper to ease command writing that, I can easily do, say message.bot_command === "/help", that can cover both above two cases?

thx

suntong commented 5 years ago

Ah, to make it simple, Is there any builtin helper to remove the "type":"mention" portion from the command? So /help and /help @botname becomes the same, and

@botname /do with parameters

become easy to handle?

edisonchee commented 5 years ago

Hey @suntong, thanks for the feedback. I'll look into this.

Meanwhile, if you have an existing working implementation, make a pull request and we'll work on it together from there.

suntong commented 5 years ago

I haven't touched the node/bot/js since then, and now while I'm re-reading what I wrote, I've lost the context why my proposed way is better, :) I think it is the difficulties on using the API, but I've lost all my memory on this matter, since I had never been a js/node programmer. Anyway, if I am to revisit the topic, I'll see if I can send in a PR -- previously I wasn't even sure if the idea is acceptable or not... :-)