initial commit

This commit is contained in:
Alexander Bukhalo
2022-11-20 14:13:48 +03:00
parent 1bb274e8e2
commit 2d23eba148
94 changed files with 65 additions and 17013 deletions

View File

@@ -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';

View File

@@ -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());

View File

@@ -1,5 +0,0 @@
import { Inject } from '@nestjs/common';
import { getBotToken } from '../../utils';
export const InjectBot = (botName?: string): ParameterDecorator =>
Inject(getBotToken(botName));

View File

@@ -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,
});

View File

@@ -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);

View File

@@ -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,
});

View File

@@ -1,4 +0,0 @@
export * from './core';
export * from './listeners';
export * from './scene';
export * from './params';

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Cashtag handling.
*
* @see https://telegraf.js.org/#/?id=cashtag
*/
export const Cashtag = createListenerDecorator('cashtag');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Command handling.
*
* @see https://telegraf.js.org/#/?id=command
*/
export const Command = createListenerDecorator('command');

View File

@@ -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');

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Hashtag handling.
*
* @see https://telegraf.js.org/#/?id=hashtag
*/
export const Hashtag = createListenerDecorator('hashtag');

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Handler for /help command.
*
* @see https://telegraf.js.org/#/?id=help
*/
export const Help = createListenerDecorator('help');

View File

@@ -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';

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Mention handling.
*
* @see https://telegraf.js.org/#/?id=mention
*/
export const Mention = createListenerDecorator('mention');

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Phone number handling.
*
* @see https://telegraf.js.org/#/?id=phone
*/
export const Phone = createListenerDecorator('phone');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Handler for /settings command.
*
* @see https://telegraf.js.org/#/?id=settings
*/
export const Settings = createListenerDecorator('settings');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Handler for /start command.
*
* @see https://telegraf.js.org/#/?id=start
*/
export const Start = createListenerDecorator('start');

View File

@@ -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');

View File

@@ -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');

View File

@@ -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');

View File

@@ -1,8 +0,0 @@
import { createListenerDecorator } from '../../utils';
/**
* Registers a middleware.
*
* @see https://telegraf.js.org/#/?id=use
*/
export const Use = createListenerDecorator('use');

View File

@@ -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;

View File

@@ -1,4 +0,0 @@
export * from './context.decorator';
export * from './next.decorator';
export * from './message.decorator';
export * from './sender.decorator';

View File

@@ -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,
);
}

View File

@@ -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,
);

View File

@@ -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,
);
}

View File

@@ -1,3 +0,0 @@
export * from './scene-enter.decorator';
export * from './scene-leave.decorator';
export * from './wizard-step.decorator';

View File

@@ -1,5 +0,0 @@
import { createListenerDecorator } from '../../utils';
import { Scenes } from 'telegraf';
export const SceneEnter =
createListenerDecorator<Scenes.BaseScene<never>>('enter');

View File

@@ -1,5 +0,0 @@
import { createListenerDecorator } from '../../utils';
import { Scenes } from 'telegraf';
export const SceneLeave =
createListenerDecorator<Scenes.BaseScene<never>>('leave');

View File

@@ -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 });