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';
|
|
|
|
|
2020-03-19 18:20:07 +03:00
|
|
|
export type TelegrafOnUpdateTypes =
|
|
|
|
| UpdateType
|
|
|
|
| UpdateType[]
|
|
|
|
| MessageSubTypes
|
|
|
|
| MessageSubTypes[];
|
|
|
|
|
2020-08-14 12:42:57 +03:00
|
|
|
export interface OnOptions {
|
2020-03-19 18:20:07 +03:00
|
|
|
updateTypes: TelegrafOnUpdateTypes;
|
|
|
|
}
|
|
|
|
|
2020-03-19 16:21:35 +03:00
|
|
|
/**
|
|
|
|
* Registers middleware for provided update type.
|
|
|
|
*
|
2020-08-14 12:42:57 +03:00
|
|
|
* @see https://telegraf.js.org/#/?id=on
|
2020-03-19 16:21:35 +03:00
|
|
|
*/
|
2020-08-14 12:42:57 +03:00
|
|
|
export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
|
2020-03-19 16:21:35 +03:00
|
|
|
return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
|
2020-08-14 12:42:57 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Registers middleware for provided update type.
|
|
|
|
*
|
|
|
|
* @see https://telegraf.js.org/#/?id=on
|
|
|
|
* @deprecated since v2, use On decorator instead.
|
|
|
|
*/
|
|
|
|
export const TelegrafOn = On;
|