mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-23 09:49:06 +03:00
Merge branch 'feature/v2' of github.com:bukhalo/nestjs-telegraf into feature/multiple-instances
Conflicts: lib/decorators/inject-bot.decorator.ts lib/index.ts lib/interfaces/context.interface.ts lib/interfaces/index.ts lib/interfaces/telegraf-options.interface.ts lib/services/metadata-accessor.service.ts lib/services/updates-explorer.service.ts lib/telegraf-core.module.ts lib/telegraf.constants.ts package-lock.json
This commit is contained in:
@@ -1,27 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
import { HearsTriggers } from 'telegraf/typings/composer';
|
||||
import { Context } from '../interfaces';
|
||||
|
||||
export type TelegrafActionTriggers = HearsTriggers<Context>;
|
||||
|
||||
export interface ActionOptions {
|
||||
triggers: TelegrafActionTriggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=action
|
||||
*/
|
||||
export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.ACTION, { triggers });
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=action
|
||||
* @deprecated since v2, use Action decorator instead.
|
||||
*/
|
||||
export const TelegrafAction = Action;
|
@@ -1,25 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafCashtagCashtag = string | string[];
|
||||
|
||||
export interface CashtagOptions {
|
||||
cashtag: TelegrafCashtagCashtag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=cashtag
|
||||
*/
|
||||
export const Cashtag = (cashtag: TelegrafCashtagCashtag): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.CASHTAG, { cashtag });
|
||||
};
|
||||
|
||||
/**
|
||||
* Cashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=cashtag
|
||||
* @deprecated since v2, use Cashtag decorator instead.
|
||||
*/
|
||||
export const TelegrafCashtag = Cashtag;
|
@@ -1,25 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafCommandCommands = string | string[];
|
||||
|
||||
export interface CommandOptions {
|
||||
commands: TelegrafCommandCommands;
|
||||
}
|
||||
|
||||
/**
|
||||
* Command handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=command
|
||||
*/
|
||||
export const Command = (commands: TelegrafCommandCommands): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.COMMAND, { commands });
|
||||
};
|
||||
|
||||
/**
|
||||
* Command handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=command
|
||||
* @deprecated since v2, use Command decorator instead.
|
||||
*/
|
||||
export const TelegrafCommand = Command;
|
3
lib/decorators/core/index.ts
Normal file
3
lib/decorators/core/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './update.decorator';
|
||||
export * from './scene.decorator';
|
||||
export * from './inject-bot.decorator';
|
4
lib/decorators/core/inject-bot.decorator.ts
Normal file
4
lib/decorators/core/inject-bot.decorator.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Telegraf } from 'telegraf';
|
||||
|
||||
export const InjectBot = (): ParameterDecorator => Inject(Telegraf);
|
8
lib/decorators/core/scene.decorator.ts
Normal file
8
lib/decorators/core/scene.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { SCENE_METADATA } from '../../telegraf.constants';
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*/
|
||||
export const Scene = (id: string): ClassDecorator =>
|
||||
SetMetadata(SCENE_METADATA, id);
|
@@ -1,8 +1,8 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
import { UPDATE_METADATA } from '../../telegraf.constants';
|
||||
|
||||
/**
|
||||
* `@Update` decorator, it's like NestJS `@Controller` decorator,
|
||||
* but for Telegram Bot API updates.
|
||||
*/
|
||||
export const Update = (): ClassDecorator => SetMetadata(DECORATORS.UPDATE, {});
|
||||
export const Update = (): ClassDecorator => SetMetadata(UPDATE_METADATA, true);
|
@@ -1,30 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafEntityEntity =
|
||||
| string
|
||||
| string[]
|
||||
| RegExp
|
||||
| RegExp[]
|
||||
| Function;
|
||||
|
||||
export interface EntityOptions {
|
||||
entity: TelegrafEntityEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Entity handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=entity
|
||||
*/
|
||||
export const Entity = (entity: TelegrafEntityEntity): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.ENTITY, { entity });
|
||||
};
|
||||
|
||||
/**
|
||||
* Entity handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=entity
|
||||
* @deprecated since v2, use Entity decorator instead.
|
||||
*/
|
||||
export const TelegrafEntity = Entity;
|
@@ -1,19 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with game query.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const GameQuery = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.GAME_QUERY, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with game query.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
* @deprecated since v2, use Action decorator instead.
|
||||
*/
|
||||
export const TelegrafGameQuery = GameQuery;
|
@@ -1,25 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafHashtagHashtag = string | string[];
|
||||
|
||||
export interface HashtagOptions {
|
||||
hashtag: TelegrafHashtagHashtag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hashtag
|
||||
*/
|
||||
export const Hashtag = (hashtag: TelegrafHashtagHashtag): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.HASHTAG, { hashtag });
|
||||
};
|
||||
|
||||
/**
|
||||
* Hashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hashtag
|
||||
* @deprecated since v2, use Hashtag decorator instead.
|
||||
*/
|
||||
export const TelegrafHashtag = Hashtag;
|
@@ -1,27 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
import { HearsTriggers } from 'telegraf/typings/composer';
|
||||
import { Context } from '../interfaces';
|
||||
|
||||
export type TelegrafHearsTriggers = HearsTriggers<Context>;
|
||||
|
||||
export interface HearsOptions {
|
||||
triggers: TelegrafHearsTriggers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers middleware for handling text messages.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hears
|
||||
*/
|
||||
export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers middleware for handling text messages.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hears
|
||||
* @deprecated since v2, use Hears decorator instead.
|
||||
*/
|
||||
export const TelegrafHears = Hears;
|
@@ -1,19 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
/**
|
||||
* Handler for /help command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=help
|
||||
*/
|
||||
export const Help = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.HELP, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for /help command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=help
|
||||
* @deprecated since v2, use Help decorator instead.
|
||||
*/
|
||||
export const TelegrafHelp = Help;
|
@@ -1,18 +1,3 @@
|
||||
export * from './action.decorator';
|
||||
export * from './cashtag.decorator';
|
||||
export * from './command.decorator';
|
||||
export * from './entity.decorator';
|
||||
export * from './game-query.decorator';
|
||||
export * from './hashtag.decorator';
|
||||
export * from './hears.decorator';
|
||||
export * from './help.decorator';
|
||||
export * from './inject-bot.decorator';
|
||||
export * from './inline-query.decorator';
|
||||
export * from './mention.decorator';
|
||||
export * from './on.decorator';
|
||||
export * from './phone.decorator';
|
||||
export * from './settings.decorator';
|
||||
export * from './start.decorator';
|
||||
export * from './update.decorator';
|
||||
export * from './update-hooks.decorators';
|
||||
export * from './use.decorator';
|
||||
export * from './core';
|
||||
export * from './listeners';
|
||||
export * from './scene';
|
||||
|
@@ -1,36 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
import * as tt from 'telegraf/typings/telegram-types';
|
||||
|
||||
export type TelegrafInlineQueryTriggers = string | string[] | RegExp | RegExp[];
|
||||
|
||||
export interface InlineQueryOptions {
|
||||
triggers?: TelegrafInlineQueryTriggers;
|
||||
updateType:
|
||||
| tt.UpdateType
|
||||
| tt.UpdateType[]
|
||||
| tt.MessageSubTypes
|
||||
| tt.MessageSubTypes[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers middleware for handling inline_query actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const InlineQuery = (
|
||||
triggers?: TelegrafInlineQueryTriggers,
|
||||
): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.INLINE_QUERY, {
|
||||
triggers,
|
||||
updateType: 'inline_query',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers middleware for handling inline_query actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
* @deprecated since v2, use InlineQuery decorator instead.
|
||||
*/
|
||||
export const TelegrafInlineQuery = InlineQuery;
|
8
lib/decorators/listeners/action.decorator.ts
Normal file
8
lib/decorators/listeners/action.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=action
|
||||
*/
|
||||
export const Action = createUpdateListenerDecorator('action');
|
8
lib/decorators/listeners/cashtag.decorator.ts
Normal file
8
lib/decorators/listeners/cashtag.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Cashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=cashtag
|
||||
*/
|
||||
export const Cashtag = createUpdateListenerDecorator('cashtag');
|
8
lib/decorators/listeners/command.decorator.ts
Normal file
8
lib/decorators/listeners/command.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Command handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=command
|
||||
*/
|
||||
export const Command = createUpdateListenerDecorator('command');
|
8
lib/decorators/listeners/email.decorator.ts
Normal file
8
lib/decorators/listeners/email.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with email entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-email
|
||||
*/
|
||||
export const Email = createUpdateListenerDecorator('email');
|
8
lib/decorators/listeners/game-query.decorator.ts
Normal file
8
lib/decorators/listeners/game-query.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with game query.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const GameQuery = createUpdateListenerDecorator('gameQuery');
|
8
lib/decorators/listeners/hashtag.decorator.ts
Normal file
8
lib/decorators/listeners/hashtag.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Hashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hashtag
|
||||
*/
|
||||
export const Hashtag = createUpdateListenerDecorator('hashtag');
|
8
lib/decorators/listeners/hears.decorator.ts
Normal file
8
lib/decorators/listeners/hears.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling text messages.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hears
|
||||
*/
|
||||
export const Hears = createUpdateListenerDecorator('hears');
|
8
lib/decorators/listeners/help.decorator.ts
Normal file
8
lib/decorators/listeners/help.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /help command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=help
|
||||
*/
|
||||
export const Help = createUpdateListenerDecorator('help');
|
18
lib/decorators/listeners/index.ts
Normal file
18
lib/decorators/listeners/index.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export * from './on.decorator';
|
||||
export * from './use.decorator';
|
||||
export * from './action.decorator';
|
||||
export * from './cashtag.decorator';
|
||||
export * from './command.decorator';
|
||||
export * from './game-query.decorator';
|
||||
export * from './hashtag.decorator';
|
||||
export * from './hears.decorator';
|
||||
export * from './help.decorator';
|
||||
export * from './inline-query.decorator';
|
||||
export * from './mention.decorator';
|
||||
export * from './phone.decorator';
|
||||
export * from './settings.decorator';
|
||||
export * from './start.decorator';
|
||||
export * from './email.decorator';
|
||||
export * from './url.decorator';
|
||||
export * from './text-link.decorator';
|
||||
export * from './text-mention.decorator';
|
8
lib/decorators/listeners/inline-query.decorator.ts
Normal file
8
lib/decorators/listeners/inline-query.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling inline_query actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const InlineQuery = createUpdateListenerDecorator('inlineQuery');
|
8
lib/decorators/listeners/mention.decorator.ts
Normal file
8
lib/decorators/listeners/mention.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Mention handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=mention
|
||||
*/
|
||||
export const Mention = createUpdateListenerDecorator('mention');
|
8
lib/decorators/listeners/on.decorator.ts
Normal file
8
lib/decorators/listeners/on.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for provided update type.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=on
|
||||
*/
|
||||
export const On = createUpdateListenerDecorator('on');
|
8
lib/decorators/listeners/phone.decorator.ts
Normal file
8
lib/decorators/listeners/phone.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Phone number handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=phone
|
||||
*/
|
||||
export const Phone = createUpdateListenerDecorator('phone');
|
8
lib/decorators/listeners/settings.decorator.ts
Normal file
8
lib/decorators/listeners/settings.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /settings command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=settings
|
||||
*/
|
||||
export const Settings = createUpdateListenerDecorator('settings');
|
8
lib/decorators/listeners/start.decorator.ts
Normal file
8
lib/decorators/listeners/start.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Handler for /start command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=start
|
||||
*/
|
||||
export const Start = createUpdateListenerDecorator('start');
|
8
lib/decorators/listeners/text-link.decorator.ts
Normal file
8
lib/decorators/listeners/text-link.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_link entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextLink = createUpdateListenerDecorator('textLink');
|
8
lib/decorators/listeners/text-mention.decorator.ts
Normal file
8
lib/decorators/listeners/text-mention.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_mention entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextMention = createUpdateListenerDecorator('textMention');
|
8
lib/decorators/listeners/url.decorator.ts
Normal file
8
lib/decorators/listeners/url.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with url entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-url
|
||||
*/
|
||||
export const Url = createUpdateListenerDecorator('url');
|
8
lib/decorators/listeners/use.decorator.ts
Normal file
8
lib/decorators/listeners/use.decorator.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { createUpdateListenerDecorator } from '../../helpers';
|
||||
|
||||
/**
|
||||
* Registers a middleware.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=use
|
||||
*/
|
||||
export const Use = createUpdateListenerDecorator('use');
|
@@ -1,25 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafMentionUsername = string | string[];
|
||||
|
||||
export interface MentionOptions {
|
||||
username: TelegrafMentionUsername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Mention handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=mention
|
||||
*/
|
||||
export const Mention = (username: TelegrafMentionUsername): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.MENTION, { username });
|
||||
};
|
||||
|
||||
/**
|
||||
* Mention handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=mention
|
||||
* @deprecated since v2, use Mention decorator instead.
|
||||
*/
|
||||
export const TelegrafMention = Mention;
|
@@ -1,30 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers middleware for provided update type.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=on
|
||||
*/
|
||||
export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers middleware for provided update type.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=on
|
||||
* @deprecated since v2, use On decorator instead.
|
||||
*/
|
||||
export const TelegrafOn = On;
|
@@ -1,25 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
export type TelegrafPhonePhone = string | string[];
|
||||
|
||||
export interface PhoneOptions {
|
||||
phone: TelegrafPhonePhone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Phone number handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=phone
|
||||
*/
|
||||
export const Phone = (phone: TelegrafPhonePhone): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.PHONE, { phone });
|
||||
};
|
||||
|
||||
/**
|
||||
* Phone number handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=phone
|
||||
* @deprecated since v2, use Phone decorator instead.
|
||||
*/
|
||||
export const TelegrafPhone = Phone;
|
2
lib/decorators/scene/index.ts
Normal file
2
lib/decorators/scene/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './scene-enter.decorator';
|
||||
export * from './scene-leave.decorator';
|
3
lib/decorators/scene/scene-enter.decorator.ts
Normal file
3
lib/decorators/scene/scene-enter.decorator.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createSceneListenerDecorator } from '../../helpers';
|
||||
|
||||
export const SceneEnter = createSceneListenerDecorator('enter');
|
3
lib/decorators/scene/scene-leave.decorator.ts
Normal file
3
lib/decorators/scene/scene-leave.decorator.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { createSceneListenerDecorator } from '../../helpers';
|
||||
|
||||
export const SceneLeave = createSceneListenerDecorator('leave');
|
@@ -1,19 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
/**
|
||||
* Handler for /settings command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=settings
|
||||
*/
|
||||
export const Settings = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.SETTINGS, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for /settings command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=settings
|
||||
* @deprecated since v2, use Settings decorator instead.
|
||||
*/
|
||||
export const TelegrafSettings = Settings;
|
@@ -1,19 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
/**
|
||||
* Handler for /start command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=start
|
||||
*/
|
||||
export const Start = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.START, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Handler for /start command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=start
|
||||
* @deprecated since v2, use Start decorator instead.
|
||||
*/
|
||||
export const TelegrafStart = Start;
|
@@ -1,104 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
import * as tt from 'telegraf/typings/telegram-types';
|
||||
|
||||
export interface UpdateHookOptions {
|
||||
updateType:
|
||||
| tt.UpdateType
|
||||
| tt.UpdateType[]
|
||||
| tt.MessageSubTypes
|
||||
| tt.MessageSubTypes[];
|
||||
}
|
||||
|
||||
/**
|
||||
* New incoming message of any kind — text, photo, sticker, etc.
|
||||
* @constructor
|
||||
*/
|
||||
export const Message = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'message',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New version of a message that is known to the bot and was edited
|
||||
* @constructor
|
||||
*/
|
||||
export const EditedMessage = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'edited_message',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New incoming channel post of any kind — text, photo, sticker, etc.
|
||||
* @constructor
|
||||
*/
|
||||
export const ChannelPost = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'channel_post',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New version of a channel post that is known to the bot and was edited
|
||||
* @constructor
|
||||
*/
|
||||
export const EditedChannelPost = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'edited_channel_post',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New incoming inline query
|
||||
* See this decorator in inline-query.decorator.ts
|
||||
* @constructor
|
||||
*/
|
||||
// export const InlineQuery = (): MethodDecorator => {
|
||||
// return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
// updateType: 'inline_query',
|
||||
// });
|
||||
// };
|
||||
|
||||
/**
|
||||
* The result of an inline query that was chosen by a user and sent to their chat partner.
|
||||
* @constructor
|
||||
*/
|
||||
export const ChosenInlineResult = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'chosen_inline_result',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New incoming callback query
|
||||
* @constructor
|
||||
*/
|
||||
export const CallbackQuery = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'callback_query',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New incoming shipping query. Only for invoices with flexible price
|
||||
* @constructor
|
||||
*/
|
||||
export const ShippingQuery = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'shipping_query',
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* New incoming pre-checkout query. Contains full information about checkout
|
||||
* @constructor
|
||||
*/
|
||||
export const PreCheckoutQuery = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.UPDATE_HOOK, {
|
||||
updateType: 'pre_checkout_query',
|
||||
});
|
||||
};
|
||||
|
||||
// Two more decorators are missing here. For 'poll' and 'poll_answer' update types.
|
@@ -1,19 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { DECORATORS } from '../telegraf.constants';
|
||||
|
||||
/**
|
||||
* Registers a middleware.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=use
|
||||
*/
|
||||
export const Use = (): MethodDecorator => {
|
||||
return SetMetadata(DECORATORS.USE, {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Registers a middleware.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=use
|
||||
* @deprecated since v2, use Use decorator instead.
|
||||
*/
|
||||
export const TelegrafUse = Use;
|
Reference in New Issue
Block a user