I am writing a chat bot for VK. Library - node-vk-bot-api

There is a problem, for example the bot has a "command", or it "listens" to a certain word:

bot.event(/^(помощь)/i, function(ctx) { блаблабла }) 

It follows from the regular list - that it is important that the word "help" be the first and does not matter the register. But if I have another "help 2" command, then it is ignored, because the bot is already targeting the function above.

Tried to do through

  bot.command(/^(помощь)/i, function(ctx) { блаблабла }) bot.command(/^(помощь 2)/i, function(ctx) { блаблабла }) 

the result is similar

Question: Is it possible to set such a parameter in a regular expression so that the method will react only if it is the only word in the line at all?

I thought about the option that if the bot finds the word help, then it determines whether there are additional words in the line that can redirect to another function. But decided that the method is dirty. Are there any other ways around this? Thank you in advance!

1 answer 1

Try with a line terminator: /^(помощь)$/i

  • one
    It helped! Thank you - Danil