feat(wip): rewrite explorer logic & update launch options & add miss decorators

This commit is contained in:
unknown
2020-12-25 23:11:16 +03:00
parent b394f5274b
commit 61c6c07482
17 changed files with 271 additions and 487 deletions

View File

@@ -0,0 +1,3 @@
export * from './on.decorator';
export * from './update.decorator';
export * from './use.decorator';

View File

@@ -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 './core/use.decorator';
export * from './core';
export * from './listeners';

View File

@@ -7,7 +7,7 @@ import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafCommand } from '../../telegraf.types';
export interface CommandOptions {
commands: TelegrafCommand;
command: TelegrafCommand;
}
/**
@@ -15,11 +15,11 @@ export interface CommandOptions {
*
* @see https://telegraf.js.org/#/?id=command
*/
export const Command = (commands: TelegrafCommand): MethodDecorator => {
export const Command = (command: TelegrafCommand): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Command),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
commands,
command: command,
} as CommandOptions),
);
};

View File

@@ -0,0 +1,25 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafEmail } from '../../telegraf.types';
export interface EmailOptions {
email: TelegrafEmail;
}
/**
* Registers middleware for handling messages with email entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-email
*/
export const Email = (email: TelegrafEmail): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Email),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
email,
} as EmailOptions),
);
};

View File

@@ -0,0 +1,16 @@
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

@@ -0,0 +1,25 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextLink } from '../../telegraf.types';
export interface TextLinkOptions {
link: TelegrafTextLink;
}
/**
* Registers middleware for handling messages with text_link entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
export const TetxLink = (link: TelegrafTextLink): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextLink),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
link,
} as TextLinkOptions),
);
};

View File

@@ -0,0 +1,25 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafTextMention } from '../../telegraf.types';
export interface TextMentionOptions {
mention: TelegrafTextMention;
}
/**
* Registers middleware for handling messages with text_mention entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-textlink
*/
export const TetxMention = (mention: TelegrafTextMention): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.TextMention),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
mention,
} as TextMentionOptions),
);
};

View File

@@ -0,0 +1,25 @@
import { applyDecorators, SetMetadata } from '@nestjs/common';
import {
TELEGRAF_LISTENER_OPTIONS,
TELEGRAF_LISTENER_TYPE,
} from '../../telegraf.constants';
import { ListenerType } from '../../enums/listener-type.enum';
import { TelegrafUrl } from '../../telegraf.types';
export interface UrlOptions {
url: TelegrafUrl;
}
/**
* Registers middleware for handling messages with url entity.
*
* @see https://telegraf.js.org/#/?id=telegraf-url
*/
export const Url = (url: TelegrafUrl): MethodDecorator => {
return applyDecorators(
SetMetadata(TELEGRAF_LISTENER_TYPE, ListenerType.Url),
SetMetadata(TELEGRAF_LISTENER_OPTIONS, {
url,
} as UrlOptions),
);
};

View File

@@ -1,70 +0,0 @@
import { On } from './core/on.decorator';
/**
* New incoming message of any kind — text, photo, sticker, etc.
* @constructor
*/
export const Message = (): MethodDecorator => On('message');
/**
* New version of a message that is known to the bot and was edited
* @constructor
*/
export const EditedMessage = (): MethodDecorator => On('edited_message');
/**
* New incoming channel post of any kind — text, photo, sticker, etc.
* @constructor
*/
export const ChannelPost = (): MethodDecorator => On('channel_post');
/**
* New version of a channel post that is known to the bot and was edited
* @constructor
*/
export const EditedChannelPost = (): MethodDecorator =>
On('edited_channel_post');
/**
* New incoming inline query
* See this decorator in inline-query.decorator.ts
* @constructor
*/
// export const InlineQuery = (): MethodDecorator => On('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 =>
On('chosen_inline_result');
/**
* New incoming callback query
* @constructor
*/
export const CallbackQuery = (): MethodDecorator => On('callback_query');
/**
* New incoming shipping query. Only for invoices with flexible price
* @constructor
*/
export const ShippingQuery = (): MethodDecorator => On('shipping_query');
/**
* New incoming pre-checkout query. Contains full information about checkout
* @constructor
*/
export const PreCheckoutQuery = (): MethodDecorator => On('pre_checkout_query');
/**
* New poll state. Bots receive only updates about stopped polls and polls, which are sent by the bot
* @constructor
*/
export const Poll = (): MethodDecorator => On('poll');
/**
* A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.
* @constructor
*/
export const PollAnswer = (): MethodDecorator => On('poll_answer');