From 05d7ae7b12a3750b1fbc29bd719724a1f3647738 Mon Sep 17 00:00:00 2001 From: Aleksandr Bukhalo Date: Fri, 14 Aug 2020 01:21:33 +0300 Subject: [PATCH] feat: add new @Update decorator --- lib/decorators/index.ts | 1 + lib/decorators/update.decorator.ts | 8 ++++++++ lib/telegraf.constants.ts | 1 + 3 files changed, 10 insertions(+) create mode 100644 lib/decorators/update.decorator.ts diff --git a/lib/decorators/index.ts b/lib/decorators/index.ts index 37dcea4..76f6f1a 100644 --- a/lib/decorators/index.ts +++ b/lib/decorators/index.ts @@ -14,3 +14,4 @@ export * from './telegraf-cashtag.decorator'; export * from './telegraf-action.decorator'; export * from './telegraf-inline-query.decorator'; export * from './telegraf-game-query.decorator'; +export * from './update.decorator'; diff --git a/lib/decorators/update.decorator.ts b/lib/decorators/update.decorator.ts new file mode 100644 index 0000000..985bb8e --- /dev/null +++ b/lib/decorators/update.decorator.ts @@ -0,0 +1,8 @@ +import { SetMetadata } from '@nestjs/common'; +import { DECORATORS } from '../telegraf.constants'; + +/** + * `@Update` decorator, it's like NestJS `@Controller` decorator, + * only for Telegram Bot API updates. + */ +export const Update = (): ClassDecorator => SetMetadata(DECORATORS.UPDATE, {}); diff --git a/lib/telegraf.constants.ts b/lib/telegraf.constants.ts index 59f27a2..b21ebd4 100644 --- a/lib/telegraf.constants.ts +++ b/lib/telegraf.constants.ts @@ -18,4 +18,5 @@ export const DECORATORS = { ACTION: `${DECORATORS_PREFIX}/ACTION`, INLINE_QUERY: `${DECORATORS_PREFIX}/INLINE_QUERY`, GAME_QUERY: `${DECORATORS_PREFIX}/GAME_QUERY`, + UPDATE: `${DECORATORS_PREFIX}/UPDATE`, };