mirror of
https://github.com/Maks1mS/nestjs-telegraf.git
synced 2025-09-30 04:18:51 +03:00
initial commit
This commit is contained in:
@@ -1,5 +0,0 @@
|
||||
export * from './update.decorator';
|
||||
export * from './scene.decorator';
|
||||
export * from './wizard.decorator';
|
||||
export * from './inject-bot.decorator';
|
||||
export * from './inject-all-bots.decorator';
|
@@ -1,9 +0,0 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { Telegraf } from 'telegraf';
|
||||
|
||||
import { getAllBotsToken } from '../../utils/get-all-bots-token.util';
|
||||
|
||||
export type AllBotsMap = Map<string, Telegraf<any>>;
|
||||
|
||||
export const InjectAllBots = (): ParameterDecorator =>
|
||||
Inject(getAllBotsToken());
|
@@ -1,5 +0,0 @@
|
||||
import { Inject } from '@nestjs/common';
|
||||
import { getBotToken } from '../../utils';
|
||||
|
||||
export const InjectBot = (botName?: string): ParameterDecorator =>
|
||||
Inject(getBotToken(botName));
|
@@ -1,14 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { SceneOptions } from 'telegraf/typings/scenes/base';
|
||||
import { SceneMetadata } from '../../interfaces';
|
||||
import { SCENE_METADATA } from '../../telegraf.constants';
|
||||
|
||||
export const Scene = (
|
||||
sceneId: string,
|
||||
options?: SceneOptions<any>,
|
||||
): ClassDecorator =>
|
||||
SetMetadata<string, SceneMetadata>(SCENE_METADATA, {
|
||||
sceneId,
|
||||
type: 'base',
|
||||
options,
|
||||
});
|
@@ -1,8 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
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(UPDATE_METADATA, true);
|
@@ -1,14 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { SceneOptions } from 'telegraf/typings/scenes/base';
|
||||
import { SceneMetadata } from '../../interfaces';
|
||||
import { SCENE_METADATA } from '../../telegraf.constants';
|
||||
|
||||
export const Wizard = (
|
||||
sceneId: string,
|
||||
options?: SceneOptions<any>,
|
||||
): ClassDecorator =>
|
||||
SetMetadata<string, SceneMetadata>(SCENE_METADATA, {
|
||||
sceneId,
|
||||
type: 'wizard',
|
||||
options,
|
||||
});
|
@@ -1,4 +0,0 @@
|
||||
export * from './core';
|
||||
export * from './listeners';
|
||||
export * from './scene';
|
||||
export * from './params';
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=action
|
||||
*/
|
||||
export const Action = createListenerDecorator('action');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Cashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=cashtag
|
||||
*/
|
||||
export const Cashtag = createListenerDecorator('cashtag');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Command handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=command
|
||||
*/
|
||||
export const Command = createListenerDecorator('command');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with email entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-email
|
||||
*/
|
||||
export const Email = createListenerDecorator('email');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling callback_data actions with game query.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const GameQuery = createListenerDecorator('gameQuery');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Hashtag handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hashtag
|
||||
*/
|
||||
export const Hashtag = createListenerDecorator('hashtag');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling text messages.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=hears
|
||||
*/
|
||||
export const Hears = createListenerDecorator('hears');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Handler for /help command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=help
|
||||
*/
|
||||
export const Help = createListenerDecorator('help');
|
@@ -1,18 +0,0 @@
|
||||
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';
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling inline_query actions with regular expressions.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=inlinequery
|
||||
*/
|
||||
export const InlineQuery = createListenerDecorator('inlineQuery');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Mention handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=mention
|
||||
*/
|
||||
export const Mention = createListenerDecorator('mention');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for provided update type.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=on
|
||||
*/
|
||||
export const On = createListenerDecorator('on');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Phone number handling.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=phone
|
||||
*/
|
||||
export const Phone = createListenerDecorator('phone');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Handler for /settings command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=settings
|
||||
*/
|
||||
export const Settings = createListenerDecorator('settings');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Handler for /start command.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=start
|
||||
*/
|
||||
export const Start = createListenerDecorator('start');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_link entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextLink = createListenerDecorator('textLink');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with text_mention entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-textlink
|
||||
*/
|
||||
export const TextMention = createListenerDecorator('textMention');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers middleware for handling messages with url entity.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=telegraf-url
|
||||
*/
|
||||
export const Url = createListenerDecorator('url');
|
@@ -1,8 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
|
||||
/**
|
||||
* Registers a middleware.
|
||||
*
|
||||
* @see https://telegraf.js.org/#/?id=use
|
||||
*/
|
||||
export const Use = createListenerDecorator('use');
|
@@ -1,8 +0,0 @@
|
||||
import { createTelegrafParamDecorator } from '../../utils/param-decorator.util';
|
||||
import { TelegrafParamtype } from '../../enums/telegraf-paramtype.enum';
|
||||
|
||||
export const Context: () => ParameterDecorator = createTelegrafParamDecorator(
|
||||
TelegrafParamtype.CONTEXT,
|
||||
);
|
||||
|
||||
export const Ctx = Context;
|
@@ -1,4 +0,0 @@
|
||||
export * from './context.decorator';
|
||||
export * from './next.decorator';
|
||||
export * from './message.decorator';
|
||||
export * from './sender.decorator';
|
@@ -1,21 +0,0 @@
|
||||
import { PipeTransform, Type } from '@nestjs/common';
|
||||
import { createTelegrafPipesParamDecorator } from '../../utils/param-decorator.util';
|
||||
import { TelegrafParamtype } from '../../enums/telegraf-paramtype.enum';
|
||||
|
||||
export function Message(): ParameterDecorator;
|
||||
export function Message(
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
export function Message(
|
||||
property: string,
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
export function Message(
|
||||
property?: string | (Type<PipeTransform> | PipeTransform),
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
) {
|
||||
return createTelegrafPipesParamDecorator(TelegrafParamtype.MESSAGE)(
|
||||
property,
|
||||
...pipes,
|
||||
);
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
import { createTelegrafParamDecorator } from '../../utils/param-decorator.util';
|
||||
import { TelegrafParamtype } from '../../enums/telegraf-paramtype.enum';
|
||||
|
||||
export const Next: () => ParameterDecorator = createTelegrafParamDecorator(
|
||||
TelegrafParamtype.NEXT,
|
||||
);
|
@@ -1,21 +0,0 @@
|
||||
import { PipeTransform, Type } from '@nestjs/common';
|
||||
import { createTelegrafPipesParamDecorator } from '../../utils/param-decorator.util';
|
||||
import { TelegrafParamtype } from '../../enums/telegraf-paramtype.enum';
|
||||
|
||||
export function Sender(): ParameterDecorator;
|
||||
export function Sender(
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
export function Sender(
|
||||
property: string,
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
): ParameterDecorator;
|
||||
export function Sender(
|
||||
property?: string | (Type<PipeTransform> | PipeTransform),
|
||||
...pipes: (Type<PipeTransform> | PipeTransform)[]
|
||||
) {
|
||||
return createTelegrafPipesParamDecorator(TelegrafParamtype.SENDER)(
|
||||
property,
|
||||
...pipes,
|
||||
);
|
||||
}
|
@@ -1,3 +0,0 @@
|
||||
export * from './scene-enter.decorator';
|
||||
export * from './scene-leave.decorator';
|
||||
export * from './wizard-step.decorator';
|
@@ -1,5 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
import { Scenes } from 'telegraf';
|
||||
|
||||
export const SceneEnter =
|
||||
createListenerDecorator<Scenes.BaseScene<never>>('enter');
|
@@ -1,5 +0,0 @@
|
||||
import { createListenerDecorator } from '../../utils';
|
||||
import { Scenes } from 'telegraf';
|
||||
|
||||
export const SceneLeave =
|
||||
createListenerDecorator<Scenes.BaseScene<never>>('leave');
|
@@ -1,6 +0,0 @@
|
||||
import { SetMetadata } from '@nestjs/common';
|
||||
import { WizardStepMetadata } from '../../interfaces';
|
||||
import { WIZARD_STEP_METADATA } from '../../telegraf.constants';
|
||||
|
||||
export const WizardStep = (step: number) =>
|
||||
SetMetadata<string, WizardStepMetadata>(WIZARD_STEP_METADATA, { step });
|
Reference in New Issue
Block a user