2020-03-19 16:21:35 +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 TelegrafHearsTriggers = HearsTriggers;
|
|
|
|
|
|
|
|
export interface TelegrafHearsMetadata {
|
|
|
|
triggers: TelegrafHearsTriggers;
|
|
|
|
}
|
|
|
|
|
2020-03-19 16:21:35 +03:00
|
|
|
/**
|
|
|
|
* Registers middleware for handling text messages.
|
|
|
|
* @param triggers Triggers
|
|
|
|
*
|
|
|
|
* https://telegraf.js.org/#/?id=hears
|
|
|
|
*/
|
2020-03-19 18:20:07 +03:00
|
|
|
export function TelegrafHears(
|
|
|
|
triggers: TelegrafHearsTriggers,
|
|
|
|
): MethodDecorator {
|
2020-03-19 16:21:35 +03:00
|
|
|
return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
|
|
|
|
}
|