From ade4088551118f56babadd04dfb02d22b61a3e95 Mon Sep 17 00:00:00 2001 From: Alexey Lepskii Date: Sat, 29 Feb 2020 12:38:32 +0300 Subject: [PATCH] Add options to telegraf instance --- lib/telegraf.service.ts | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/telegraf.service.ts b/lib/telegraf.service.ts index 48a27a5..f927acb 100644 --- a/lib/telegraf.service.ts +++ b/lib/telegraf.service.ts @@ -1,17 +1,16 @@ -import { Injectable, Inject, Logger } from '@nestjs/common' +import { Inject, Injectable, Logger } from '@nestjs/common' import { ModuleRef } from '@nestjs/core' -import Telegraf, { ContextMessageUpdate } from 'telegraf' import { flatten, head } from 'lodash' - -import { TelegramCatch, TelegramActionHandler } from './decorators' -import { TokenInjectionToken } from './telegraf.constants' +import Telegraf, { ContextMessageUpdate } from 'telegraf' +import { TelegramActionHandler, TelegramCatch } from './decorators' +import { InvalidConfigurationException } from './exeptions' import { + ContextTransformer, + Handler, TelegrafOptionsFactory, TelegramErrorHandler, - Handler, - ContextTransformer, } from './interfaces' -import { InvalidConfigurationException } from './exeptions' +import { TokenInjectionToken } from './telegraf.constants' @Injectable() export class TelegrafService { @@ -23,9 +22,13 @@ export class TelegrafService { public constructor( @Inject(TokenInjectionToken) options: TelegrafOptionsFactory ) { - const { token, sitePublicUrl } = options.createTelegrafOptions() + const { + token, + sitePublicUrl, + telegrafOptions, + } = options.createTelegrafOptions() this.sitePublicUrl = sitePublicUrl - this.bot = new Telegraf(token) + this.bot = new Telegraf(token, telegrafOptions) } public init(ref: ModuleRef, devMode: boolean = false) {