chz-telegram-bot 0.3.9 → 0.3.11
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/builtin/helpAction.ts +1 -1
- package/dist/builtin/helpAction.js +1 -1
- package/dist/dtos/chatInfo.js +4 -0
- package/dist/dtos/commandTriggerCheckResult.js +3 -0
- package/dist/dtos/incomingMessage.js +9 -1
- package/dist/dtos/incomingQuery.js +5 -0
- package/dist/dtos/replyInfo.js +2 -0
- package/dist/dtos/responses/delay.js +6 -2
- package/dist/dtos/responses/imageMessage.js +10 -4
- package/dist/dtos/responses/inlineQueryResponse.js +6 -2
- package/dist/dtos/responses/reaction.js +7 -2
- package/dist/dtos/responses/textMessage.js +10 -3
- package/dist/dtos/responses/unpin.js +6 -2
- package/dist/dtos/responses/videoMessage.js +10 -4
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +14 -1
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
- package/dist/entities/actions/inlineQueryAction.js +8 -1
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.js +8 -1
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +13 -14
- package/dist/entities/botInstance.js +6 -1
- package/dist/entities/cachedStateFactory.js +2 -0
- package/dist/entities/context/baseContext.js +14 -2
- package/dist/entities/context/chatContext.d.ts +0 -3
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +38 -41
- package/dist/entities/context/inlineQueryContext.d.ts +0 -3
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.js +12 -6
- package/dist/entities/context/messageContext.d.ts +0 -3
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +77 -68
- package/dist/entities/context/replyContext.d.ts +0 -3
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +90 -65
- package/dist/entities/states/actionStateBase.js +2 -4
- package/dist/entities/taskRecord.js +3 -0
- package/dist/helpers/builders/commandActionBuilder.js +10 -8
- package/dist/helpers/builders/inlineQueryActionBuilder.js +7 -6
- package/dist/helpers/builders/scheduledActionBuilder.js +7 -5
- package/dist/helpers/mapUtils.d.ts +3 -0
- package/dist/helpers/mapUtils.d.ts.map +1 -0
- package/dist/helpers/mapUtils.js +17 -0
- package/dist/helpers/noop.d.ts +3 -4
- package/dist/helpers/noop.d.ts.map +1 -1
- package/dist/helpers/noop.js +2 -1
- package/dist/helpers/traceFactory.d.ts +1 -1
- package/dist/helpers/traceFactory.d.ts.map +1 -1
- package/dist/main.js +1 -3
- package/dist/services/actionProcessingService.d.ts.map +1 -1
- package/dist/services/actionProcessingService.js +15 -3
- package/dist/services/actionProcessors/baseProcessor.d.ts +1 -3
- package/dist/services/actionProcessors/baseProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/baseProcessor.js +6 -2
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +0 -4
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +11 -14
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +0 -4
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +5 -7
- package/dist/services/actionProcessors/scheduledActionProcessor.js +7 -5
- package/dist/services/jsonFileStorage.d.ts +4 -3
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/jsonFileStorage.js +22 -14
- package/dist/services/jsonLogger.d.ts +1 -1
- package/dist/services/jsonLogger.d.ts.map +1 -1
- package/dist/services/jsonLogger.js +9 -3
- package/dist/services/nodeTimeoutScheduler.d.ts +2 -2
- package/dist/services/nodeTimeoutScheduler.d.ts.map +1 -1
- package/dist/services/nodeTimeoutScheduler.js +6 -5
- package/dist/services/responseProcessingQueue.d.ts +1 -0
- package/dist/services/responseProcessingQueue.d.ts.map +1 -1
- package/dist/services/responseProcessingQueue.js +11 -10
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +17 -8
- package/dist/types/commandTrigger.d.ts +1 -2
- package/dist/types/commandTrigger.d.ts.map +1 -1
- package/dist/types/handlers.d.ts +1 -1
- package/dist/types/handlers.d.ts.map +1 -1
- package/dist/types/logger.d.ts +2 -2
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/scheduler.d.ts +2 -2
- package/dist/types/scheduler.d.ts.map +1 -1
- package/dist/types/storage.d.ts +2 -2
- package/dist/types/storage.d.ts.map +1 -1
- package/dist/types/timeValues.d.ts +3 -3
- package/dist/types/timeValues.d.ts.map +1 -1
- package/dist/types/trace.d.ts +1 -1
- package/dist/types/trace.d.ts.map +1 -1
- package/dtos/incomingMessage.ts +1 -1
- package/entities/actions/commandAction.ts +5 -1
- package/entities/actions/inlineQueryAction.ts +5 -1
- package/entities/actions/replyCaptureAction.ts +5 -1
- package/entities/actions/scheduledAction.ts +11 -13
- package/entities/botInstance.ts +7 -7
- package/entities/context/chatContext.ts +0 -6
- package/entities/context/inlineQueryContext.ts +0 -6
- package/entities/context/messageContext.ts +0 -6
- package/entities/context/replyContext.ts +18 -15
- package/eslint.config.js +26 -1
- package/helpers/mapUtils.ts +15 -0
- package/helpers/noop.ts +4 -4
- package/helpers/traceFactory.ts +2 -2
- package/package.json +1 -1
- package/services/actionProcessingService.ts +8 -4
- package/services/actionProcessors/baseProcessor.ts +5 -8
- package/services/actionProcessors/commandActionProcessor.ts +6 -18
- package/services/actionProcessors/inlineQueryActionProcessor.ts +6 -16
- package/services/actionProcessors/scheduledActionProcessor.ts +5 -5
- package/services/jsonFileStorage.ts +39 -21
- package/services/jsonLogger.ts +12 -8
- package/services/nodeTimeoutScheduler.ts +6 -6
- package/services/responseProcessingQueue.ts +13 -7
- package/services/telegramApi.ts +7 -5
- package/tsconfig.json +1 -1
- package/types/commandTrigger.ts +1 -3
- package/types/handlers.ts +1 -1
- package/types/logger.ts +3 -6
- package/types/scheduler.ts +2 -2
- package/types/storage.ts +2 -2
- package/types/timeValues.ts +3 -3
- package/types/trace.ts +3 -1
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { TelegramEmoji } from 'telegraf/types';
|
|
2
|
-
import { IStorageClient } from '../../types/storage';
|
|
3
2
|
import { IActionState } from '../../types/actionState';
|
|
4
3
|
import { ChatContext } from './chatContext';
|
|
5
4
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
5
|
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
7
|
-
import { IScheduler } from '../../types/scheduler';
|
|
8
6
|
import { CommandAction } from '../actions/commandAction';
|
|
9
7
|
/**
|
|
10
8
|
* Context of action executed in chat, in response to a message
|
|
@@ -26,7 +24,6 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
26
24
|
messageType: MessageTypeValue;
|
|
27
25
|
/** Message object recieved from Telegram */
|
|
28
26
|
messageUpdateObject: TelegrafContextMessage;
|
|
29
|
-
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
30
27
|
private getQuotePart;
|
|
31
28
|
private replyWithText;
|
|
32
29
|
private replyWithImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEzD;;GAEG;AACH,qBAAa,cAAc,CACvB,YAAY,SAAS,YAAY,CACnC,SAAQ,WAAW,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IAC5D,kDAAkD;IAClD,SAAS,EAAG,MAAM,CAAC;IACnB,oDAAoD;IACpD,WAAW,EAAG,MAAM,CAAC;IACrB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,qEAAqE;IACrE,YAAY,EAAG,MAAM,CAAC;IACtB,qCAAqC;IACrC,WAAW,EAAG,gBAAgB,CAAC;IAC/B,4CAA4C;IAC5C,mBAAmB,EAAG,sBAAsB,CAAC;IAE7C,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAGnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAIvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -12,74 +12,22 @@ const replyInfo_1 = require("../../dtos/replyInfo");
|
|
|
12
12
|
* Context of action executed in chat, in response to a message
|
|
13
13
|
*/
|
|
14
14
|
class MessageContext extends chatContext_1.ChatContext {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* Reply with text message to message that triggered this action after action execution is finished.
|
|
32
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
33
|
-
* @param text Message contents.
|
|
34
|
-
* @param options Message sending option.
|
|
35
|
-
*/
|
|
36
|
-
withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
|
|
37
|
-
/**
|
|
38
|
-
* Reply with image message to message that triggered this action after action execution is finished.
|
|
39
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
40
|
-
* @param text Message contents.
|
|
41
|
-
* @param options Message sending option.
|
|
42
|
-
*/
|
|
43
|
-
withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
|
|
44
|
-
/**
|
|
45
|
-
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
46
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
47
|
-
* @param text Message contents.
|
|
48
|
-
* @param options Message sending option.
|
|
49
|
-
*/
|
|
50
|
-
withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
|
|
51
|
-
},
|
|
52
|
-
/**
|
|
53
|
-
* Reply with text message to message that triggered this action after action execution is finished.
|
|
54
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
55
|
-
* @param text Message contents.
|
|
56
|
-
* @param options Message sending option.
|
|
57
|
-
*/
|
|
58
|
-
withText: (text, options) => this.replyWithText(text, false, options),
|
|
59
|
-
/**
|
|
60
|
-
* Reply with image message to message that triggered this action after action execution is finished.
|
|
61
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
62
|
-
* @param text Message contents.
|
|
63
|
-
* @param options Message sending option.
|
|
64
|
-
*/
|
|
65
|
-
withImage: (name, options) => this.replyWithImage(name, false, options),
|
|
66
|
-
/**
|
|
67
|
-
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
68
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
69
|
-
* @param text Message contents.
|
|
70
|
-
* @param options Message sending option.
|
|
71
|
-
*/
|
|
72
|
-
withVideo: (name, options) => this.replyWithVideo(name, false, options),
|
|
73
|
-
/**
|
|
74
|
-
* React to the message that triggered this action after action execution is finished.
|
|
75
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
76
|
-
* @param emoji Telegram emoji to react with.
|
|
77
|
-
*/
|
|
78
|
-
withReaction: (emoji) => {
|
|
79
|
-
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
15
|
+
/** Id of a message that triggered this action. */
|
|
16
|
+
messageId;
|
|
17
|
+
/** Text of a message that triggered this action. */
|
|
18
|
+
messageText;
|
|
19
|
+
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
20
|
+
matchResults = [];
|
|
21
|
+
/** Id of a user that sent a message that triggered this action. */
|
|
22
|
+
fromUserId;
|
|
23
|
+
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
24
|
+
startCooldown = true;
|
|
25
|
+
/** Name of a user that sent a message that triggered this action. */
|
|
26
|
+
fromUserName;
|
|
27
|
+
/** Type of message being received */
|
|
28
|
+
messageType;
|
|
29
|
+
/** Message object recieved from Telegram */
|
|
30
|
+
messageUpdateObject;
|
|
83
31
|
getQuotePart(quote) {
|
|
84
32
|
return typeof quote == 'boolean'
|
|
85
33
|
? this.matchResults.length != 0
|
|
@@ -105,5 +53,66 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
105
53
|
this.responses.push(response);
|
|
106
54
|
return this.createCaptureController(response);
|
|
107
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
58
|
+
*/
|
|
59
|
+
reply = {
|
|
60
|
+
/**
|
|
61
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
62
|
+
* If regex is matched, first match will be quoted
|
|
63
|
+
*/
|
|
64
|
+
andQuote: {
|
|
65
|
+
/**
|
|
66
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
67
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
68
|
+
* @param text Message contents.
|
|
69
|
+
* @param options Message sending option.
|
|
70
|
+
*/
|
|
71
|
+
withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
|
|
72
|
+
/**
|
|
73
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
74
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
75
|
+
* @param text Message contents.
|
|
76
|
+
* @param options Message sending option.
|
|
77
|
+
*/
|
|
78
|
+
withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
|
|
79
|
+
/**
|
|
80
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
81
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
82
|
+
* @param text Message contents.
|
|
83
|
+
* @param options Message sending option.
|
|
84
|
+
*/
|
|
85
|
+
withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
|
|
86
|
+
},
|
|
87
|
+
/**
|
|
88
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
89
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
90
|
+
* @param text Message contents.
|
|
91
|
+
* @param options Message sending option.
|
|
92
|
+
*/
|
|
93
|
+
withText: (text, options) => this.replyWithText(text, false, options),
|
|
94
|
+
/**
|
|
95
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
96
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
97
|
+
* @param text Message contents.
|
|
98
|
+
* @param options Message sending option.
|
|
99
|
+
*/
|
|
100
|
+
withImage: (name, options) => this.replyWithImage(name, false, options),
|
|
101
|
+
/**
|
|
102
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
103
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
104
|
+
* @param text Message contents.
|
|
105
|
+
* @param options Message sending option.
|
|
106
|
+
*/
|
|
107
|
+
withVideo: (name, options) => this.replyWithVideo(name, false, options),
|
|
108
|
+
/**
|
|
109
|
+
* React to the message that triggered this action after action execution is finished.
|
|
110
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
111
|
+
* @param emoji Telegram emoji to react with.
|
|
112
|
+
*/
|
|
113
|
+
withReaction: (emoji) => {
|
|
114
|
+
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
115
|
+
}
|
|
116
|
+
};
|
|
108
117
|
}
|
|
109
118
|
exports.MessageContext = MessageContext;
|
|
@@ -2,8 +2,6 @@ import { TelegramEmoji } from 'telegraf/types';
|
|
|
2
2
|
import { IActionState } from '../../types/actionState';
|
|
3
3
|
import { TextMessageSendingOptions, MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
4
|
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
5
|
-
import { IScheduler } from '../../types/scheduler';
|
|
6
|
-
import { IStorageClient } from '../../types/storage';
|
|
7
5
|
import { ReplyCaptureAction } from '../actions/replyCaptureAction';
|
|
8
6
|
import { BaseContext } from './baseContext';
|
|
9
7
|
export declare class ReplyContext<TParentActionState extends IActionState> extends BaseContext<ReplyCaptureAction<TParentActionState>> {
|
|
@@ -24,7 +22,6 @@ export declare class ReplyContext<TParentActionState extends IActionState> exten
|
|
|
24
22
|
/** Message object recieved from Telegram */
|
|
25
23
|
messageUpdateObject: TelegrafContextMessage;
|
|
26
24
|
isInitialized: boolean;
|
|
27
|
-
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
28
25
|
private getQuotePart;
|
|
29
26
|
private replyWithText;
|
|
30
27
|
private replyWithImage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,YAAY,CACrB,kBAAkB,SAAS,YAAY,CACzC,SAAQ,WAAW,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACzD,4HAA4H;IAC5H,YAAY,EAAG,eAAe,EAAE,CAAC;IACjC,kDAAkD;IAClD,cAAc,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,kDAAkD;IAClD,SAAS,EAAG,MAAM,CAAC;IACnB,qCAAqC;IACrC,WAAW,EAAG,gBAAgB,CAAC;IAC/B,oDAAoD;IACpD,WAAW,EAAG,MAAM,CAAC;IACrB,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,qEAAqE;IACrE,YAAY,EAAG,MAAM,CAAC;IACtB,4CAA4C;IAC5C,mBAAmB,EAAG,sBAAsB,CAAC;IAE7C,aAAa,UAAS;IAEtB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,WAAW;IAIX;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAIvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAKnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAMvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAG5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -9,71 +9,23 @@ const videoMessage_1 = require("../../dtos/responses/videoMessage");
|
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
const baseContext_1 = require("./baseContext");
|
|
11
11
|
class ReplyContext extends baseContext_1.BaseContext {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
|
|
31
|
-
/**
|
|
32
|
-
* Reply with image message to message that triggered this action after action execution is finished.
|
|
33
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
34
|
-
* @param text Message contents.
|
|
35
|
-
* @param options Message sending option.
|
|
36
|
-
*/
|
|
37
|
-
withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
|
|
38
|
-
/**
|
|
39
|
-
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
40
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
41
|
-
* @param text Message contents.
|
|
42
|
-
* @param options Message sending option.
|
|
43
|
-
*/
|
|
44
|
-
withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
|
|
45
|
-
},
|
|
46
|
-
/**
|
|
47
|
-
* Reply with text message to message that triggered this action after action execution is finished.
|
|
48
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
49
|
-
* @param text Message contents.
|
|
50
|
-
* @param options Message sending option.
|
|
51
|
-
*/
|
|
52
|
-
withText: (text, options) => this.replyWithText(text, false, options),
|
|
53
|
-
/**
|
|
54
|
-
* Reply with image message to message that triggered this action after action execution is finished.
|
|
55
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
56
|
-
* @param text Message contents.
|
|
57
|
-
* @param options Message sending option.
|
|
58
|
-
*/
|
|
59
|
-
withImage: (name, options) => this.replyWithImage(name, false, options),
|
|
60
|
-
/**
|
|
61
|
-
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
62
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
63
|
-
* @param text Message contents.
|
|
64
|
-
* @param options Message sending option.
|
|
65
|
-
*/
|
|
66
|
-
withVideo: (name, options) => this.replyWithVideo(name, false, options),
|
|
67
|
-
/**
|
|
68
|
-
* React to the message that triggered this action after action execution is finished.
|
|
69
|
-
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
70
|
-
* @param emoji Telegram emoji to react with.
|
|
71
|
-
*/
|
|
72
|
-
withReaction: (emoji) => {
|
|
73
|
-
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
}
|
|
12
|
+
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
13
|
+
matchResults;
|
|
14
|
+
/** Id of a message that triggered this action. */
|
|
15
|
+
replyMessageId;
|
|
16
|
+
/** Id of a message that triggered this action. */
|
|
17
|
+
messageId;
|
|
18
|
+
/** Type of message being received */
|
|
19
|
+
messageType;
|
|
20
|
+
/** Text of a message that triggered this action. */
|
|
21
|
+
messageText;
|
|
22
|
+
/** Id of a user that sent a message that triggered this action. */
|
|
23
|
+
fromUserId;
|
|
24
|
+
/** Name of a user that sent a message that triggered this action. */
|
|
25
|
+
fromUserName;
|
|
26
|
+
/** Message object recieved from Telegram */
|
|
27
|
+
messageUpdateObject;
|
|
28
|
+
isInitialized = false;
|
|
77
29
|
getQuotePart(quote) {
|
|
78
30
|
return typeof quote == 'boolean'
|
|
79
31
|
? this.matchResults.length != 0
|
|
@@ -102,5 +54,78 @@ class ReplyContext extends baseContext_1.BaseContext {
|
|
|
102
54
|
stopCapture() {
|
|
103
55
|
this.action.abortController.abort();
|
|
104
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
59
|
+
*/
|
|
60
|
+
reply = {
|
|
61
|
+
/**
|
|
62
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
63
|
+
* If regex is matched, first match will be quoted
|
|
64
|
+
*/
|
|
65
|
+
andQuote: {
|
|
66
|
+
/**
|
|
67
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
68
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
69
|
+
* @param text Message contents.
|
|
70
|
+
* @param options Message sending option.
|
|
71
|
+
*/
|
|
72
|
+
withText: (text, quote, options) => {
|
|
73
|
+
this.replyWithText(text, quote ?? true, options);
|
|
74
|
+
},
|
|
75
|
+
/**
|
|
76
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
77
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
78
|
+
* @param text Message contents.
|
|
79
|
+
* @param options Message sending option.
|
|
80
|
+
*/
|
|
81
|
+
withImage: (name, quote, options) => {
|
|
82
|
+
this.replyWithImage(name, quote ?? true, options);
|
|
83
|
+
},
|
|
84
|
+
/**
|
|
85
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
86
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
87
|
+
* @param text Message contents.
|
|
88
|
+
* @param options Message sending option.
|
|
89
|
+
*/
|
|
90
|
+
withVideo: (name, quote, options) => {
|
|
91
|
+
this.replyWithVideo(name, quote ?? true, options);
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
/**
|
|
95
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
96
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
97
|
+
* @param text Message contents.
|
|
98
|
+
* @param options Message sending option.
|
|
99
|
+
*/
|
|
100
|
+
withText: (text, options) => {
|
|
101
|
+
this.replyWithText(text, false, options);
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
105
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
106
|
+
* @param text Message contents.
|
|
107
|
+
* @param options Message sending option.
|
|
108
|
+
*/
|
|
109
|
+
withImage: (name, options) => {
|
|
110
|
+
this.replyWithImage(name, false, options);
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
114
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
115
|
+
* @param text Message contents.
|
|
116
|
+
* @param options Message sending option.
|
|
117
|
+
*/
|
|
118
|
+
withVideo: (name, options) => {
|
|
119
|
+
this.replyWithVideo(name, false, options);
|
|
120
|
+
},
|
|
121
|
+
/**
|
|
122
|
+
* React to the message that triggered this action after action execution is finished.
|
|
123
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
124
|
+
* @param emoji Telegram emoji to react with.
|
|
125
|
+
*/
|
|
126
|
+
withReaction: (emoji) => {
|
|
127
|
+
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
105
130
|
}
|
|
106
131
|
exports.ReplyContext = ReplyContext;
|
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ActionStateBase = void 0;
|
|
4
4
|
class ActionStateBase {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.lastExecutedDate = 0;
|
|
8
|
-
}
|
|
5
|
+
pinnedMessages = [];
|
|
6
|
+
lastExecutedDate = 0;
|
|
9
7
|
}
|
|
10
8
|
exports.ActionStateBase = ActionStateBase;
|
|
@@ -9,20 +9,22 @@ const noop_1 = require("../noop");
|
|
|
9
9
|
* Builder for `CommandAction` with state represented by `TActionState`
|
|
10
10
|
*/
|
|
11
11
|
class CommandActionBuilderWithState {
|
|
12
|
+
name;
|
|
13
|
+
trigger = [];
|
|
14
|
+
active = true;
|
|
15
|
+
readmeFactory = null;
|
|
16
|
+
cooldownSeconds = 0;
|
|
17
|
+
blacklist = [];
|
|
18
|
+
allowedUsers = [];
|
|
19
|
+
stateConstructor;
|
|
20
|
+
handler = noop_1.Noop.call;
|
|
21
|
+
condition = noop_1.Noop.true;
|
|
12
22
|
/**
|
|
13
23
|
* Builder for `CommandAction` with state represented by `TActionState`
|
|
14
24
|
* @param name Action name, will be used for logging and storage
|
|
15
25
|
* @param stateConstructor Function that creates default state object
|
|
16
26
|
*/
|
|
17
27
|
constructor(name, stateConstructor) {
|
|
18
|
-
this.trigger = [];
|
|
19
|
-
this.active = true;
|
|
20
|
-
this.readmeFactory = null;
|
|
21
|
-
this.cooldownSeconds = 0;
|
|
22
|
-
this.blacklist = [];
|
|
23
|
-
this.allowedUsers = [];
|
|
24
|
-
this.handler = noop_1.Noop.call;
|
|
25
|
-
this.condition = noop_1.Noop.true;
|
|
26
28
|
this.name = name;
|
|
27
29
|
this.stateConstructor = stateConstructor;
|
|
28
30
|
}
|
|
@@ -7,17 +7,18 @@ const inlineQueryAction_1 = require("../../entities/actions/inlineQueryAction");
|
|
|
7
7
|
* Builder for `InlineQueryAction`
|
|
8
8
|
*/
|
|
9
9
|
class InlineQueryActionBuilder {
|
|
10
|
+
name;
|
|
11
|
+
pattern = /.+/gi;
|
|
12
|
+
active = true;
|
|
13
|
+
cooldownSeconds = 0;
|
|
14
|
+
blacklist = [];
|
|
15
|
+
allowedUsers = [];
|
|
16
|
+
handler = noop_1.Noop.call;
|
|
10
17
|
/**
|
|
11
18
|
* Builder for `InlineQueryAction`
|
|
12
19
|
* @param name Action name, will be used for logging and storage
|
|
13
20
|
*/
|
|
14
21
|
constructor(name) {
|
|
15
|
-
this.pattern = /.+/gi;
|
|
16
|
-
this.active = true;
|
|
17
|
-
this.cooldownSeconds = 0;
|
|
18
|
-
this.blacklist = [];
|
|
19
|
-
this.allowedUsers = [];
|
|
20
|
-
this.handler = noop_1.Noop.call;
|
|
21
22
|
this.name = name;
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
@@ -9,17 +9,19 @@ const noop_1 = require("../noop");
|
|
|
9
9
|
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
10
10
|
*/
|
|
11
11
|
class ScheduledActionBuilderWithState {
|
|
12
|
+
active = true;
|
|
13
|
+
time = 0;
|
|
14
|
+
cachedStateFactories = new Map();
|
|
15
|
+
whitelist = [];
|
|
16
|
+
stateConstructor;
|
|
17
|
+
handler = noop_1.Noop.call;
|
|
18
|
+
name;
|
|
12
19
|
/**
|
|
13
20
|
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
14
21
|
* @param name Action name, will be used for logging and storage
|
|
15
22
|
* @param stateConstructor Function that creates default state object
|
|
16
23
|
*/
|
|
17
24
|
constructor(name, stateConstructor) {
|
|
18
|
-
this.active = true;
|
|
19
|
-
this.time = 0;
|
|
20
|
-
this.cachedStateFactories = new Map();
|
|
21
|
-
this.whitelist = [];
|
|
22
|
-
this.handler = noop_1.Noop.call;
|
|
23
25
|
this.name = name;
|
|
24
26
|
this.stateConstructor = stateConstructor;
|
|
25
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapUtils.d.ts","sourceRoot":"","sources":["../../helpers/mapUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,KAO5E;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,kBAKrE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOrSetIfNotExists = getOrSetIfNotExists;
|
|
4
|
+
exports.getOrThrow = getOrThrow;
|
|
5
|
+
function getOrSetIfNotExists(map, key, fallback) {
|
|
6
|
+
const existingValue = map.get(key);
|
|
7
|
+
if (existingValue)
|
|
8
|
+
return existingValue;
|
|
9
|
+
map.set(key, fallback);
|
|
10
|
+
return fallback;
|
|
11
|
+
}
|
|
12
|
+
function getOrThrow(map, key, error) {
|
|
13
|
+
const existingValue = map.get(key);
|
|
14
|
+
if (existingValue)
|
|
15
|
+
return existingValue;
|
|
16
|
+
throw new Error(error);
|
|
17
|
+
}
|
package/dist/helpers/noop.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { BotResponse } from '../types/response';
|
|
2
2
|
export declare class Noop {
|
|
3
3
|
static NoResponse: BotResponse[];
|
|
4
|
-
static true
|
|
5
|
-
static false
|
|
6
|
-
static call
|
|
7
|
-
static call<T1, T2>(arg1: T1, arg2: T2): Promise<void>;
|
|
4
|
+
static true(arg1: unknown): boolean;
|
|
5
|
+
static false(arg1: unknown): boolean;
|
|
6
|
+
static call(arg1: unknown): Promise<void>;
|
|
8
7
|
}
|
|
9
8
|
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD,qBAAa,IAAI;IACb,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IACtC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO;IAGzB,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,OAAO;WAIb,IAAI,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAElD"}
|
package/dist/helpers/noop.js
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Noop = void 0;
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
5
6
|
class Noop {
|
|
7
|
+
static NoResponse = [];
|
|
6
8
|
static true(arg1) {
|
|
7
9
|
return true;
|
|
8
10
|
}
|
|
@@ -12,4 +14,3 @@ class Noop {
|
|
|
12
14
|
static async call(arg1, arg2) { }
|
|
13
15
|
}
|
|
14
16
|
exports.Noop = Noop;
|
|
15
|
-
Noop.NoResponse = [];
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TraceId } from '../types/trace';
|
|
2
|
-
export declare function createTrace
|
|
2
|
+
export declare function createTrace(traceOwner: object | string, botName: string, traceName: string): TraceId;
|
|
3
3
|
//# sourceMappingURL=traceFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,
|
|
1
|
+
{"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CACvB,UAAU,EAAE,MAAM,GAAG,MAAM,EAC3B,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAIa,OAAO,CACxC"}
|
package/dist/main.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionProcessingService.d.ts","sourceRoot":"","sources":["../../services/actionProcessingService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAMtE,qBAAa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;IAC9D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6B;IAElE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,OAAO,CAAC,QAAQ,CAAY;gBAGxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IA4Bb,UAAU,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACL,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,aAAa,EAAE,iBAAiB,EAAE,CAAC;KACtC,EACD,eAAe,CAAC,EAAE,OAAO,EACzB,gCAAgC,CAAC,EAAE,OAAO;
|
|
1
|
+
{"version":3,"file":"actionProcessingService.d.ts","sourceRoot":"","sources":["../../services/actionProcessingService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAuB,MAAM,qBAAqB,CAAC;AAEnE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AAMtE,qBAAa,uBAAuB;IAChC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAyB;IAC1D,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAA2B;IAC9D,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA6B;IAElE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,OAAO,CAAC,QAAQ,CAAY;gBAGxB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IA4Bb,UAAU,CACZ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACL,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,aAAa,EAAE,iBAAiB,EAAE,CAAC;KACtC,EACD,eAAe,CAAC,EAAE,OAAO,EACzB,gCAAgC,CAAC,EAAE,OAAO;IA0D9C,IAAI,CAAC,IAAI,EAAE,MAAM;CAGpB"}
|
|
@@ -9,6 +9,13 @@ const commandActionProcessor_1 = require("./actionProcessors/commandActionProces
|
|
|
9
9
|
const inlineQueryActionProcessor_1 = require("./actionProcessors/inlineQueryActionProcessor");
|
|
10
10
|
const scheduledActionProcessor_1 = require("./actionProcessors/scheduledActionProcessor");
|
|
11
11
|
class ActionProcessingService {
|
|
12
|
+
storage;
|
|
13
|
+
logger;
|
|
14
|
+
commandProcessor;
|
|
15
|
+
scheduledProcessor;
|
|
16
|
+
inlineQueryProcessor;
|
|
17
|
+
botName;
|
|
18
|
+
telegraf;
|
|
12
19
|
constructor(botName, chats, storage, scheduler, logger) {
|
|
13
20
|
this.storage = storage;
|
|
14
21
|
this.logger = logger;
|
|
@@ -19,7 +26,9 @@ class ActionProcessingService {
|
|
|
19
26
|
}
|
|
20
27
|
async initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage) {
|
|
21
28
|
this.telegraf = new telegraf_1.Telegraf(token);
|
|
22
|
-
const api = new telegramApi_1.TelegramApiService(this.botName, this.telegraf.telegram, this.storage, this.logger, (capture, id, chatInfo, traceId) =>
|
|
29
|
+
const api = new telegramApi_1.TelegramApiService(this.botName, this.telegraf.telegram, this.storage, this.logger, (capture, id, chatInfo, traceId) => {
|
|
30
|
+
this.commandProcessor.captureRegistrationCallback(capture, id, chatInfo, traceId);
|
|
31
|
+
});
|
|
23
32
|
const botInfo = await this.telegraf.telegram.getMe();
|
|
24
33
|
const commandActions = actions.commands.length > 0
|
|
25
34
|
? [
|
|
@@ -32,8 +41,11 @@ class ActionProcessingService {
|
|
|
32
41
|
this.commandProcessor.initialize(api, this.telegraf, commandActions, verboseLoggingForIncomingMessage ?? false);
|
|
33
42
|
this.inlineQueryProcessor.initialize(api, this.telegraf, actions.inlineQueries, 300);
|
|
34
43
|
this.scheduledProcessor.initialize(api, actions.scheduled, scheduledPeriod ?? (0, timeConvertions_1.hoursToSeconds)(1));
|
|
35
|
-
this.storage.saveMetadata([
|
|
36
|
-
|
|
44
|
+
void this.storage.saveMetadata([
|
|
45
|
+
...actions.scheduled,
|
|
46
|
+
...commandActions
|
|
47
|
+
]);
|
|
48
|
+
void this.telegraf.launch();
|
|
37
49
|
}
|
|
38
50
|
stop(code) {
|
|
39
51
|
this.telegraf.stop(code);
|