fix(telegraf-service): ability to listen to all messages has been added

This commit is contained in:
Aleksandr Bukhalo 2020-02-29 21:26:02 +03:00
parent ee6d2f9b0e
commit ed2c96c6f1

View File

@ -109,10 +109,16 @@ export class TelegrafService {
} }
private setupOnMessage(handlers: Handler[]): void { private setupOnMessage(handlers: Handler[]): void {
const onMessageHandlers = handlers.filter(({ config }) => config.message) const onMessageHandlers = handlers.filter(
({ config }) => config.message !== undefined
)
onMessageHandlers.forEach(handler => { 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))
}
}) })
} }