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

23 lines
609 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 { UpdateType, MessageSubTypes } from 'telegraf/typings/telegram-types';
export type TelegrafOnUpdateTypes =
| UpdateType
| UpdateType[]
| MessageSubTypes
| MessageSubTypes[];
export interface OnOptions {
updateTypes: TelegrafOnUpdateTypes;
}
2020-03-19 16:21:35 +03:00
/**
* Registers middleware for provided update type.
*
* @see https://telegraf.js.org/#/?id=on
2020-03-19 16:21:35 +03:00
*/
export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
2020-03-19 16:21:35 +03:00
return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
};