-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: decorators refactoring
- Loading branch information
Showing
36 changed files
with
387 additions
and
273 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 './telegraf-use.decorator'; | ||
export * from './telegraf-on.decorator'; | ||
export * from './telegraf-hears.decorator'; | ||
export * from './telegraf-command.decorator'; | ||
export * from './telegraf-start.decorator'; | ||
export * from './telegraf-help.decorator'; | ||
export * from './telegraf-settings.decorator'; | ||
export * from './telegraf-entity.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'; | ||
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 './use.decorator'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.