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