From 63fe457b584d6e106f1af9d8de349abff4f7c07f Mon Sep 17 00:00:00 2001 From: Alexander Bukhalo Date: Sat, 2 Jan 2021 16:37:59 +0300 Subject: [PATCH] fix(): module work restored --- lib/helpers/create-update-listener-decorator.helper.ts | 2 +- lib/telegraf.providers.ts | 4 +++- sample/app.update.ts | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/helpers/create-update-listener-decorator.helper.ts b/lib/helpers/create-update-listener-decorator.helper.ts index 6c28eb2..a27f85b 100644 --- a/lib/helpers/create-update-listener-decorator.helper.ts +++ b/lib/helpers/create-update-listener-decorator.helper.ts @@ -5,7 +5,7 @@ import { UPDATE_LISTENER_METADATA } from '../telegraf.constants'; import { ListenerMetadata } from '../interfaces'; export function createUpdateListenerDecorator( - method: Method, + method: unknown, ) { return ( ...args: ComposerMethodArgs, Method> diff --git a/lib/telegraf.providers.ts b/lib/telegraf.providers.ts index 399efe7..b13de54 100644 --- a/lib/telegraf.providers.ts +++ b/lib/telegraf.providers.ts @@ -7,7 +7,9 @@ export const TelegrafProvider = { provide: Telegraf, useFactory: (options: TelegrafModuleOptions) => { const telegraf = new Telegraf(options.token, options.options); - telegraf.use(...options.middlewares); + if (options.middlewares?.length > 0) { + telegraf.use(...options.middlewares); + } return telegraf; }, inject: [TELEGRAF_MODULE_OPTIONS], diff --git a/sample/app.update.ts b/sample/app.update.ts index 402e9fb..f3c5022 100644 --- a/sample/app.update.ts +++ b/sample/app.update.ts @@ -1,4 +1,4 @@ -import { SceneContext, Telegraf } from 'telegraf'; +import { Telegraf } from 'telegraf'; import { Command, Help, InjectBot, On, Start, Update } from '../lib'; import { EchoService } from './echo.service'; import { HELLO_SCENE_ID } from './app.constants'; @@ -8,7 +8,7 @@ import { Context } from './interfaces/context.interface'; export class AppUpdate { constructor( @InjectBot() - private readonly bot: Telegraf, + private readonly bot: Telegraf, // TODO: fix any private readonly echoService: EchoService, ) {}