2020-03-19 17:20:13 +03:00
|
|
|
import { SetMetadata } from '@nestjs/common';
|
|
|
|
import { DECORATORS } from '../telegraf.constants';
|
|
|
|
import { HearsTriggers } from 'telegraf';
|
|
|
|
|
2020-03-19 18:20:07 +03:00
|
|
|
export type TelegrafActionTriggers = HearsTriggers;
|
|
|
|
|
|
|
|
export interface TelegrafActionMetadata {
|
|
|
|
triggers: TelegrafActionTriggers;
|
|
|
|
}
|
|
|
|
|
2020-03-19 17:20:13 +03:00
|
|
|
/**
|
|
|
|
* Registers middleware for handling callback_data actions with regular expressions.
|
|
|
|
* @param triggers Triggers
|
|
|
|
*
|
|
|
|
* https://telegraf.js.org/#/?id=action
|
|
|
|
*/
|
2020-03-19 18:20:07 +03:00
|
|
|
export function TelegrafAction(
|
|
|
|
triggers: TelegrafActionTriggers,
|
|
|
|
): MethodDecorator {
|
2020-03-19 17:20:13 +03:00
|
|
|
return SetMetadata(DECORATORS.ACTION, { triggers });
|
|
|
|
}
|