chz-telegram-bot 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +2 -1
- package/dist/types/messageTypes.d.ts +1 -0
- package/dist/types/messageTypes.d.ts.map +1 -1
- package/dist/types/messageTypes.js +1 -0
- package/entities/actions/commandAction.ts +2 -1
- package/package.json +1 -1
- package/types/messageTypes.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,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9
9
|
const toArray_1 = require("../../helpers/toArray");
|
|
10
10
|
const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResult");
|
|
11
11
|
const noop_1 = require("../../helpers/noop");
|
|
12
|
+
const messageTypes_1 = require("../../types/messageTypes");
|
|
12
13
|
class CommandAction {
|
|
13
14
|
constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor, readmeFactory) {
|
|
14
15
|
this.triggers = (0, toArray_1.toArray)(trigger);
|
|
@@ -64,7 +65,7 @@ class CommandAction {
|
|
|
64
65
|
return this.checkTrigger(ctx, trigger);
|
|
65
66
|
}
|
|
66
67
|
checkTrigger(ctx, trigger) {
|
|
67
|
-
if (trigger == ctx.messageType)
|
|
68
|
+
if (trigger == messageTypes_1.MessageType.Any || trigger == ctx.messageType)
|
|
68
69
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger;
|
|
69
70
|
if (typeof trigger == 'string')
|
|
70
71
|
return ctx.messageText.toLowerCase() == trigger.toLowerCase()
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Message, Update } from 'telegraf/types';
|
|
2
2
|
export declare const INTERNAL_MESSAGE_TYPE_PREFIX = "__msg:";
|
|
3
3
|
export declare const MessageType: {
|
|
4
|
+
readonly Any: "__msg:ANY";
|
|
4
5
|
readonly Text: "__msg:Text";
|
|
5
6
|
readonly Sticker: "__msg:Sticker";
|
|
6
7
|
readonly Animation: "__msg:Animation";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../types/messageTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../types/messageTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAed,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.MessageType = exports.INTERNAL_MESSAGE_TYPE_PREFIX = void 0;
|
|
4
4
|
exports.INTERNAL_MESSAGE_TYPE_PREFIX = `__msg:`;
|
|
5
5
|
exports.MessageType = {
|
|
6
|
+
Any: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}ANY`,
|
|
6
7
|
Text: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Text`,
|
|
7
8
|
Sticker: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Sticker`,
|
|
8
9
|
Animation: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Animation`,
|
|
@@ -10,6 +10,7 @@ import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult'
|
|
|
10
10
|
import { MessageContext } from '../context/messageContext';
|
|
11
11
|
import { CommandTrigger } from '../../types/commandTrigger';
|
|
12
12
|
import { Noop } from '../../helpers/noop';
|
|
13
|
+
import { MessageType } from '../../types/messageTypes';
|
|
13
14
|
|
|
14
15
|
export class CommandAction<TActionState extends IActionState>
|
|
15
16
|
implements IActionWithState<TActionState>
|
|
@@ -134,7 +135,7 @@ export class CommandAction<TActionState extends IActionState>
|
|
|
134
135
|
ctx: MessageContext<TActionState>,
|
|
135
136
|
trigger: CommandTrigger
|
|
136
137
|
) {
|
|
137
|
-
if (trigger == ctx.messageType)
|
|
138
|
+
if (trigger == MessageType.Any || trigger == ctx.messageType)
|
|
138
139
|
return CommandTriggerCheckResult.Trigger;
|
|
139
140
|
|
|
140
141
|
if (typeof trigger == 'string')
|
package/package.json
CHANGED
package/types/messageTypes.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { Message, Update } from 'telegraf/types';
|
|
|
3
3
|
export const INTERNAL_MESSAGE_TYPE_PREFIX = `__msg:`;
|
|
4
4
|
|
|
5
5
|
export const MessageType = {
|
|
6
|
+
Any: `${INTERNAL_MESSAGE_TYPE_PREFIX}ANY`,
|
|
6
7
|
Text: `${INTERNAL_MESSAGE_TYPE_PREFIX}Text`,
|
|
7
8
|
Sticker: `${INTERNAL_MESSAGE_TYPE_PREFIX}Sticker`,
|
|
8
9
|
Animation: `${INTERNAL_MESSAGE_TYPE_PREFIX}Animation`,
|