nestjs-telegraf/lib/decorators/hears.decorator.ts
2020-08-14 12:42:57 +03:00

28 lines
779 B
TypeScript

import { SetMetadata } from '@nestjs/common';
import { DECORATORS } from '../telegraf.constants';
import { HearsTriggers } from 'telegraf/typings/composer';
import { Context } from '../interfaces';
export type TelegrafHearsTriggers = HearsTriggers<Context>;
export interface HearsOptions {
triggers: TelegrafHearsTriggers;
}
/**
* Registers middleware for handling text messages.
*
* @see https://telegraf.js.org/#/?id=hears
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
};
/**
* Registers middleware for handling text messages.
*
* @see https://telegraf.js.org/#/?id=hears
* @deprecated since v2, use Hears decorator instead.
*/
export const TelegrafHears = Hears;