mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-01-11 22:51:06 +03:00
Add options to telegraf instance
This commit is contained in:
parent
9e02f3aebf
commit
ade4088551
@ -1,17 +1,16 @@
|
|||||||
import { Injectable, Inject, Logger } from '@nestjs/common'
|
import { Inject, Injectable, Logger } from '@nestjs/common'
|
||||||
import { ModuleRef } from '@nestjs/core'
|
import { ModuleRef } from '@nestjs/core'
|
||||||
import Telegraf, { ContextMessageUpdate } from 'telegraf'
|
|
||||||
import { flatten, head } from 'lodash'
|
import { flatten, head } from 'lodash'
|
||||||
|
import Telegraf, { ContextMessageUpdate } from 'telegraf'
|
||||||
import { TelegramCatch, TelegramActionHandler } from './decorators'
|
import { TelegramActionHandler, TelegramCatch } from './decorators'
|
||||||
import { TokenInjectionToken } from './telegraf.constants'
|
import { InvalidConfigurationException } from './exeptions'
|
||||||
import {
|
import {
|
||||||
|
ContextTransformer,
|
||||||
|
Handler,
|
||||||
TelegrafOptionsFactory,
|
TelegrafOptionsFactory,
|
||||||
TelegramErrorHandler,
|
TelegramErrorHandler,
|
||||||
Handler,
|
|
||||||
ContextTransformer,
|
|
||||||
} from './interfaces'
|
} from './interfaces'
|
||||||
import { InvalidConfigurationException } from './exeptions'
|
import { TokenInjectionToken } from './telegraf.constants'
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TelegrafService {
|
export class TelegrafService {
|
||||||
@ -23,9 +22,13 @@ export class TelegrafService {
|
|||||||
public constructor(
|
public constructor(
|
||||||
@Inject(TokenInjectionToken) options: TelegrafOptionsFactory
|
@Inject(TokenInjectionToken) options: TelegrafOptionsFactory
|
||||||
) {
|
) {
|
||||||
const { token, sitePublicUrl } = options.createTelegrafOptions()
|
const {
|
||||||
|
token,
|
||||||
|
sitePublicUrl,
|
||||||
|
telegrafOptions,
|
||||||
|
} = options.createTelegrafOptions()
|
||||||
this.sitePublicUrl = sitePublicUrl
|
this.sitePublicUrl = sitePublicUrl
|
||||||
this.bot = new Telegraf(token)
|
this.bot = new Telegraf(token, telegrafOptions)
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(ref: ModuleRef, devMode: boolean = false) {
|
public init(ref: ModuleRef, devMode: boolean = false) {
|
||||||
|
Loading…
Reference in New Issue
Block a user