mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-23 09:49:06 +03:00
feat(): wip
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { BaseScene as Scene } from 'telegraf';
|
||||
import { ComposerMethodArgs, SceneMethods } from '../types';
|
||||
import { UPDATE_LISTENER_METADATA } from '../telegraf.constants';
|
||||
import { LISTENER_METADATA } from '../telegraf.constants';
|
||||
import { ListenerMetadata } from '../interfaces';
|
||||
|
||||
export function createListenerDecorator<TMethod extends SceneMethods>(
|
||||
@@ -10,7 +10,7 @@ export function createListenerDecorator<TMethod extends SceneMethods>(
|
||||
return (
|
||||
...args: ComposerMethodArgs<Scene<never>, TMethod>
|
||||
): MethodDecorator => {
|
||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||
return SetMetadata(LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
} as ListenerMetadata);
|
||||
@@ -21,7 +21,7 @@ export function createMissedListenerDecorator<TArgs extends any[]>(
|
||||
method: string,
|
||||
) {
|
||||
return (...args: TArgs): MethodDecorator => {
|
||||
return SetMetadata(UPDATE_LISTENER_METADATA, {
|
||||
return SetMetadata(LISTENER_METADATA, {
|
||||
method,
|
||||
args,
|
||||
} as ListenerMetadata);
|
||||
|
@@ -48,39 +48,3 @@ export const addPipesMetadata = (
|
||||
key,
|
||||
);
|
||||
};
|
||||
|
||||
// export function createTelegrafParamDecorator(
|
||||
// paramtype: TelegrafParamtype,
|
||||
// ): (...pipes: (Type<PipeTransform> | PipeTransform)[]) => ParameterDecorator {
|
||||
// return (...pipes: (Type<PipeTransform> | PipeTransform)[]) => (
|
||||
// target,
|
||||
// key,
|
||||
// index,
|
||||
// ) => {
|
||||
// const args =
|
||||
// Reflect.getMetadata(LISTENER_ARGS_METADATA, target.constructor, key) ||
|
||||
// {};
|
||||
// Reflect.defineMetadata(
|
||||
// LISTENER_ARGS_METADATA,
|
||||
// assignMetadata(args, paramtype, index, undefined, ...pipes),
|
||||
// target.constructor,
|
||||
// key,
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
//
|
||||
// export const createPipesTelegrafParamDecorator = (
|
||||
// paramtype: TelegrafParamtype,
|
||||
// ) => (
|
||||
// ...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
// ): ParameterDecorator => (target, key, index) => {
|
||||
// const args =
|
||||
// Reflect.getMetadata(LISTENER_ARGS_METADATA, target.constructor, key) || {};
|
||||
//
|
||||
// Reflect.defineMetadata(
|
||||
// LISTENER_ARGS_METADATA,
|
||||
// assignMetadata(args, paramtype, index, undefined, ...pipes),
|
||||
// target.constructor,
|
||||
// key,
|
||||
// );
|
||||
// };
|
||||
|
Reference in New Issue
Block a user