mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2024-12-25 07:24:39 +03:00
28 lines
846 B
TypeScript
28 lines
846 B
TypeScript
import { SetMetadata } from '@nestjs/common';
|
|
import { DECORATORS } from '../telegraf.constants';
|
|
import { HearsTriggers } from 'telegraf/typings/composer';
|
|
import { Context } from '../interfaces';
|
|
|
|
export type TelegrafActionTriggers = HearsTriggers<Context>;
|
|
|
|
export interface ActionOptions {
|
|
triggers: TelegrafActionTriggers;
|
|
}
|
|
|
|
/**
|
|
* Registers middleware for handling callback_data actions with regular expressions.
|
|
*
|
|
* @see https://telegraf.js.org/#/?id=action
|
|
*/
|
|
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
|
|
return SetMetadata(DECORATORS.ACTION, { triggers });
|
|
};
|
|
|
|
/**
|
|
* Registers middleware for handling callback_data actions with regular expressions.
|
|
*
|
|
* @see https://telegraf.js.org/#/?id=action
|
|
* @deprecated since v2, use Action decorator instead.
|
|
*/
|
|
export const TelegrafAction = Action;
|