Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
721 stars 143 forks source link

Problem with RegExp route #84

Closed edakhmetgareev closed 8 years ago

edakhmetgareev commented 8 years ago

Hello,

I have catched a problem with regexp route setting. When I try to set something like this tg.router.when([/\/top10/, /\/top3/], new TopController()) without /g key, then in TelegramRouter.js on line 231 this code while (arg = command.exec(message.text)) { query.push(arg[1] || arg[0]) }

goes into an infinite loop.

VitaliyR commented 8 years ago

👍 confirm it, really annoying. Temp solution:

.when({ name: 'Search', test: m => m.text.match(/.+/) }, new SearchController(config));
JoshBones commented 8 years ago

I ran into this just now as well, there is a pretty quick fix, from line 321 in TelegramRouter:

while (arg = command.exec(message.text)) {
  query.push(arg[1] || arg[0])

  if (command.lastIndex === 0)
    break;
}

I might submit a PR tomorrow, too tired to think right now 😉

Naltox commented 8 years ago

Fixed!