mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-27 00:08:09 +03:00
29 lines
727 B
TypeScript
29 lines
727 B
TypeScript
import {
|
|
Injectable,
|
|
Inject,
|
|
OnApplicationBootstrap,
|
|
Logger,
|
|
} from '@nestjs/common';
|
|
import Telegraf, { ContextMessageUpdate } from 'telegraf';
|
|
import { TELEGRAF_MODULE_OPTIONS } from './telegraf.constants';
|
|
import { TelegrafModuleOptions } from './interfaces';
|
|
|
|
@Injectable()
|
|
// @ts-ignore
|
|
export class TelegrafProvider<TContext extends ContextMessageUpdate>
|
|
extends Telegraf<TContext>
|
|
implements OnApplicationBootstrap {
|
|
private logger = new Logger('Telegraf');
|
|
|
|
constructor(@Inject(TELEGRAF_MODULE_OPTIONS) options: TelegrafModuleOptions) {
|
|
super(options.token, options.options);
|
|
}
|
|
|
|
onApplicationBootstrap() {
|
|
this.catch(e => {
|
|
this.logger.error(e);
|
|
});
|
|
this.startPolling();
|
|
}
|
|
}
|