chz-telegram-bot 0.5.4 → 0.5.5
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/builtin/helpAction.d.ts +2 -0
- package/dist/builtin/helpAction.d.ts.map +1 -0
- package/dist/builtin/helpAction.js +14 -0
- package/dist/dtos/chatHistoryMessage.d.ts +35 -0
- package/dist/dtos/chatHistoryMessage.d.ts.map +1 -0
- package/dist/dtos/chatHistoryMessage.js +32 -0
- package/dist/dtos/chatInfo.d.ts +17 -0
- package/dist/dtos/chatInfo.d.ts.map +1 -0
- package/dist/dtos/chatInfo.js +16 -0
- package/dist/dtos/commandTriggerCheckResult.d.ts +24 -0
- package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -0
- package/dist/dtos/commandTriggerCheckResult.js +34 -0
- package/dist/dtos/cooldownInfo.d.ts +13 -0
- package/dist/dtos/cooldownInfo.d.ts.map +1 -0
- package/dist/dtos/cooldownInfo.js +12 -0
- package/dist/dtos/incomingMessage.d.ts +19 -0
- package/dist/dtos/incomingMessage.d.ts.map +1 -0
- package/dist/dtos/incomingMessage.js +63 -0
- package/dist/dtos/incomingQuery.d.ts +10 -0
- package/dist/dtos/incomingQuery.d.ts.map +1 -0
- package/dist/dtos/incomingQuery.js +14 -0
- package/dist/dtos/messageInfo.d.ts +22 -0
- package/dist/dtos/messageInfo.d.ts.map +1 -0
- package/dist/dtos/messageInfo.js +20 -0
- package/dist/dtos/propertyProviderSets.d.ts +16 -0
- package/dist/dtos/propertyProviderSets.d.ts.map +1 -0
- package/dist/dtos/propertyProviderSets.js +1 -0
- package/dist/dtos/replyInfo.d.ts +6 -0
- package/dist/dtos/replyInfo.d.ts.map +1 -0
- package/dist/dtos/replyInfo.js +8 -0
- package/dist/dtos/responses/delay.d.ts +16 -0
- package/dist/dtos/responses/delay.d.ts.map +1 -0
- package/dist/dtos/responses/delay.js +15 -0
- package/dist/dtos/responses/imageMessage.d.ts +22 -0
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -0
- package/dist/dtos/responses/imageMessage.js +21 -0
- package/dist/dtos/responses/inlineQueryResponse.d.ts +13 -0
- package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -0
- package/dist/dtos/responses/inlineQueryResponse.js +15 -0
- package/dist/dtos/responses/reaction.d.ts +16 -0
- package/dist/dtos/responses/reaction.d.ts.map +1 -0
- package/dist/dtos/responses/reaction.js +17 -0
- package/dist/dtos/responses/textMessage.d.ts +23 -0
- package/dist/dtos/responses/textMessage.d.ts.map +1 -0
- package/dist/dtos/responses/textMessage.js +24 -0
- package/dist/dtos/responses/unpin.d.ts +15 -0
- package/dist/dtos/responses/unpin.d.ts.map +1 -0
- package/dist/dtos/responses/unpin.js +15 -0
- package/dist/dtos/responses/videoMessage.d.ts +22 -0
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -0
- package/dist/dtos/responses/videoMessage.js +21 -0
- package/dist/dtos/userInfo.d.ts +12 -0
- package/dist/dtos/userInfo.d.ts.map +1 -0
- package/dist/dtos/userInfo.js +12 -0
- package/dist/entities/actions/commandAction.d.ts +31 -0
- package/dist/entities/actions/commandAction.d.ts.map +1 -0
- package/dist/entities/actions/commandAction.js +139 -0
- package/dist/entities/actions/inlineQueryAction.d.ts +14 -0
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -0
- package/dist/entities/actions/inlineQueryAction.js +43 -0
- package/dist/entities/actions/replyCaptureAction.d.ts +15 -0
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -0
- package/dist/entities/actions/replyCaptureAction.js +58 -0
- package/dist/entities/actions/scheduledAction.d.ts +24 -0
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -0
- package/dist/entities/actions/scheduledAction.js +72 -0
- package/dist/entities/botInstance.d.ts +37 -0
- package/dist/entities/botInstance.d.ts.map +1 -0
- package/dist/entities/botInstance.js +37 -0
- package/dist/entities/cachedStateFactory.d.ts +7 -0
- package/dist/entities/cachedStateFactory.d.ts.map +1 -0
- package/dist/entities/cachedStateFactory.js +8 -0
- package/dist/entities/context/baseContext.d.ts +39 -0
- package/dist/entities/context/baseContext.d.ts.map +1 -0
- package/dist/entities/context/baseContext.js +55 -0
- package/dist/entities/context/chatContext.d.ts +50 -0
- package/dist/entities/context/chatContext.d.ts.map +1 -0
- package/dist/entities/context/chatContext.js +65 -0
- package/dist/entities/context/inlineQueryContext.d.ts +27 -0
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -0
- package/dist/entities/context/inlineQueryContext.js +29 -0
- package/dist/entities/context/messageContext.d.ts +92 -0
- package/dist/entities/context/messageContext.d.ts.map +1 -0
- package/dist/entities/context/messageContext.js +116 -0
- package/dist/entities/context/replyContext.d.ts +89 -0
- package/dist/entities/context/replyContext.d.ts.map +1 -0
- package/dist/entities/context/replyContext.js +124 -0
- package/dist/entities/states/actionStateBase.d.ts +6 -0
- package/dist/entities/states/actionStateBase.d.ts.map +1 -0
- package/dist/entities/states/actionStateBase.js +4 -0
- package/dist/entities/taskRecord.d.ts +8 -0
- package/dist/entities/taskRecord.d.ts.map +1 -0
- package/dist/entities/taskRecord.js +10 -0
- package/dist/eslint.config.d.ts +3 -0
- package/dist/eslint.config.d.ts.map +1 -0
- package/dist/eslint.config.js +51 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts +100 -0
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/commandActionBuilder.js +146 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts +37 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/inlineQueryActionBuilder.js +50 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts +68 -0
- package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +1 -0
- package/dist/helpers/builders/scheduledActionBuilder.js +95 -0
- package/dist/helpers/mapUtils.d.ts +10 -0
- package/dist/helpers/mapUtils.d.ts.map +1 -0
- package/dist/helpers/mapUtils.js +13 -0
- package/dist/helpers/noop.d.ts +9 -0
- package/dist/helpers/noop.d.ts.map +1 -0
- package/dist/helpers/noop.js +17 -0
- package/dist/helpers/objectFromEntries.d.ts +2 -0
- package/dist/helpers/objectFromEntries.d.ts.map +1 -0
- package/dist/helpers/objectFromEntries.js +3 -0
- package/dist/helpers/timeConvertions.d.ts +5 -0
- package/dist/helpers/timeConvertions.d.ts.map +1 -0
- package/dist/helpers/timeConvertions.js +9 -0
- package/dist/helpers/toArray.d.ts +2 -0
- package/dist/helpers/toArray.d.ts.map +1 -0
- package/dist/helpers/toArray.js +3 -0
- package/dist/helpers/traceFactory.d.ts +3 -0
- package/dist/helpers/traceFactory.d.ts.map +1 -0
- package/dist/helpers/traceFactory.js +3 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/main.d.ts +52 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +34 -0
- package/dist/services/actionProcessingService.d.ts +25 -0
- package/dist/services/actionProcessingService.d.ts.map +1 -0
- package/dist/services/actionProcessingService.js +50 -0
- package/dist/services/actionProcessors/baseProcessor.d.ts +18 -0
- package/dist/services/actionProcessors/baseProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/baseProcessor.js +29 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +20 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/commandActionProcessor.js +116 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +11 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +61 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts +17 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.js +56 -0
- package/dist/services/jsonFileStorage.d.ts +23 -0
- package/dist/services/jsonFileStorage.d.ts.map +1 -0
- package/dist/services/jsonFileStorage.js +109 -0
- package/dist/services/jsonLogger.d.ts +11 -0
- package/dist/services/jsonLogger.d.ts.map +1 -0
- package/dist/services/jsonLogger.js +66 -0
- package/dist/services/nodeTimeoutScheduler.d.ts +13 -0
- package/dist/services/nodeTimeoutScheduler.d.ts.map +1 -0
- package/dist/services/nodeTimeoutScheduler.js +31 -0
- package/dist/services/responseProcessingQueue.d.ts +12 -0
- package/dist/services/responseProcessingQueue.d.ts.map +1 -0
- package/dist/services/responseProcessingQueue.js +37 -0
- package/dist/services/telegramApi.d.ts +23 -0
- package/dist/services/telegramApi.d.ts.map +1 -0
- package/dist/services/telegramApi.js +133 -0
- package/dist/types/action.d.ts +14 -0
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/action.js +1 -0
- package/dist/types/actionState.d.ts +5 -0
- package/dist/types/actionState.d.ts.map +1 -0
- package/dist/types/actionState.js +1 -0
- package/dist/types/cachedValueAccessor.d.ts +2 -0
- package/dist/types/cachedValueAccessor.d.ts.map +1 -0
- package/dist/types/cachedValueAccessor.js +1 -0
- package/dist/types/capture.d.ts +24 -0
- package/dist/types/capture.d.ts.map +1 -0
- package/dist/types/capture.js +1 -0
- package/dist/types/commandCondition.d.ts +8 -0
- package/dist/types/commandCondition.d.ts.map +1 -0
- package/dist/types/commandCondition.js +1 -0
- package/dist/types/commandTrigger.d.ts +2 -0
- package/dist/types/commandTrigger.d.ts.map +1 -0
- package/dist/types/commandTrigger.js +1 -0
- package/dist/types/externalAliases.d.ts +11 -0
- package/dist/types/externalAliases.d.ts.map +1 -0
- package/dist/types/externalAliases.js +1 -0
- package/dist/types/handlers.d.ts +21 -0
- package/dist/types/handlers.d.ts.map +1 -0
- package/dist/types/handlers.js +1 -0
- package/dist/types/inputFile.d.ts +5 -0
- package/dist/types/inputFile.d.ts.map +1 -0
- package/dist/types/inputFile.js +1 -0
- package/dist/types/logger.d.ts +13 -0
- package/dist/types/logger.d.ts.map +1 -0
- package/dist/types/logger.js +1 -0
- package/dist/types/messageSendingOptions.d.ts +9 -0
- package/dist/types/messageSendingOptions.d.ts.map +1 -0
- package/dist/types/messageSendingOptions.js +1 -0
- package/dist/types/messageTypes.d.ts +20 -0
- package/dist/types/messageTypes.d.ts.map +1 -0
- package/dist/types/messageTypes.js +18 -0
- package/dist/types/propertyProvider.d.ts +8 -0
- package/dist/types/propertyProvider.d.ts.map +1 -0
- package/dist/types/propertyProvider.js +1 -0
- package/dist/types/response.d.ts +39 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +9 -0
- package/dist/types/scheduler.d.ts +7 -0
- package/dist/types/scheduler.d.ts.map +1 -0
- package/dist/types/scheduler.js +1 -0
- package/dist/types/storage.d.ts +11 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +1 -0
- package/dist/types/timeValues.d.ts +15 -0
- package/dist/types/timeValues.d.ts.map +1 -0
- package/dist/types/timeValues.js +1 -0
- package/dist/types/trace.d.ts +6 -0
- package/dist/types/trace.d.ts.map +1 -0
- package/dist/types/trace.js +1 -0
- package/package.json +38 -38
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,MAAM,YAAY,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAC9D,oBAAoB,CAAC,YAAY,CAAC,EAChC,2BAA2B,GAC3B,WAAW,GACX,eAAe,GACf,gBAAgB,CACrB,CAAC;AAEF,qBAAa,oBAAoB,CAC7B,kBAAkB,SAAS,YAAY,CACzC,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACjE,4HAA4H;IAC5H,YAAY,EAAG,eAAe,EAAE,CAAC;IACjC,kDAAkD;IAClD,cAAc,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,6BAA6B;IAC7B,OAAO,EAAG,YAAY,CAAC;IAEvB,aAAa,UAAS;IAEtB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB;;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"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ReplyInfo } from '../../dtos/replyInfo';
|
|
2
|
+
import { ImageMessage } from '../../dtos/responses/imageMessage';
|
|
3
|
+
import { Reaction } from '../../dtos/responses/reaction';
|
|
4
|
+
import { TextMessage } from '../../dtos/responses/textMessage';
|
|
5
|
+
import { VideoMessage } from '../../dtos/responses/videoMessage';
|
|
6
|
+
import { resolve } from 'path';
|
|
7
|
+
import { BaseContextInternal } from './baseContext';
|
|
8
|
+
export class ReplyContextInternal extends BaseContextInternal {
|
|
9
|
+
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
10
|
+
matchResults;
|
|
11
|
+
/** Id of a message that triggered this action. */
|
|
12
|
+
replyMessageId;
|
|
13
|
+
/** Information about the user that triggered this action */
|
|
14
|
+
userInfo;
|
|
15
|
+
/** Information about the message that triggered this action */
|
|
16
|
+
messageInfo;
|
|
17
|
+
/** Bot info from Telegram */
|
|
18
|
+
botInfo;
|
|
19
|
+
isInitialized = false;
|
|
20
|
+
getQuotePart(quote) {
|
|
21
|
+
if (typeof quote != 'boolean')
|
|
22
|
+
return quote;
|
|
23
|
+
return this.matchResults.length == 0
|
|
24
|
+
? this.messageInfo.text
|
|
25
|
+
: this.matchResults[0][1];
|
|
26
|
+
}
|
|
27
|
+
replyWithText(text, quote, options) {
|
|
28
|
+
const quotedPart = this.getQuotePart(quote);
|
|
29
|
+
const response = new TextMessage(text, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
30
|
+
this.responses.push(response);
|
|
31
|
+
return this.createCaptureController(response);
|
|
32
|
+
}
|
|
33
|
+
replyWithImage(name, quote, options) {
|
|
34
|
+
const quotedPart = this.getQuotePart(quote);
|
|
35
|
+
const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
36
|
+
this.responses.push(response);
|
|
37
|
+
return this.createCaptureController(response);
|
|
38
|
+
}
|
|
39
|
+
replyWithVideo(name, quote, options) {
|
|
40
|
+
const quotedPart = this.getQuotePart(quote);
|
|
41
|
+
const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
42
|
+
this.responses.push(response);
|
|
43
|
+
return this.createCaptureController(response);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Stops capturing replies and removes this action
|
|
47
|
+
*/
|
|
48
|
+
stopCapture() {
|
|
49
|
+
this.action.abortController.abort();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
53
|
+
*/
|
|
54
|
+
reply = {
|
|
55
|
+
/**
|
|
56
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
57
|
+
* If regex is matched, first match will be quoted
|
|
58
|
+
*/
|
|
59
|
+
andQuote: {
|
|
60
|
+
/**
|
|
61
|
+
* Reply with text 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
|
+
withText: (text, quote, options) => {
|
|
67
|
+
return this.replyWithText(text, quote ?? true, options);
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
71
|
+
* 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.
|
|
72
|
+
* @param text Message contents.
|
|
73
|
+
* @param options Message sending option.
|
|
74
|
+
*/
|
|
75
|
+
withImage: (name, quote, options) => {
|
|
76
|
+
return this.replyWithImage(name, quote ?? true, options);
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
80
|
+
* 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.
|
|
81
|
+
* @param text Message contents.
|
|
82
|
+
* @param options Message sending option.
|
|
83
|
+
*/
|
|
84
|
+
withVideo: (name, quote, options) => {
|
|
85
|
+
return this.replyWithVideo(name, quote ?? true, options);
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
/**
|
|
89
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
90
|
+
* 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.
|
|
91
|
+
* @param text Message contents.
|
|
92
|
+
* @param options Message sending option.
|
|
93
|
+
*/
|
|
94
|
+
withText: (text, options) => {
|
|
95
|
+
return this.replyWithText(text, false, options);
|
|
96
|
+
},
|
|
97
|
+
/**
|
|
98
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
99
|
+
* 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.
|
|
100
|
+
* @param text Message contents.
|
|
101
|
+
* @param options Message sending option.
|
|
102
|
+
*/
|
|
103
|
+
withImage: (name, options) => {
|
|
104
|
+
return this.replyWithImage(name, false, options);
|
|
105
|
+
},
|
|
106
|
+
/**
|
|
107
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
108
|
+
* 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.
|
|
109
|
+
* @param text Message contents.
|
|
110
|
+
* @param options Message sending option.
|
|
111
|
+
*/
|
|
112
|
+
withVideo: (name, options) => {
|
|
113
|
+
return this.replyWithVideo(name, false, options);
|
|
114
|
+
},
|
|
115
|
+
/**
|
|
116
|
+
* React to the message that triggered this action after action execution is finished.
|
|
117
|
+
* 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.
|
|
118
|
+
* @param emoji Telegram emoji to react with.
|
|
119
|
+
*/
|
|
120
|
+
withReaction: (emoji) => {
|
|
121
|
+
this.responses.push(new Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionStateBase.d.ts","sourceRoot":"","sources":["../../../entities/states/actionStateBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,eAAgB,YAAW,YAAY;IAChD,cAAc,EAAE,MAAM,EAAE,CAAM;IAC9B,gBAAgB,SAAK;CACxB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Milliseconds } from '../types/timeValues';
|
|
2
|
+
export declare class TaskRecord {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
readonly taskId: NodeJS.Timeout;
|
|
5
|
+
readonly interval: Milliseconds;
|
|
6
|
+
constructor(name: string, taskId: NodeJS.Timeout, interval: Milliseconds);
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=taskRecord.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"taskRecord.d.ts","sourceRoot":"","sources":["../../entities/taskRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,qBAAa,UAAU;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;gBAEpB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;CAK3E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eslint.config.d.ts","sourceRoot":"","sources":["../eslint.config.ts"],"names":[],"mappings":";AAIA,wBAoDE"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
import parser from '@typescript-eslint/parser';
|
|
4
|
+
export default tseslint.config({
|
|
5
|
+
ignores: ['dist/**']
|
|
6
|
+
}, eslint.configs.recommended, tseslint.configs.strictTypeChecked, {
|
|
7
|
+
languageOptions: {
|
|
8
|
+
parser,
|
|
9
|
+
parserOptions: {
|
|
10
|
+
project: './tsconfig.json',
|
|
11
|
+
tsconfigRootDir: __dirname,
|
|
12
|
+
sourceType: 'module',
|
|
13
|
+
projectService: true
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
plugins: { '@typescript-eslint': tseslint.plugin },
|
|
17
|
+
rules: {
|
|
18
|
+
'@typescript-eslint/switch-exhaustiveness-check': 'error',
|
|
19
|
+
'@typescript-eslint/no-unused-vars': [
|
|
20
|
+
'error',
|
|
21
|
+
{
|
|
22
|
+
args: 'all',
|
|
23
|
+
argsIgnorePattern: '^_',
|
|
24
|
+
caughtErrors: 'all',
|
|
25
|
+
caughtErrorsIgnorePattern: '^_',
|
|
26
|
+
destructuredArrayIgnorePattern: '^_',
|
|
27
|
+
varsIgnorePattern: '^_',
|
|
28
|
+
ignoreRestSiblings: true
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
'@typescript-eslint/no-misused-promises': [
|
|
32
|
+
'error',
|
|
33
|
+
{
|
|
34
|
+
checksVoidReturn: true,
|
|
35
|
+
checksConditionals: true
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
'@typescript-eslint/restrict-template-expressions': [
|
|
39
|
+
'error',
|
|
40
|
+
{
|
|
41
|
+
allowNumber: true
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
'@typescript-eslint/unbound-method': [
|
|
45
|
+
'error',
|
|
46
|
+
{
|
|
47
|
+
ignoreStatic: true
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
});
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { CommandHandler } from '../../types/handlers';
|
|
2
|
+
import { CommandCondition } from '../../types/commandCondition';
|
|
3
|
+
import { Seconds } from '../../types/timeValues';
|
|
4
|
+
import { CommandAction } from '../../entities/actions/commandAction';
|
|
5
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
6
|
+
import { IActionState } from '../../types/actionState';
|
|
7
|
+
import { CommandTrigger } from '../../types/commandTrigger';
|
|
8
|
+
import { CooldownInfo } from '../../dtos/cooldownInfo';
|
|
9
|
+
import { CommandActionPropertyProvider } from '../../types/propertyProvider';
|
|
10
|
+
/**
|
|
11
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
12
|
+
*/
|
|
13
|
+
export declare class CommandActionBuilderWithState<TActionState extends IActionState> {
|
|
14
|
+
private readonly name;
|
|
15
|
+
private trigger;
|
|
16
|
+
private activeProvider;
|
|
17
|
+
private cooldownSettingsProvider;
|
|
18
|
+
private blacklistProvider;
|
|
19
|
+
private whitelistProvider;
|
|
20
|
+
private allowedUsersProvider;
|
|
21
|
+
private readmeFactory;
|
|
22
|
+
private readonly stateConstructor;
|
|
23
|
+
private handler;
|
|
24
|
+
private condition;
|
|
25
|
+
private maxAllowedSimultaniousExecutions;
|
|
26
|
+
/**
|
|
27
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
28
|
+
* @param name Action name, will be used for logging and storage
|
|
29
|
+
* @param stateConstructor Function that creates default state object
|
|
30
|
+
*/
|
|
31
|
+
constructor(name: string, stateConstructor: () => TActionState);
|
|
32
|
+
/**
|
|
33
|
+
* Defines action trigger
|
|
34
|
+
* @param trigger If `string` or `string[]` is provided, will be triggered only on exact message match.
|
|
35
|
+
*
|
|
36
|
+
* If `RegExp` or `RegExp[]` is provided, will be triggered on successful match.
|
|
37
|
+
*/
|
|
38
|
+
on(trigger: CommandTrigger | CommandTrigger[]): this;
|
|
39
|
+
/** Defines id (or ids) of users that are allowed to trigger this action.
|
|
40
|
+
* @param id User id or ids
|
|
41
|
+
*/
|
|
42
|
+
from(id: number | number[]): this;
|
|
43
|
+
/**
|
|
44
|
+
* Sets chats whitelist for this action.
|
|
45
|
+
* @param chatIds Chats ids to allow.
|
|
46
|
+
*/
|
|
47
|
+
in(chatIds: number[]): this;
|
|
48
|
+
/**
|
|
49
|
+
* Sets chats blacklist for this action.
|
|
50
|
+
* @param chatIds Chats ids to ignore.
|
|
51
|
+
*/
|
|
52
|
+
notIn(chatIds: number[]): this;
|
|
53
|
+
/** Defines action logic itself, will be executed on trigger.
|
|
54
|
+
* @param handler Callback that will be called on trigger
|
|
55
|
+
*/
|
|
56
|
+
do(handler: CommandHandler<TActionState>): this;
|
|
57
|
+
/** Defines condition that will be checked before trigger match check is executed.
|
|
58
|
+
* @param condition Condition check predicate
|
|
59
|
+
*/
|
|
60
|
+
when(condition: CommandCondition<TActionState>): this;
|
|
61
|
+
/**
|
|
62
|
+
* Sets factory method for readme (shown on /help) for this action.
|
|
63
|
+
* @param readmeFactory readme factory
|
|
64
|
+
*/
|
|
65
|
+
withHelp(readmeFactory: (botName: string) => string): this;
|
|
66
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
67
|
+
disabled(): this;
|
|
68
|
+
/** Sets maximum number of simultaniously executing handlers for this command per chat. 0 is treated as unlimited. */
|
|
69
|
+
withRatelimit(maxAllowedSimultaniousExecutions: number): this;
|
|
70
|
+
/** Sets action cooldown settings.
|
|
71
|
+
* @param cooldownSettings Settings.
|
|
72
|
+
*/
|
|
73
|
+
withCooldown(cooldownSettings: {
|
|
74
|
+
cooldown: Seconds;
|
|
75
|
+
message?: string;
|
|
76
|
+
}): this;
|
|
77
|
+
/**
|
|
78
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
79
|
+
*/
|
|
80
|
+
withConfiguration(configuration: CommandActionProvidersConfiguration | (() => CommandActionProvidersConfiguration)): this;
|
|
81
|
+
/** Builds action */
|
|
82
|
+
build(): CommandAction<TActionState>;
|
|
83
|
+
}
|
|
84
|
+
export type CommandActionProvidersConfiguration = {
|
|
85
|
+
cooldownProvider?: CommandActionPropertyProvider<CooldownInfo>;
|
|
86
|
+
isActiveProvider?: CommandActionPropertyProvider<boolean>;
|
|
87
|
+
chatsBlacklistProvider?: CommandActionPropertyProvider<number[]>;
|
|
88
|
+
chatsWhitelistProvider?: CommandActionPropertyProvider<number[]>;
|
|
89
|
+
usersWhitelistProvider?: CommandActionPropertyProvider<number[]>;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
93
|
+
*/
|
|
94
|
+
export declare class CommandActionBuilder extends CommandActionBuilderWithState<ActionStateBase> {
|
|
95
|
+
/**
|
|
96
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
97
|
+
*/
|
|
98
|
+
constructor(name: string);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=commandActionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commandActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/commandActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAE7E;;GAEG;AACH,qBAAa,6BAA6B,CAAC,YAAY,SAAS,YAAY;IACxE,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAyC;IAExD,OAAO,CAAC,cAAc,CAAsD;IAC5E,OAAO,CAAC,wBAAwB,CACS;IACzC,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,oBAAoB,CACf;IAEb,OAAO,CAAC,aAAa,CAAiD;IACtE,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IACtD,OAAO,CAAC,OAAO,CAA2C;IAC1D,OAAO,CAAC,SAAS,CAA6C;IAC9D,OAAO,CAAC,gCAAgC,CAAa;IAErD;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY;IAK9D;;;;;OAKG;IACH,EAAE,CAAC,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE;IAM7C;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE;IAO1B;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE;IAMpB;;;OAGG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE;IAMvB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC;IAMxC;;OAEG;IACH,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAM9C;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAMnD,iFAAiF;IACjF,QAAQ;IAMR,qHAAqH;IACrH,aAAa,CAAC,gCAAgC,EAAE,MAAM;IAOtD;;OAEG;IACH,YAAY,CAAC,gBAAgB,EAAE;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE;IAUtE;;OAEG;IACH,iBAAiB,CACb,aAAa,EACP,mCAAmC,GACnC,CAAC,MAAM,mCAAmC,CAAC;IAwBrD,oBAAoB;IACpB,KAAK;CAkBR;AAED,MAAM,MAAM,mCAAmC,GAAG;IAC9C,gBAAgB,CAAC,EAAE,6BAA6B,CAAC,YAAY,CAAC,CAAC;IAC/D,gBAAgB,CAAC,EAAE,6BAA6B,CAAC,OAAO,CAAC,CAAC;IAC1D,sBAAsB,CAAC,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,sBAAsB,CAAC,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;IACjE,sBAAsB,CAAC,EAAE,6BAA6B,CAAC,MAAM,EAAE,CAAC,CAAC;CACpE,CAAC;AAEF;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,6BAA6B,CAAC,eAAe,CAAC;IACpF;;OAEG;gBACS,IAAI,EAAE,MAAM;CAG3B"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { CommandAction } from '../../entities/actions/commandAction';
|
|
2
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
3
|
+
import { toArray } from '../toArray';
|
|
4
|
+
import { Noop } from '../noop';
|
|
5
|
+
import { CooldownInfo } from '../../dtos/cooldownInfo';
|
|
6
|
+
/**
|
|
7
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
8
|
+
*/
|
|
9
|
+
export class CommandActionBuilderWithState {
|
|
10
|
+
name;
|
|
11
|
+
trigger = [];
|
|
12
|
+
activeProvider = () => true;
|
|
13
|
+
cooldownSettingsProvider = () => new CooldownInfo(0);
|
|
14
|
+
blacklistProvider = () => [];
|
|
15
|
+
whitelistProvider = () => [];
|
|
16
|
+
allowedUsersProvider = () => [];
|
|
17
|
+
readmeFactory = Noop.emptyString;
|
|
18
|
+
stateConstructor;
|
|
19
|
+
handler = Noop.call;
|
|
20
|
+
condition = Noop.true;
|
|
21
|
+
maxAllowedSimultaniousExecutions = 0;
|
|
22
|
+
/**
|
|
23
|
+
* Builder for `CommandAction` with state represented by `TActionState`
|
|
24
|
+
* @param name Action name, will be used for logging and storage
|
|
25
|
+
* @param stateConstructor Function that creates default state object
|
|
26
|
+
*/
|
|
27
|
+
constructor(name, stateConstructor) {
|
|
28
|
+
this.name = name;
|
|
29
|
+
this.stateConstructor = stateConstructor;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Defines action trigger
|
|
33
|
+
* @param trigger If `string` or `string[]` is provided, will be triggered only on exact message match.
|
|
34
|
+
*
|
|
35
|
+
* If `RegExp` or `RegExp[]` is provided, will be triggered on successful match.
|
|
36
|
+
*/
|
|
37
|
+
on(trigger) {
|
|
38
|
+
this.trigger = trigger;
|
|
39
|
+
return this;
|
|
40
|
+
}
|
|
41
|
+
/** Defines id (or ids) of users that are allowed to trigger this action.
|
|
42
|
+
* @param id User id or ids
|
|
43
|
+
*/
|
|
44
|
+
from(id) {
|
|
45
|
+
const ids = toArray(id);
|
|
46
|
+
this.allowedUsersProvider = () => ids;
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets chats whitelist for this action.
|
|
51
|
+
* @param chatIds Chats ids to allow.
|
|
52
|
+
*/
|
|
53
|
+
in(chatIds) {
|
|
54
|
+
this.whitelistProvider = () => chatIds;
|
|
55
|
+
return this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Sets chats blacklist for this action.
|
|
59
|
+
* @param chatIds Chats ids to ignore.
|
|
60
|
+
*/
|
|
61
|
+
notIn(chatIds) {
|
|
62
|
+
this.blacklistProvider = () => chatIds;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/** Defines action logic itself, will be executed on trigger.
|
|
66
|
+
* @param handler Callback that will be called on trigger
|
|
67
|
+
*/
|
|
68
|
+
do(handler) {
|
|
69
|
+
this.handler = handler;
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/** Defines condition that will be checked before trigger match check is executed.
|
|
73
|
+
* @param condition Condition check predicate
|
|
74
|
+
*/
|
|
75
|
+
when(condition) {
|
|
76
|
+
this.condition = condition;
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Sets factory method for readme (shown on /help) for this action.
|
|
81
|
+
* @param readmeFactory readme factory
|
|
82
|
+
*/
|
|
83
|
+
withHelp(readmeFactory) {
|
|
84
|
+
this.readmeFactory = readmeFactory;
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
88
|
+
disabled() {
|
|
89
|
+
this.activeProvider = () => false;
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
/** Sets maximum number of simultaniously executing handlers for this command per chat. 0 is treated as unlimited. */
|
|
93
|
+
withRatelimit(maxAllowedSimultaniousExecutions) {
|
|
94
|
+
this.maxAllowedSimultaniousExecutions =
|
|
95
|
+
maxAllowedSimultaniousExecutions;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
/** Sets action cooldown settings.
|
|
99
|
+
* @param cooldownSettings Settings.
|
|
100
|
+
*/
|
|
101
|
+
withCooldown(cooldownSettings) {
|
|
102
|
+
const settings = new CooldownInfo(cooldownSettings.cooldown, cooldownSettings.message);
|
|
103
|
+
this.cooldownSettingsProvider = () => settings;
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
108
|
+
*/
|
|
109
|
+
withConfiguration(configuration) {
|
|
110
|
+
if (typeof configuration == 'function') {
|
|
111
|
+
configuration = configuration();
|
|
112
|
+
}
|
|
113
|
+
if (configuration.cooldownProvider)
|
|
114
|
+
this.cooldownSettingsProvider = configuration.cooldownProvider;
|
|
115
|
+
if (configuration.chatsWhitelistProvider)
|
|
116
|
+
this.whitelistProvider = configuration.chatsWhitelistProvider;
|
|
117
|
+
if (configuration.chatsBlacklistProvider)
|
|
118
|
+
this.blacklistProvider = configuration.chatsBlacklistProvider;
|
|
119
|
+
if (configuration.usersWhitelistProvider)
|
|
120
|
+
this.allowedUsersProvider = configuration.usersWhitelistProvider;
|
|
121
|
+
if (configuration.isActiveProvider)
|
|
122
|
+
this.activeProvider = configuration.isActiveProvider;
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
/** Builds action */
|
|
126
|
+
build() {
|
|
127
|
+
return new CommandAction(this.trigger, this.handler, this.name, {
|
|
128
|
+
cooldownProvider: this.cooldownSettingsProvider,
|
|
129
|
+
isActiveProvider: this.activeProvider,
|
|
130
|
+
chatsBlacklistProvider: this.blacklistProvider,
|
|
131
|
+
chatsWhitelistProvider: this.whitelistProvider,
|
|
132
|
+
usersWhitelistProvider: this.allowedUsersProvider
|
|
133
|
+
}, this.maxAllowedSimultaniousExecutions, this.condition, this.stateConstructor, this.readmeFactory);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
138
|
+
*/
|
|
139
|
+
export class CommandActionBuilder extends CommandActionBuilderWithState {
|
|
140
|
+
/**
|
|
141
|
+
* Builder for `CommandAction` with state represented by default state (containing only last execution date).
|
|
142
|
+
*/
|
|
143
|
+
constructor(name) {
|
|
144
|
+
super(name, () => new ActionStateBase());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InlineQueryHandler } from '../../types/handlers';
|
|
2
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
3
|
+
import { InlineActionPropertyProvider } from '../../types/propertyProvider';
|
|
4
|
+
/**
|
|
5
|
+
* Builder for `InlineQueryAction`
|
|
6
|
+
*/
|
|
7
|
+
export declare class InlineQueryActionBuilder {
|
|
8
|
+
private readonly name;
|
|
9
|
+
private pattern;
|
|
10
|
+
private activeProvider;
|
|
11
|
+
private handler;
|
|
12
|
+
/**
|
|
13
|
+
* Builder for `InlineQueryAction`
|
|
14
|
+
* @param name Action name, will be used for logging and storage
|
|
15
|
+
*/
|
|
16
|
+
constructor(name: string);
|
|
17
|
+
/**
|
|
18
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
19
|
+
* @param trigger RegExp to check
|
|
20
|
+
*/
|
|
21
|
+
on(pattern: RegExp): this;
|
|
22
|
+
/** Defines action logic itself, will be executed.
|
|
23
|
+
* @param handler Callback that will be called
|
|
24
|
+
*/
|
|
25
|
+
do(handler: InlineQueryHandler): this;
|
|
26
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
27
|
+
disabled(): this;
|
|
28
|
+
/**
|
|
29
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
30
|
+
*/
|
|
31
|
+
withConfiguration(configuration: {
|
|
32
|
+
isActiveProvider?: InlineActionPropertyProvider<boolean>;
|
|
33
|
+
}): this;
|
|
34
|
+
/** Builds action */
|
|
35
|
+
build(): InlineQueryAction;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=inlineQueryActionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inlineQueryActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/inlineQueryActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAE5E;;GAEG;AACH,qBAAa,wBAAwB;IACjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,OAAO,CAAkB;IAEjC,OAAO,CAAC,cAAc,CAAqD;IAC3E,OAAO,CAAC,OAAO,CAAiC;IAEhD;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM;IAMlB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,kBAAkB;IAM9B,iFAAiF;IACjF,QAAQ;IAMR;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE;QAC7B,gBAAgB,CAAC,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;KAC5D;IAOD,oBAAoB;IACpB,KAAK;CAQR"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Noop } from '../noop';
|
|
2
|
+
import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
|
|
3
|
+
/**
|
|
4
|
+
* Builder for `InlineQueryAction`
|
|
5
|
+
*/
|
|
6
|
+
export class InlineQueryActionBuilder {
|
|
7
|
+
name;
|
|
8
|
+
pattern = /.+/gi;
|
|
9
|
+
activeProvider = () => true;
|
|
10
|
+
handler = Noop.call;
|
|
11
|
+
/**
|
|
12
|
+
* Builder for `InlineQueryAction`
|
|
13
|
+
* @param name Action name, will be used for logging and storage
|
|
14
|
+
*/
|
|
15
|
+
constructor(name) {
|
|
16
|
+
this.name = name;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Defines action pattern to check if action should be executed, if not setup, check will default to true
|
|
20
|
+
* @param trigger RegExp to check
|
|
21
|
+
*/
|
|
22
|
+
on(pattern) {
|
|
23
|
+
this.pattern = pattern;
|
|
24
|
+
return this;
|
|
25
|
+
}
|
|
26
|
+
/** Defines action logic itself, will be executed.
|
|
27
|
+
* @param handler Callback that will be called
|
|
28
|
+
*/
|
|
29
|
+
do(handler) {
|
|
30
|
+
this.handler = handler;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
34
|
+
disabled() {
|
|
35
|
+
this.activeProvider = () => false;
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
40
|
+
*/
|
|
41
|
+
withConfiguration(configuration) {
|
|
42
|
+
if (configuration.isActiveProvider)
|
|
43
|
+
this.activeProvider = configuration.isActiveProvider;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/** Builds action */
|
|
47
|
+
build() {
|
|
48
|
+
return new InlineQueryAction(this.handler, this.name, this.activeProvider, this.pattern);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ScheduledAction } from '../../entities/actions/scheduledAction';
|
|
2
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
3
|
+
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ScheduledHandler } from '../../types/handlers';
|
|
5
|
+
import { ScheduledActionPropertyProvider } from '../../types/propertyProvider';
|
|
6
|
+
import { Hours, HoursOfDay } from '../../types/timeValues';
|
|
7
|
+
/**
|
|
8
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
9
|
+
*/
|
|
10
|
+
export declare class ScheduledActionBuilderWithState<TActionState extends IActionState> {
|
|
11
|
+
private readonly name;
|
|
12
|
+
private readonly cachedStateFactories;
|
|
13
|
+
private readonly stateConstructor;
|
|
14
|
+
private handler;
|
|
15
|
+
private whitelistProvider;
|
|
16
|
+
private activeProvider;
|
|
17
|
+
private timeinHoursProvider;
|
|
18
|
+
/**
|
|
19
|
+
* Builder for `ScheduledAction` with state represented by `TActionState`
|
|
20
|
+
* @param name Action name, will be used for logging and storage
|
|
21
|
+
* @param stateConstructor Function that creates default state object
|
|
22
|
+
*/
|
|
23
|
+
constructor(name: string, stateConstructor: () => TActionState);
|
|
24
|
+
/**
|
|
25
|
+
* Sets whitelist for this action.
|
|
26
|
+
* @param chatIds Chat ids to execute in.
|
|
27
|
+
*/
|
|
28
|
+
in(chatIds: number[]): this;
|
|
29
|
+
/**
|
|
30
|
+
* Defines time for scheduled item execution.
|
|
31
|
+
* @param time Time of day (0 - 23) to execute action.
|
|
32
|
+
*/
|
|
33
|
+
runAt(time: HoursOfDay): this;
|
|
34
|
+
/** Defines action logic itself, will be executed on timer.
|
|
35
|
+
* @param handler Callback that will be called on timer.
|
|
36
|
+
*/
|
|
37
|
+
do(handler: ScheduledHandler<TActionState>): this;
|
|
38
|
+
/**
|
|
39
|
+
* Defines process-wide cache, that is shared by all actions of this type (even in different bot instances).
|
|
40
|
+
* Can be used for fetch request de-duping, etc.
|
|
41
|
+
* @param key Key that will be used to retrieve value from cache.
|
|
42
|
+
* @param itemFactory Callback that will be executed once to create cached value.
|
|
43
|
+
* @param invalidationTimeoutInHours Timeout for cache invalidation.
|
|
44
|
+
*/
|
|
45
|
+
withSharedCache(key: string, itemFactory: () => Promise<unknown>, invalidationTimeoutInHours?: Hours): this;
|
|
46
|
+
/** If called during building, action is marked as disabled and never checked. */
|
|
47
|
+
disabled(): this;
|
|
48
|
+
/**
|
|
49
|
+
* Configures action to use property value providers instead of static value to allow changes in runtime
|
|
50
|
+
*/
|
|
51
|
+
withConfiguration(configuration: {
|
|
52
|
+
timeinHoursProvider?: ScheduledActionPropertyProvider<HoursOfDay>;
|
|
53
|
+
isActiveProvider?: ScheduledActionPropertyProvider<boolean>;
|
|
54
|
+
chatsWhitelistProvider?: ScheduledActionPropertyProvider<number[]>;
|
|
55
|
+
}): this;
|
|
56
|
+
/** Builds action */
|
|
57
|
+
build(): ScheduledAction<TActionState>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
61
|
+
*/
|
|
62
|
+
export declare class ScheduledActionBuilder extends ScheduledActionBuilderWithState<ActionStateBase> {
|
|
63
|
+
/**
|
|
64
|
+
* Builder for `ScheduledAction` with state represented by default state (containing only last execution date).
|
|
65
|
+
*/
|
|
66
|
+
constructor(name: string);
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=scheduledActionBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scheduledActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/scheduledActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,+BAA+B,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG3D;;GAEG;AACH,qBAAa,+BAA+B,CACxC,YAAY,SAAS,YAAY;IAEjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAGjC;IACJ,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAqB;IACtD,OAAO,CAAC,OAAO,CAA6C;IAE5D,OAAO,CAAC,iBAAiB,CACZ;IACb,OAAO,CAAC,cAAc,CACb;IACT,OAAO,CAAC,mBAAmB,CACf;IAEZ;;;;OAIG;gBACS,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY;IAK9D;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE;IAMpB;;;OAGG;IACH,KAAK,CAAC,IAAI,EAAE,UAAU;IAMtB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAM1C;;;;;;OAMG;IACH,eAAe,CACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EACnC,0BAA0B,GAAE,KAAmB;IAUnD,iFAAiF;IACjF,QAAQ;IAMR;;OAEG;IACH,iBAAiB,CAAC,aAAa,EAAE;QAC7B,mBAAmB,CAAC,EAAE,+BAA+B,CAAC,UAAU,CAAC,CAAC;QAClE,gBAAgB,CAAC,EAAE,+BAA+B,CAAC,OAAO,CAAC,CAAC;QAC5D,sBAAsB,CAAC,EAAE,+BAA+B,CAAC,MAAM,EAAE,CAAC,CAAC;KACtE;IAaD,oBAAoB;IACpB,KAAK;CAaR;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,+BAA+B,CAAC,eAAe,CAAC;IACxF;;OAEG;gBACS,IAAI,EAAE,MAAM;CAG3B"}
|