mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-23 09:49:06 +03:00
feat(): add middleware support & refactor
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=action
|
||||
*/
|
||||
export const Action = createUpdateDecorator('action');
|
||||
export const Action = createUpdateListenerDecorator('action');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Cashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=cashtag
|
||||
*/
|
||||
export const Cashtag = createUpdateDecorator('cashtag');
|
||||
export const Cashtag = createUpdateListenerDecorator('cashtag');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Command handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=command
|
||||
*/
|
||||
export const Command = createUpdateDecorator('command');
|
||||
export const Command = createUpdateListenerDecorator('command');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with email entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-email
|
||||
*/
|
||||
export const Email = createUpdateDecorator('email');
|
||||
export const Email = createUpdateListenerDecorator('email');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with game query.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const GameQuery = createUpdateDecorator('gameQuery');
|
||||
export const GameQuery = createUpdateListenerDecorator('gameQuery');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Hashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hashtag
|
||||
*/
|
||||
export const Hashtag = createUpdateDecorator('hashtag');
|
||||
export const Hashtag = createUpdateListenerDecorator('hashtag');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling text messages.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hears
|
||||
*/
|
||||
export const Hears = createUpdateDecorator('hears');
|
||||
export const Hears = createUpdateListenerDecorator('hears');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /help command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=help
|
||||
*/
|
||||
export const Help = createUpdateDecorator('help');
|
||||
export const Help = createUpdateListenerDecorator('help');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling inline_query actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const InlineQuery = createUpdateDecorator('inlineQuery');
|
||||
export const InlineQuery = createUpdateListenerDecorator('inlineQuery');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Mention handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=mention
|
||||
*/
|
||||
export const Mention = createUpdateDecorator('mention');
|
||||
export const Mention = createUpdateListenerDecorator('mention');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for provided update type.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=on
|
||||
*/
|
||||
export const On = createUpdateDecorator('on');
|
||||
export const On = createUpdateListenerDecorator('on');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Phone number handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=phone
|
||||
*/
|
||||
export const Phone = createUpdateDecorator('phone');
|
||||
export const Phone = createUpdateListenerDecorator('phone');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /settings command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=settings
|
||||
*/
|
||||
export const Settings = createUpdateDecorator('settings');
|
||||
export const Settings = createUpdateListenerDecorator('settings');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /start command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=start
|
||||
*/
|
||||
export const Start = createUpdateDecorator('start');
|
||||
export const Start = createUpdateListenerDecorator('start');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_link entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextLink = createUpdateDecorator('textLink');
|
||||
export const TextLink = createUpdateListenerDecorator('textLink');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_mention entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextMention = createUpdateDecorator('textMention');
|
||||
export const TextMention = createUpdateListenerDecorator('textMention');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with url entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-url
|
||||
*/
|
||||
export const Url = createUpdateDecorator('url');
|
||||
export const Url = createUpdateListenerDecorator('url');
|
||||
|
@@ -1,8 +1,8 @@
|
||||
import { createUpdateDecorator } from '../../helpers/create-update-decorator.helper';
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers a middleware.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=use
|
||||
*/
|
||||
export const Use = createUpdateDecorator('use');
|
||||
export const Use = createUpdateListenerDecorator('use');
|
||||
|
@@ -1,6 +1,3 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
|
||||
import { SceneEventType } from '../../enums/scene-event-type.enum';
|
||||
import { createSceneListenerDecorator } from '../../helpers';
|
||||
|
||||
export const SceneEnter = (): MethodDecorator =>
|
||||
SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Enter);
|
||||
export const SceneEnter = createSceneListenerDecorator('enter');
|
||||
|
@@ -1,6 +1,3 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { SCENE_LISTENER_METADATA } from '../../telegraf.constants';
|
||||
import { SceneEventType } from '../../enums/scene-event-type.enum';
|
||||
import { createSceneListenerDecorator } from '../../helpers';
|
||||
|
||||
export const SceneLeave = (): MethodDecorator =>
|
||||
SetMetadata(SCENE_LISTENER_METADATA, SceneEventType.Leave);
|
||||
export const SceneLeave = createSceneListenerDecorator('leave');
|
||||
|
Reference in New Issue
Block a user