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

20 lines
581 B
TypeScript
Raw Normal View History

2020-03-19 16:21:35 +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 16:21:35 +03:00
export type TelegrafHearsTriggers = HearsTriggers<Context>;
export interface HearsOptions {
triggers: TelegrafHearsTriggers;
}
2020-03-19 16:21:35 +03:00
/**
* Registers middleware for handling text messages.
*
* @see https://telegraf.js.org/#/?id=hears
2020-03-19 16:21:35 +03:00
*/
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
2020-03-19 16:21:35 +03:00
return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
};