From ed2c96c6f1a3606fac898de47377fa6b0f0d2285 Mon Sep 17 00:00:00 2001 From: Aleksandr Bukhalo Date: Sat, 29 Feb 2020 21:26:02 +0300 Subject: [PATCH] fix(telegraf-service): ability to listen to all messages has been added --- lib/telegraf.service.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/telegraf.service.ts b/lib/telegraf.service.ts index f927acb..5ba6e8a 100644 --- a/lib/telegraf.service.ts +++ b/lib/telegraf.service.ts @@ -109,10 +109,16 @@ export class TelegrafService { } private setupOnMessage(handlers: Handler[]): void { - const onMessageHandlers = handlers.filter(({ config }) => config.message) + const onMessageHandlers = handlers.filter( + ({ config }) => config.message !== undefined + ) onMessageHandlers.forEach(handler => { - this.bot.hears(handler.config.message, this.adoptHandle(handler)) + if (handler.config.message) { + this.bot.hears(handler.config.message, this.adoptHandle(handler)) + } else { + this.bot.on('message', this.adoptHandle(handler)) + } }) }