mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-23 09:49:06 +03:00
Update to Telegraf v4.0.0 (#212)
* feat(telegraf): update to v4.0.0 * chore(lock): update package-lock * chore(deps): remove telegraf from dependencies * chore(readme): update installation command * chore(deps): add telegraf to dev dependencies
This commit is contained in:
@@ -3,8 +3,8 @@ import { TelegrafModuleOptions } from '../interfaces';
|
||||
|
||||
export async function createBotFactory(
|
||||
options: TelegrafModuleOptions,
|
||||
): Promise<Telegraf<never>> {
|
||||
const bot = new Telegraf<never>(options.token, options.options);
|
||||
): Promise<Telegraf<any>> {
|
||||
const bot = new Telegraf<any>(options.token, options.options);
|
||||
|
||||
bot.use(...(options.middlewares ?? []));
|
||||
await bot.launch(options.launchOptions);
|
||||
|
@@ -1,26 +1,14 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { BaseScene as Scene } from 'telegraf';
|
||||
import { ComposerMethodArgs, SceneMethods } from '../types';
|
||||
import { Composer } from 'telegraf';
|
||||
import { ComposerMethodArgs, OnlyFunctionPropertyNames } from '../types';
|
||||
import { LISTENER_METADATA } from '../telegraf.constants';
|
||||
import { ListenerMetadata } from '../interfaces';
|
||||
|
||||
export function createListenerDecorator<TMethod extends SceneMethods>(
|
||||
method: TMethod,
|
||||
) {
|
||||
return (
|
||||
...args: ComposerMethodArgs<Scene<never>, TMethod>
|
||||
): MethodDecorator => {
|
||||
return SetMetadata(LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
} as ListenerMetadata);
|
||||
};
|
||||
}
|
||||
|
||||
export function createMissedListenerDecorator<TArgs extends any[]>(
|
||||
method: string,
|
||||
) {
|
||||
return (...args: TArgs): MethodDecorator => {
|
||||
export function createListenerDecorator<
|
||||
TComposer extends Composer<never>,
|
||||
TMethod extends OnlyFunctionPropertyNames<TComposer> = OnlyFunctionPropertyNames<TComposer>
|
||||
>(method: TMethod) {
|
||||
return (...args: ComposerMethodArgs<TComposer, TMethod>): MethodDecorator => {
|
||||
return SetMetadata(LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
|
Reference in New Issue
Block a user