Naltox / telegram-node-bot

Node module for creating Telegram bots.
MIT License
720 stars 144 forks source link

RegexpCommand - is not installed #176

Closed Yojj closed 7 years ago

Yojj commented 7 years ago

использую из примера .when( new RegexpCommand(new RegExp(/test/, 'g'), 'testHandler'), new TestController() )

пишет RegexpCommand - is not installed

new RegexpCommand(new RegExp(/test/, 'g'), 'testHandler'), ^ ReferenceError: RegexpCommand is not defined

подскажите, пожалуйста, как решить? Спасибо!

rafaelpradella commented 7 years ago

Hi! I´m not sure if you already made it in the start of your file, but the RegexpCommand is a method inside the telegram-node-bot Class. Try calling it that way:

const Telegram = require('telegram-node-bot');
const RegexpCommand = Telegram.RegexpCommand;

.when(
new RegexpCommand(new RegExp(/test/, 'g'), 'testHandler'),
new TestController()
)

Hope it helps! ;)

magikcypress commented 7 years ago

Hello,

On the documentation this method is create and says that ...

tg.router
  .when(
      new RegexpCommand(/test/g, 'testHandler'),
      new TestController()
  )

but a loggout say "error Not implemented"

Regards

Yojj commented 7 years ago

Hello, example for works

var reg =/ Hi | Hello | Hao | Vitayu |\b/i;

tg.router .when(new Telegram.RegexpCommand ( reg, 'pingCommand'), new HiController() )