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[];
|
|
|
|
|
|
|
|
export interface TelegrafOnMetadata {
|
|
|
|
updateTypes: TelegrafOnUpdateTypes;
|
|
|
|
}
|
|
|
|
|
2020-03-19 16:21:35 +03:00
|
|
|
/**
|
|
|
|
* Registers middleware for provided update type.
|
|
|
|
* @param updateTypes Update type
|
|
|
|
*
|
|
|
|
* https://telegraf.js.org/#/?id=on
|
|
|
|
*/
|
|
|
|
export function TelegrafOn(
|
2020-03-19 18:20:07 +03:00
|
|
|
updateTypes: TelegrafOnUpdateTypes,
|
2020-03-19 16:21:35 +03:00
|
|
|
): MethodDecorator {
|
|
|
|
return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
|
|
|
|
}
|