nestjs-telegraf/lib/decorators/action.decorator.ts

20 lines
611 B
TypeScript
Raw Normal View History

2020-03-19 17:20:13 +03:00
import { SetMetadata } from '@nestjs/common';
import { DECORATORS } from '../telegraf.constants';
import { HearsTriggers } from 'telegraf/typings/composer';
import { Context } from '../interfaces';
2020-03-19 17:20:13 +03:00
export type TelegrafActionTriggers = HearsTriggers<Context>;
export interface ActionOptions {
triggers: TelegrafActionTriggers;
}
2020-03-19 17:20:13 +03:00
/**
* Registers middleware for handling callback_data actions with regular expressions.
*
* @see https://telegraf.js.org/#/?id=action
2020-03-19 17:20:13 +03:00
*/
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
2020-03-19 17:20:13 +03:00
return SetMetadata(DECORATORS.ACTION, { triggers });
};