mirror of
				https://github.com/Maks1mS/nestjs-telegraf.git
				synced 2025-11-04 07:51:22 +03:00 
			
		
		
		
	
							
								
								
									
										16
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								README.md
									
									
									
									
									
								
							@@ -48,31 +48,31 @@ Now let's try to repeat the example from the Telegraf [documentation page](https
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { Injectable } from '@nestjs/common';
 | 
					import { Injectable } from '@nestjs/common';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  TelegrafStart,
 | 
					  Start,
 | 
				
			||||||
  TelegrafHelp,
 | 
					  Help,
 | 
				
			||||||
  TelegrafOn,
 | 
					  On,
 | 
				
			||||||
  TelegrafHears,
 | 
					  Hears,
 | 
				
			||||||
  Context,
 | 
					  Context,
 | 
				
			||||||
} from 'nestjs-telegraf';
 | 
					} from 'nestjs-telegraf';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Injectable()
 | 
					@Injectable()
 | 
				
			||||||
export class AppService {
 | 
					export class AppService {
 | 
				
			||||||
  @TelegrafStart()
 | 
					  @Start()
 | 
				
			||||||
  start(ctx: Context) {
 | 
					  start(ctx: Context) {
 | 
				
			||||||
    ctx.reply('Welcome');
 | 
					    ctx.reply('Welcome');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @TelegrafHelp()
 | 
					  @Help()
 | 
				
			||||||
  help(ctx: Context) {
 | 
					  help(ctx: Context) {
 | 
				
			||||||
    ctx.reply('Send me a sticker');
 | 
					    ctx.reply('Send me a sticker');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @TelegrafOn('sticker')
 | 
					  @On('sticker')
 | 
				
			||||||
  on(ctx: Context) {
 | 
					  on(ctx: Context) {
 | 
				
			||||||
    ctx.reply('👍');
 | 
					    ctx.reply('👍');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @TelegrafHears('hi')
 | 
					  @Hears('hi')
 | 
				
			||||||
  hears(ctx: Context) {
 | 
					  hears(ctx: Context) {
 | 
				
			||||||
    ctx.reply('Hey there');
 | 
					    ctx.reply('Hey there');
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,18 +5,23 @@ import { Context } from '../interfaces';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type TelegrafActionTriggers = HearsTriggers<Context>;
 | 
					export type TelegrafActionTriggers = HearsTriggers<Context>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface TelegrafActionMetadata {
 | 
					export interface ActionOptions {
 | 
				
			||||||
  triggers: TelegrafActionTriggers;
 | 
					  triggers: TelegrafActionTriggers;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Registers middleware for handling callback_data actions with regular expressions.
 | 
					 * Registers middleware for handling callback_data actions with regular expressions.
 | 
				
			||||||
 * @param triggers Triggers
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * https://telegraf.js.org/#/?id=action
 | 
					 * @see https://telegraf.js.org/#/?id=action
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function TelegrafAction(
 | 
					export const Action = (triggers: TelegrafActionTriggers): MethodDecorator => {
 | 
				
			||||||
  triggers: TelegrafActionTriggers,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.ACTION, { triggers });
 | 
					  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;
 | 
				
			||||||
							
								
								
									
										25
									
								
								lib/decorators/cashtag.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/decorators/cashtag.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										25
									
								
								lib/decorators/command.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/decorators/command.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										30
									
								
								lib/decorators/entity.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								lib/decorators/entity.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										19
									
								
								lib/decorators/game-query.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lib/decorators/game-query.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										25
									
								
								lib/decorators/hashtag.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/decorators/hashtag.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
@@ -5,18 +5,23 @@ import { Context } from '../interfaces';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type TelegrafHearsTriggers = HearsTriggers<Context>;
 | 
					export type TelegrafHearsTriggers = HearsTriggers<Context>;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface TelegrafHearsMetadata {
 | 
					export interface HearsOptions {
 | 
				
			||||||
  triggers: TelegrafHearsTriggers;
 | 
					  triggers: TelegrafHearsTriggers;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Registers middleware for handling text messages.
 | 
					 * Registers middleware for handling text messages.
 | 
				
			||||||
 * @param triggers Triggers
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * https://telegraf.js.org/#/?id=hears
 | 
					 * @see https://telegraf.js.org/#/?id=hears
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function TelegrafHears(
 | 
					export const Hears = (triggers: TelegrafHearsTriggers): MethodDecorator => {
 | 
				
			||||||
  triggers: TelegrafHearsTriggers,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.HEARS, { triggers: triggers });
 | 
					  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;
 | 
				
			||||||
							
								
								
									
										19
									
								
								lib/decorators/help.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lib/decorators/help.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					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,16 +1,17 @@
 | 
				
			|||||||
 | 
					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 './inject-bot.decorator';
 | 
				
			||||||
export * from './telegraf-use.decorator';
 | 
					export * from './inline-query.decorator';
 | 
				
			||||||
export * from './telegraf-on.decorator';
 | 
					export * from './mention.decorator';
 | 
				
			||||||
export * from './telegraf-hears.decorator';
 | 
					export * from './on.decorator';
 | 
				
			||||||
export * from './telegraf-command.decorator';
 | 
					export * from './phone.decorator';
 | 
				
			||||||
export * from './telegraf-start.decorator';
 | 
					export * from './settings.decorator';
 | 
				
			||||||
export * from './telegraf-help.decorator';
 | 
					export * from './start.decorator';
 | 
				
			||||||
export * from './telegraf-settings.decorator';
 | 
					export * from './update.decorator';
 | 
				
			||||||
export * from './telegraf-entity.decorator';
 | 
					export * from './use.decorator';
 | 
				
			||||||
export * from './telegraf-mention.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-phone.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-hashtag.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-cashtag.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-action.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-inline-query.decorator';
 | 
					 | 
				
			||||||
export * from './telegraf-game-query.decorator';
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,18 +3,25 @@ import { DECORATORS } from '../telegraf.constants';
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export type TelegrafInlineQueryTriggers = string | string[] | RegExp | RegExp[];
 | 
					export type TelegrafInlineQueryTriggers = string | string[] | RegExp | RegExp[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface TelegrafInlineQueryMetadata {
 | 
					export interface InlineQueryOptions {
 | 
				
			||||||
  triggers: TelegrafInlineQueryTriggers;
 | 
					  triggers: TelegrafInlineQueryTriggers;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Registers middleware for handling inline_query actions with regular expressions.
 | 
					 * Registers middleware for handling inline_query actions with regular expressions.
 | 
				
			||||||
 * @param triggers Triggers
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * https://telegraf.js.org/#/?id=inlinequery
 | 
					 * @see https://telegraf.js.org/#/?id=inlinequery
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function TelegrafInlineQuery(
 | 
					export const InlineQuery = (
 | 
				
			||||||
  triggers: TelegrafInlineQueryTriggers,
 | 
					  triggers: TelegrafInlineQueryTriggers,
 | 
				
			||||||
): MethodDecorator {
 | 
					): MethodDecorator => {
 | 
				
			||||||
  return SetMetadata(DECORATORS.INLINE_QUERY, { triggers });
 | 
					  return SetMetadata(DECORATORS.INLINE_QUERY, { triggers });
 | 
				
			||||||
}
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/**
 | 
				
			||||||
 | 
					 * 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;
 | 
				
			||||||
							
								
								
									
										25
									
								
								lib/decorators/mention.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/decorators/mention.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
@@ -8,18 +8,23 @@ export type TelegrafOnUpdateTypes =
 | 
				
			|||||||
  | MessageSubTypes
 | 
					  | MessageSubTypes
 | 
				
			||||||
  | MessageSubTypes[];
 | 
					  | MessageSubTypes[];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export interface TelegrafOnMetadata {
 | 
					export interface OnOptions {
 | 
				
			||||||
  updateTypes: TelegrafOnUpdateTypes;
 | 
					  updateTypes: TelegrafOnUpdateTypes;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * Registers middleware for provided update type.
 | 
					 * Registers middleware for provided update type.
 | 
				
			||||||
 * @param updateTypes Update type
 | 
					 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * https://telegraf.js.org/#/?id=on
 | 
					 * @see https://telegraf.js.org/#/?id=on
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export function TelegrafOn(
 | 
					export const On = (updateTypes: TelegrafOnUpdateTypes): MethodDecorator => {
 | 
				
			||||||
  updateTypes: TelegrafOnUpdateTypes,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.ON, { updateTypes: updateTypes });
 | 
					  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;
 | 
				
			||||||
							
								
								
									
										25
									
								
								lib/decorators/phone.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								lib/decorators/phone.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										19
									
								
								lib/decorators/settings.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lib/decorators/settings.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
							
								
								
									
										19
									
								
								lib/decorators/start.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lib/decorators/start.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					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,20 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafCashtagCashtag = string | string[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafCashtagMetadata {
 | 
					 | 
				
			||||||
  cashtag: TelegrafCashtagCashtag;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Cashtag handling.
 | 
					 | 
				
			||||||
 * @param cashtag Cashtag
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=cashtag
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafCashtag(
 | 
					 | 
				
			||||||
  cashtag: TelegrafCashtagCashtag,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.CASHTAG, { cashtag });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,20 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafCommandCommands = string | string[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafCommandMetadata {
 | 
					 | 
				
			||||||
  commands: TelegrafCommandCommands;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Command handling.
 | 
					 | 
				
			||||||
 * @param commands Commands
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=command
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafCommand(
 | 
					 | 
				
			||||||
  commands: TelegrafCommandCommands,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.COMMAND, { commands });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,23 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafEntityEntity =
 | 
					 | 
				
			||||||
  | string
 | 
					 | 
				
			||||||
  | string[]
 | 
					 | 
				
			||||||
  | RegExp
 | 
					 | 
				
			||||||
  | RegExp[]
 | 
					 | 
				
			||||||
  | Function;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafEntityMetadata {
 | 
					 | 
				
			||||||
  entity: TelegrafEntityEntity;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Entity handling.
 | 
					 | 
				
			||||||
 * @param entity Entity name
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=entity
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafEntity(entity: TelegrafEntityEntity): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.ENTITY, { entity });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Registers middleware for handling callback_data actions with game query.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=inlinequery
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafGameQuery(): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.GAME_QUERY, {});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,20 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafHashtagHashtag = string | string[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafHashtagMetadata {
 | 
					 | 
				
			||||||
  hashtag: TelegrafHashtagHashtag;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Hashtag handling.
 | 
					 | 
				
			||||||
 * @param hashtag Hashtag
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=hashtag
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafHashtag(
 | 
					 | 
				
			||||||
  hashtag: TelegrafHashtagHashtag,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.HASHTAG, { hashtag });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Handler for /help command.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=help
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafHelp(): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.HELP, {});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,20 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafMentionUsername = string | string[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafMentionMetadata {
 | 
					 | 
				
			||||||
  username: TelegrafMentionUsername;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Mention handling.
 | 
					 | 
				
			||||||
 * @param username Username
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=mention
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafMention(
 | 
					 | 
				
			||||||
  username: TelegrafMentionUsername,
 | 
					 | 
				
			||||||
): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.MENTION, { username });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,18 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export type TelegrafPhonePhone = string | string[];
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
export interface TelegrafPhoneMetadata {
 | 
					 | 
				
			||||||
  phone: TelegrafPhonePhone;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Phone number handling.
 | 
					 | 
				
			||||||
 * @param phone Phone number
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=phone
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafPhone(phone: TelegrafPhonePhone): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.PHONE, { phone });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Handler for /settings command.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=settings
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafSettings(): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.SETTINGS, {});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Handler for /start command.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=start
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafStart(): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.START, {});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@@ -1,11 +0,0 @@
 | 
				
			|||||||
import { SetMetadata } from '@nestjs/common';
 | 
					 | 
				
			||||||
import { DECORATORS } from '../telegraf.constants';
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/**
 | 
					 | 
				
			||||||
 * Registers a middleware.
 | 
					 | 
				
			||||||
 *
 | 
					 | 
				
			||||||
 * https://telegraf.js.org/#/?id=use
 | 
					 | 
				
			||||||
 */
 | 
					 | 
				
			||||||
export function TelegrafUse(): MethodDecorator {
 | 
					 | 
				
			||||||
  return SetMetadata(DECORATORS.USE, {});
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										8
									
								
								lib/decorators/update.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								lib/decorators/update.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -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, {});
 | 
				
			||||||
							
								
								
									
										19
									
								
								lib/decorators/use.decorator.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								lib/decorators/use.decorator.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
				
			|||||||
 | 
					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;
 | 
				
			||||||
@@ -4,6 +4,7 @@ export * as BaseScene from 'telegraf/scenes/base';
 | 
				
			|||||||
export * as session from 'telegraf/session';
 | 
					export * as session from 'telegraf/session';
 | 
				
			||||||
export * as Stage from 'telegraf/stage';
 | 
					export * as Stage from 'telegraf/stage';
 | 
				
			||||||
export * as WizardScene from 'telegraf/scenes/wizard';
 | 
					export * as WizardScene from 'telegraf/scenes/wizard';
 | 
				
			||||||
 | 
					export * as Extra from 'telegraf/extra';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export * from './decorators';
 | 
					export * from './decorators';
 | 
				
			||||||
export * from './interfaces';
 | 
					export * from './interfaces';
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,16 @@
 | 
				
			|||||||
import { Injectable, Type } from '@nestjs/common';
 | 
					import { Injectable, Type } from '@nestjs/common';
 | 
				
			||||||
import { Reflector } from '@nestjs/core';
 | 
					import { Reflector } from '@nestjs/core';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  TelegrafActionMetadata,
 | 
					  ActionOptions,
 | 
				
			||||||
  TelegrafCashtagMetadata,
 | 
					  CashtagOptions,
 | 
				
			||||||
  TelegrafCommandMetadata,
 | 
					  CommandOptions,
 | 
				
			||||||
  TelegrafEntityMetadata,
 | 
					  EntityOptions,
 | 
				
			||||||
  TelegrafHashtagMetadata,
 | 
					  HashtagOptions,
 | 
				
			||||||
  TelegrafHearsMetadata,
 | 
					  HearsOptions,
 | 
				
			||||||
  TelegrafInlineQueryMetadata,
 | 
					  InlineQueryOptions,
 | 
				
			||||||
  TelegrafMentionMetadata,
 | 
					  MentionOptions,
 | 
				
			||||||
  TelegrafOnMetadata,
 | 
					  OnOptions,
 | 
				
			||||||
  TelegrafPhoneMetadata,
 | 
					  PhoneOptions,
 | 
				
			||||||
  TelegrafStart,
 | 
					 | 
				
			||||||
} from './decorators';
 | 
					} from './decorators';
 | 
				
			||||||
import { DECORATORS } from './telegraf.constants';
 | 
					import { DECORATORS } from './telegraf.constants';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -33,9 +32,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
    return !!this.reflector.get(DECORATORS.ON, target);
 | 
					    return !!this.reflector.get(DECORATORS.ON, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getTelegrafOnMetadata(
 | 
					  getTelegrafOnMetadata(target: Type<any> | Function): OnOptions | undefined {
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					 | 
				
			||||||
  ): TelegrafOnMetadata | undefined {
 | 
					 | 
				
			||||||
    return this.reflector.get(DECORATORS.ON, target);
 | 
					    return this.reflector.get(DECORATORS.ON, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,7 +45,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafHearsMetadata(
 | 
					  getTelegrafHearsMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafHearsMetadata | undefined {
 | 
					  ): HearsOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.HEARS, target);
 | 
					    return this.reflector.get(DECORATORS.HEARS, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -61,7 +58,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafCommandMetadata(
 | 
					  getTelegrafCommandMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafCommandMetadata | undefined {
 | 
					  ): CommandOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.COMMAND, target);
 | 
					    return this.reflector.get(DECORATORS.COMMAND, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -95,7 +92,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafEntityMetadata(
 | 
					  getTelegrafEntityMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafEntityMetadata | undefined {
 | 
					  ): EntityOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.ENTITY, target);
 | 
					    return this.reflector.get(DECORATORS.ENTITY, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -108,7 +105,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafMentionMetadata(
 | 
					  getTelegrafMentionMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafMentionMetadata | undefined {
 | 
					  ): MentionOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.MENTION, target);
 | 
					    return this.reflector.get(DECORATORS.MENTION, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -121,7 +118,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafPhoneMetadata(
 | 
					  getTelegrafPhoneMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafPhoneMetadata | undefined {
 | 
					  ): PhoneOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.PHONE, target);
 | 
					    return this.reflector.get(DECORATORS.PHONE, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,7 +131,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafHashtagMetadata(
 | 
					  getTelegrafHashtagMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafHashtagMetadata | undefined {
 | 
					  ): HashtagOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.HASHTAG, target);
 | 
					    return this.reflector.get(DECORATORS.HASHTAG, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -147,7 +144,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafCashtagMetadata(
 | 
					  getTelegrafCashtagMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafCashtagMetadata | undefined {
 | 
					  ): CashtagOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.CASHTAG, target);
 | 
					    return this.reflector.get(DECORATORS.CASHTAG, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -160,7 +157,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafActionMetadata(
 | 
					  getTelegrafActionMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafActionMetadata | undefined {
 | 
					  ): ActionOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.ACTION, target);
 | 
					    return this.reflector.get(DECORATORS.ACTION, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -173,7 +170,7 @@ export class TelegrafMetadataAccessor {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  getTelegrafInlineQueryMetadata(
 | 
					  getTelegrafInlineQueryMetadata(
 | 
				
			||||||
    target: Type<any> | Function,
 | 
					    target: Type<any> | Function,
 | 
				
			||||||
  ): TelegrafInlineQueryMetadata | undefined {
 | 
					  ): InlineQueryOptions | undefined {
 | 
				
			||||||
    return this.reflector.get(DECORATORS.INLINE_QUERY, target);
 | 
					    return this.reflector.get(DECORATORS.INLINE_QUERY, target);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -18,4 +18,5 @@ export const DECORATORS = {
 | 
				
			|||||||
  ACTION: `${DECORATORS_PREFIX}/ACTION`,
 | 
					  ACTION: `${DECORATORS_PREFIX}/ACTION`,
 | 
				
			||||||
  INLINE_QUERY: `${DECORATORS_PREFIX}/INLINE_QUERY`,
 | 
					  INLINE_QUERY: `${DECORATORS_PREFIX}/INLINE_QUERY`,
 | 
				
			||||||
  GAME_QUERY: `${DECORATORS_PREFIX}/GAME_QUERY`,
 | 
					  GAME_QUERY: `${DECORATORS_PREFIX}/GAME_QUERY`,
 | 
				
			||||||
 | 
					  UPDATE: `${DECORATORS_PREFIX}/UPDATE`,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -6,16 +6,16 @@ import { TelegrafMetadataAccessor } from './telegraf-metadata.accessor';
 | 
				
			|||||||
import { TelegrafProvider } from './telegraf.provider';
 | 
					import { TelegrafProvider } from './telegraf.provider';
 | 
				
			||||||
import { TELEGRAF_PROVIDER } from './telegraf.constants';
 | 
					import { TELEGRAF_PROVIDER } from './telegraf.constants';
 | 
				
			||||||
import {
 | 
					import {
 | 
				
			||||||
  TelegrafActionMetadata,
 | 
					  ActionOptions,
 | 
				
			||||||
  TelegrafCashtagMetadata,
 | 
					  CashtagOptions,
 | 
				
			||||||
  TelegrafCommandMetadata,
 | 
					  CommandOptions,
 | 
				
			||||||
  TelegrafEntityMetadata,
 | 
					  EntityOptions,
 | 
				
			||||||
  TelegrafHashtagMetadata,
 | 
					  HashtagOptions,
 | 
				
			||||||
  TelegrafHearsMetadata,
 | 
					  HearsOptions,
 | 
				
			||||||
  TelegrafInlineQueryMetadata,
 | 
					  InlineQueryOptions,
 | 
				
			||||||
  TelegrafMentionMetadata,
 | 
					  MentionOptions,
 | 
				
			||||||
  TelegrafOnMetadata,
 | 
					  OnOptions,
 | 
				
			||||||
  TelegrafPhoneMetadata,
 | 
					  PhoneOptions,
 | 
				
			||||||
} from './decorators';
 | 
					} from './decorators';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Injectable()
 | 
					@Injectable()
 | 
				
			||||||
@@ -127,7 +127,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafOnMetadata,
 | 
					    metadata: OnOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    telegraf.on(metadata.updateTypes, instance[key].bind(instance));
 | 
					    telegraf.on(metadata.updateTypes, instance[key].bind(instance));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -136,7 +136,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafHearsMetadata,
 | 
					    metadata: HearsOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    telegraf.hears(metadata.triggers, instance[key].bind(instance));
 | 
					    telegraf.hears(metadata.triggers, instance[key].bind(instance));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -145,7 +145,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafCommandMetadata,
 | 
					    metadata: CommandOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    telegraf.command(metadata.commands, instance[key].bind(instance));
 | 
					    telegraf.command(metadata.commands, instance[key].bind(instance));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -179,7 +179,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafEntityMetadata,
 | 
					    metadata: EntityOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.entity(metadata.entity, instance[key].bind(instance));
 | 
					    telegraf.entity(metadata.entity, instance[key].bind(instance));
 | 
				
			||||||
@@ -189,7 +189,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafMentionMetadata,
 | 
					    metadata: MentionOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.mention(metadata.username, instance[key].bind(instance));
 | 
					    telegraf.mention(metadata.username, instance[key].bind(instance));
 | 
				
			||||||
@@ -199,7 +199,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafPhoneMetadata,
 | 
					    metadata: PhoneOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.phone(metadata.phone, instance[key].bind(instance));
 | 
					    telegraf.phone(metadata.phone, instance[key].bind(instance));
 | 
				
			||||||
@@ -209,7 +209,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafHashtagMetadata,
 | 
					    metadata: HashtagOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.hashtag(metadata.hashtag, instance[key].bind(instance));
 | 
					    telegraf.hashtag(metadata.hashtag, instance[key].bind(instance));
 | 
				
			||||||
@@ -219,7 +219,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafCashtagMetadata,
 | 
					    metadata: CashtagOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.cashtag(metadata.cashtag, instance[key].bind(instance));
 | 
					    telegraf.cashtag(metadata.cashtag, instance[key].bind(instance));
 | 
				
			||||||
@@ -229,7 +229,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafActionMetadata,
 | 
					    metadata: ActionOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    telegraf.action(metadata.triggers, instance[key].bind(instance));
 | 
					    telegraf.action(metadata.triggers, instance[key].bind(instance));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@@ -238,7 +238,7 @@ export class TelegrafExplorer implements OnModuleInit {
 | 
				
			|||||||
    instance: object,
 | 
					    instance: object,
 | 
				
			||||||
    key: string,
 | 
					    key: string,
 | 
				
			||||||
    telegraf: TelegrafProvider,
 | 
					    telegraf: TelegrafProvider,
 | 
				
			||||||
    metadata: TelegrafInlineQueryMetadata,
 | 
					    metadata: InlineQueryOptions,
 | 
				
			||||||
  ) {
 | 
					  ) {
 | 
				
			||||||
    // @ts-ignore
 | 
					    // @ts-ignore
 | 
				
			||||||
    telegraf.inlineQuery(metadata.triggers, instance[key].bind(instance));
 | 
					    telegraf.inlineQuery(metadata.triggers, instance[key].bind(instance));
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										11
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										11
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "nestjs-telegraf",
 | 
					  "name": "nestjs-telegraf",
 | 
				
			||||||
  "version": "1.2.1",
 | 
					  "version": "1.3.0",
 | 
				
			||||||
  "lockfileVersion": 1,
 | 
					  "lockfileVersion": 1,
 | 
				
			||||||
  "requires": true,
 | 
					  "requires": true,
 | 
				
			||||||
  "dependencies": {
 | 
					  "dependencies": {
 | 
				
			||||||
@@ -2397,6 +2397,15 @@
 | 
				
			|||||||
        "glob": "^7.1.3"
 | 
					        "glob": "^7.1.3"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    "rxjs": {
 | 
				
			||||||
 | 
					      "version": "6.6.2",
 | 
				
			||||||
 | 
					      "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.2.tgz",
 | 
				
			||||||
 | 
					      "integrity": "sha512-BHdBMVoWC2sL26w//BCu3YzKT4s2jip/WhwsGEDmeKYBhKDZeYezVUnHatYB7L85v5xs0BAQmg6BEYJEKxBabg==",
 | 
				
			||||||
 | 
					      "dev": true,
 | 
				
			||||||
 | 
					      "requires": {
 | 
				
			||||||
 | 
					        "tslib": "^1.9.0"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    "sandwich-stream": {
 | 
					    "sandwich-stream": {
 | 
				
			||||||
      "version": "2.0.2",
 | 
					      "version": "2.0.2",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/sandwich-stream/-/sandwich-stream-2.0.2.tgz",
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
  "name": "nestjs-telegraf",
 | 
					  "name": "nestjs-telegraf",
 | 
				
			||||||
  "version": "1.2.1",
 | 
					  "version": "1.3.0",
 | 
				
			||||||
  "description": "Telegraf module for NestJS",
 | 
					  "description": "Telegraf module for NestJS",
 | 
				
			||||||
  "keywords": [
 | 
					  "keywords": [
 | 
				
			||||||
    "nest",
 | 
					    "nest",
 | 
				
			||||||
@@ -47,6 +47,7 @@
 | 
				
			|||||||
    "lint-staged": "10.2.11",
 | 
					    "lint-staged": "10.2.11",
 | 
				
			||||||
    "prettier": "2.0.5",
 | 
					    "prettier": "2.0.5",
 | 
				
			||||||
    "reflect-metadata": "0.1.13",
 | 
					    "reflect-metadata": "0.1.13",
 | 
				
			||||||
 | 
					    "rxjs": "6.6.2",
 | 
				
			||||||
    "typescript": "3.9.7"
 | 
					    "typescript": "3.9.7"
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  "peerDependencies": {
 | 
					  "peerDependencies": {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,7 +3,7 @@
 | 
				
			|||||||
    "module": "commonjs",
 | 
					    "module": "commonjs",
 | 
				
			||||||
    "declaration": true,
 | 
					    "declaration": true,
 | 
				
			||||||
    "noImplicitAny": false,
 | 
					    "noImplicitAny": false,
 | 
				
			||||||
    "removeComments": true,
 | 
					    "removeComments": false,
 | 
				
			||||||
    "noLib": false,
 | 
					    "noLib": false,
 | 
				
			||||||
    "emitDecoratorMetadata": true,
 | 
					    "emitDecoratorMetadata": true,
 | 
				
			||||||
    "experimentalDecorators": true,
 | 
					    "experimentalDecorators": true,
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user