fix(): missing decorators & refactor

This commit is contained in:
Morb0
2021-01-03 16:11:17 +03:00
parent 90cb548551
commit f13eebe685
30 changed files with 71 additions and 96 deletions

View File

@@ -4,11 +4,24 @@ import { ComposerMethodArgs, SceneMethods } from '../types';
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
import { ListenerMetadata } from '../interfaces';
export function createListenerDecorator<Method extends SceneMethods>(
method: Method,
export function createListenerDecorator<TMethod extends SceneMethods>(
method: TMethod,
) {
return (
...args: ComposerMethodArgs<Scene<never>, Method>
...args: ComposerMethodArgs<Scene<never>, TMethod>
): MethodDecorator => {
return SetMetadata(UPDATE_LISTENER_METADATA, {
method,
args,
} as ListenerMetadata);
};
}
export function createMissedListenerDecorator<TArgs extends any[]>(
method: string,
) {
return (
...args: TArgs
): MethodDecorator => {
return SetMetadata(UPDATE_LISTENER_METADATA, {
method,

View File

@@ -1 +1,3 @@
export * from './get-bot-token.util';
export * from './create-bot-factory.util';
export * from './create-listener-decorator.util';