chz-telegram-bot 0.3.10 → 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 +9 -12
- 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 +4 -6
- package/dist/services/actionProcessors/scheduledActionProcessor.js +6 -4
- 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.map +1 -1
- package/dist/services/responseProcessingQueue.js +9 -7
- 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 +4 -16
- package/services/actionProcessors/inlineQueryActionProcessor.ts +5 -15
- package/services/actionProcessors/scheduledActionProcessor.ts +4 -4
- package/services/jsonFileStorage.ts +39 -21
- package/services/jsonLogger.ts +12 -8
- package/services/nodeTimeoutScheduler.ts +6 -6
- package/services/responseProcessingQueue.ts +9 -4
- 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
package/builtin/helpAction.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Seconds } from '../types/timeValues';
|
|
|
4
4
|
export function buildHelpCommand(readmes: string[], botUsername: string) {
|
|
5
5
|
return new CommandActionBuilder('Reaction.Help')
|
|
6
6
|
.on(['/help', `/help@${botUsername}`])
|
|
7
|
-
.do(
|
|
7
|
+
.do((ctx) => {
|
|
8
8
|
if (readmes.length == 0) return;
|
|
9
9
|
|
|
10
10
|
ctx.reply.withText(readmes.join('\n\n'));
|
|
@@ -5,7 +5,7 @@ const commandActionBuilder_1 = require("../helpers/builders/commandActionBuilder
|
|
|
5
5
|
function buildHelpCommand(readmes, botUsername) {
|
|
6
6
|
return new commandActionBuilder_1.CommandActionBuilder('Reaction.Help')
|
|
7
7
|
.on(['/help', `/help@${botUsername}`])
|
|
8
|
-
.do(
|
|
8
|
+
.do((ctx) => {
|
|
9
9
|
if (readmes.length == 0)
|
|
10
10
|
return;
|
|
11
11
|
ctx.reply.withText(readmes.join('\n\n'));
|
package/dist/dtos/chatInfo.js
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChatInfo = void 0;
|
|
4
4
|
class ChatInfo {
|
|
5
|
+
/** Id of a chat that action is executed in. */
|
|
6
|
+
id;
|
|
7
|
+
/** Name of a chat that action is executed in. */
|
|
8
|
+
name;
|
|
5
9
|
constructor(chatId, chatName) {
|
|
6
10
|
this.id = chatId;
|
|
7
11
|
this.name = chatName;
|
|
@@ -11,6 +11,9 @@ class CommandTriggerCheckResult {
|
|
|
11
11
|
static get Trigger() {
|
|
12
12
|
return new CommandTriggerCheckResult(true, [], false);
|
|
13
13
|
}
|
|
14
|
+
shouldExecute;
|
|
15
|
+
matchResults;
|
|
16
|
+
skipCooldown;
|
|
14
17
|
constructor(shouldExecute, matchResults, skipCooldown) {
|
|
15
18
|
this.shouldExecute = shouldExecute;
|
|
16
19
|
this.matchResults = matchResults;
|
|
@@ -6,6 +6,14 @@ const messageTypes_1 = require("../types/messageTypes");
|
|
|
6
6
|
const chatInfo_1 = require("./chatInfo");
|
|
7
7
|
const traceFactory_1 = require("../helpers/traceFactory");
|
|
8
8
|
class IncomingMessage {
|
|
9
|
+
messageId;
|
|
10
|
+
chatInfo;
|
|
11
|
+
from;
|
|
12
|
+
text;
|
|
13
|
+
type;
|
|
14
|
+
traceId;
|
|
15
|
+
replyToMessageId;
|
|
16
|
+
updateObject;
|
|
9
17
|
detectMessageType(message) {
|
|
10
18
|
if ('forward_origin' in message)
|
|
11
19
|
return messageTypes_1.MessageType.Forward;
|
|
@@ -50,7 +58,7 @@ class IncomingMessage {
|
|
|
50
58
|
? ctxMessage.caption ?? ''
|
|
51
59
|
: '';
|
|
52
60
|
this.chatInfo = new chatInfo_1.ChatInfo(ctxMessage.chat.id, 'title' in ctxMessage.chat
|
|
53
|
-
? ctxMessage.chat.title
|
|
61
|
+
? `${ctxMessage.chat.title} ${ctxMessage.chat.id}`
|
|
54
62
|
: 'DM');
|
|
55
63
|
this.type = this.detectMessageType(ctxMessage);
|
|
56
64
|
this.updateObject = ctxMessage;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.IncomingInlineQuery = void 0;
|
|
4
4
|
class IncomingInlineQuery {
|
|
5
|
+
queryId;
|
|
6
|
+
query;
|
|
7
|
+
userId;
|
|
8
|
+
traceId;
|
|
9
|
+
abortController;
|
|
5
10
|
constructor(queryId, query, userId, traceId) {
|
|
6
11
|
this.queryId = queryId;
|
|
7
12
|
this.query = query;
|
package/dist/dtos/replyInfo.js
CHANGED
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DelayResponse = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class DelayResponse {
|
|
6
|
+
kind = response_1.BotResponseTypes.delay;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
chatInfo;
|
|
9
|
+
traceId;
|
|
10
|
+
delay;
|
|
11
|
+
action;
|
|
6
12
|
constructor(delay, chatInfo, traceId, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.delay;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
13
|
this.chatInfo = chatInfo;
|
|
10
14
|
this.delay = delay;
|
|
11
15
|
this.traceId = traceId;
|
|
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ImageMessage = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class ImageMessage {
|
|
6
|
+
kind = response_1.BotResponseTypes.image;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
captures = [];
|
|
9
|
+
content;
|
|
10
|
+
chatInfo;
|
|
11
|
+
replyInfo;
|
|
12
|
+
traceId;
|
|
13
|
+
disableWebPreview = false;
|
|
14
|
+
shouldPin;
|
|
15
|
+
action;
|
|
6
16
|
constructor(image, chatInfo, traceId, action, replyInfo, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.image;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
|
-
this.captures = [];
|
|
10
|
-
this.disableWebPreview = false;
|
|
11
17
|
this.content = image;
|
|
12
18
|
this.chatInfo = chatInfo;
|
|
13
19
|
this.replyInfo = replyInfo;
|
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InlineQueryResponse = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class InlineQueryResponse {
|
|
6
|
+
kind = response_1.BotResponseTypes.inlineQuery;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
queryId;
|
|
9
|
+
traceId;
|
|
10
|
+
action;
|
|
11
|
+
queryResults;
|
|
6
12
|
constructor(queryResult, queryId, traceId, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.inlineQuery;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
13
|
this.queryResults = queryResult;
|
|
10
14
|
this.queryId = queryId;
|
|
11
15
|
this.traceId = traceId;
|
|
@@ -3,9 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Reaction = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class Reaction {
|
|
6
|
+
kind = response_1.BotResponseTypes.react;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
chatInfo;
|
|
9
|
+
messageId;
|
|
10
|
+
traceId;
|
|
11
|
+
emoji;
|
|
12
|
+
action;
|
|
6
13
|
constructor(traceId, chatInfo, messageId, emoji, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.react;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
14
|
this.chatInfo = chatInfo;
|
|
10
15
|
this.messageId = messageId;
|
|
11
16
|
this.emoji = emoji;
|
|
@@ -3,10 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TextMessage = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class TextMessage {
|
|
6
|
+
kind = response_1.BotResponseTypes.text;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
captures = [];
|
|
9
|
+
content;
|
|
10
|
+
chatInfo;
|
|
11
|
+
replyInfo;
|
|
12
|
+
traceId;
|
|
13
|
+
disableWebPreview;
|
|
14
|
+
shouldPin;
|
|
15
|
+
action;
|
|
6
16
|
constructor(text, chatInfo, traceId, action, replyInfo, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.text;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
|
-
this.captures = [];
|
|
10
17
|
this.content = text;
|
|
11
18
|
this.chatInfo = chatInfo;
|
|
12
19
|
this.replyInfo = replyInfo;
|
|
@@ -3,9 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.UnpinResponse = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class UnpinResponse {
|
|
6
|
+
kind = response_1.BotResponseTypes.unpin;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
messageId;
|
|
9
|
+
chatInfo;
|
|
10
|
+
traceId;
|
|
11
|
+
action;
|
|
6
12
|
constructor(messageId, chatInfo, traceId, action) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.unpin;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
13
|
this.messageId = messageId;
|
|
10
14
|
this.chatInfo = chatInfo;
|
|
11
15
|
this.traceId = traceId;
|
|
@@ -3,11 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VideoMessage = void 0;
|
|
4
4
|
const response_1 = require("../../types/response");
|
|
5
5
|
class VideoMessage {
|
|
6
|
+
kind = response_1.BotResponseTypes.video;
|
|
7
|
+
createdAt = Date.now();
|
|
8
|
+
captures = [];
|
|
9
|
+
content;
|
|
10
|
+
chatInfo;
|
|
11
|
+
replyInfo;
|
|
12
|
+
traceId;
|
|
13
|
+
disableWebPreview = false;
|
|
14
|
+
shouldPin;
|
|
15
|
+
action;
|
|
6
16
|
constructor(video, chatInfo, traceId, action, replyInfo, options) {
|
|
7
|
-
this.kind = response_1.BotResponseTypes.video;
|
|
8
|
-
this.createdAt = Date.now();
|
|
9
|
-
this.captures = [];
|
|
10
|
-
this.disableWebPreview = false;
|
|
11
17
|
this.content = video;
|
|
12
18
|
this.chatInfo = chatInfo;
|
|
13
19
|
this.replyInfo = replyInfo;
|
|
@@ -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;AAI5D,qBAAa,aAAa,CAAC,YAAY,SAAS,YAAY,CACxD,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;gBAGhD,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY,EACpC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAgBxC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;IA+C5C,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,YAAY;
|
|
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;AAI5D,qBAAa,aAAa,CAAC,YAAY,SAAS,YAAY,CACxD,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;gBAGhD,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY,EACpC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAgBxC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;IA+C5C,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,YAAY;CAuCvB"}
|
|
@@ -11,6 +11,17 @@ const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResul
|
|
|
11
11
|
const noop_1 = require("../../helpers/noop");
|
|
12
12
|
const messageTypes_1 = require("../../types/messageTypes");
|
|
13
13
|
class CommandAction {
|
|
14
|
+
triggers;
|
|
15
|
+
handler;
|
|
16
|
+
name;
|
|
17
|
+
cooldownInSeconds;
|
|
18
|
+
active;
|
|
19
|
+
chatsBlacklist;
|
|
20
|
+
allowedUsers;
|
|
21
|
+
condition;
|
|
22
|
+
stateConstructor;
|
|
23
|
+
key;
|
|
24
|
+
readmeFactory;
|
|
14
25
|
constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor, readmeFactory) {
|
|
15
26
|
this.triggers = (0, toArray_1.toArray)(trigger);
|
|
16
27
|
this.handler = handler;
|
|
@@ -75,13 +86,15 @@ class CommandAction {
|
|
|
75
86
|
trigger.lastIndex = 0;
|
|
76
87
|
const execResult = trigger.exec(ctx.messageText);
|
|
77
88
|
if (execResult != null) {
|
|
89
|
+
let regexMatchLimit = 100;
|
|
78
90
|
matchResults.push(execResult);
|
|
79
91
|
if (trigger.global) {
|
|
80
|
-
while (
|
|
92
|
+
while (regexMatchLimit > 0) {
|
|
81
93
|
const nextResult = trigger.exec(ctx.messageText);
|
|
82
94
|
if (nextResult == null)
|
|
83
95
|
break;
|
|
84
96
|
matchResults.push(nextResult);
|
|
97
|
+
regexMatchLimit -= 1;
|
|
85
98
|
}
|
|
86
99
|
}
|
|
87
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,kBAAkB;CAuCrC"}
|
|
@@ -3,6 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.InlineQueryAction = void 0;
|
|
4
4
|
const noop_1 = require("../../helpers/noop");
|
|
5
5
|
class InlineQueryAction {
|
|
6
|
+
key;
|
|
7
|
+
active;
|
|
8
|
+
handler;
|
|
9
|
+
name;
|
|
10
|
+
pattern;
|
|
6
11
|
constructor(handler, name, active, pattern) {
|
|
7
12
|
this.handler = handler;
|
|
8
13
|
this.name = name;
|
|
@@ -19,13 +24,15 @@ class InlineQueryAction {
|
|
|
19
24
|
this.pattern.lastIndex = 0;
|
|
20
25
|
const execResult = this.pattern.exec(ctx.queryText);
|
|
21
26
|
if (execResult != null) {
|
|
27
|
+
let regexMatchLimit = 100;
|
|
22
28
|
matchResults.push(execResult);
|
|
23
29
|
if (this.pattern.global) {
|
|
24
|
-
while (
|
|
30
|
+
while (regexMatchLimit > 0) {
|
|
25
31
|
const nextResult = this.pattern.exec(ctx.queryText);
|
|
26
32
|
if (nextResult == null)
|
|
27
33
|
break;
|
|
28
34
|
matchResults.push(nextResult);
|
|
35
|
+
regexMatchLimit -= 1;
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/replyCaptureAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,kBAAkB,CAAC,kBAAkB,SAAS,YAAY,CACnE,YAAW,OAAO;IAElB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CACd,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAGtC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAClD,OAAO,EAAE,CACL,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,EAClB,QAAQ,EAAE,cAAc,EAAE,EAC1B,eAAe,EAAE,eAAe;IAY9B,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,kBAAkB,CAAC;IAyBhD,OAAO,CAAC,uBAAuB;
|
|
1
|
+
{"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/replyCaptureAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,kBAAkB,CAAC,kBAAkB,SAAS,YAAY,CACnE,YAAW,OAAO;IAElB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CACd,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAGtC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAClD,OAAO,EAAE,CACL,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,EAClB,QAAQ,EAAE,cAAc,EAAE,EAC1B,eAAe,EAAE,eAAe;IAY9B,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,kBAAkB,CAAC;IAyBhD,OAAO,CAAC,uBAAuB;CA0ClC"}
|
|
@@ -4,6 +4,11 @@ exports.ReplyCaptureAction = void 0;
|
|
|
4
4
|
const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResult");
|
|
5
5
|
const noop_1 = require("../../helpers/noop");
|
|
6
6
|
class ReplyCaptureAction {
|
|
7
|
+
parentMessageId;
|
|
8
|
+
key;
|
|
9
|
+
handler;
|
|
10
|
+
triggers;
|
|
11
|
+
abortController;
|
|
7
12
|
constructor(parentMessageId, parentAction, handler, triggers, abortController) {
|
|
8
13
|
this.parentMessageId = parentMessageId;
|
|
9
14
|
this.handler = handler;
|
|
@@ -40,13 +45,15 @@ class ReplyCaptureAction {
|
|
|
40
45
|
trigger.lastIndex = 0;
|
|
41
46
|
const execResult = trigger.exec(ctx.messageText);
|
|
42
47
|
if (execResult != null) {
|
|
48
|
+
let regexMatchLimit = 100;
|
|
43
49
|
matchResults.push(execResult);
|
|
44
50
|
if (trigger.global) {
|
|
45
|
-
while (
|
|
51
|
+
while (regexMatchLimit > 0) {
|
|
46
52
|
const nextResult = trigger.exec(ctx.messageText);
|
|
47
53
|
if (nextResult == null)
|
|
48
54
|
break;
|
|
49
55
|
matchResults.push(nextResult);
|
|
56
|
+
regexMatchLimit -= 1;
|
|
50
57
|
}
|
|
51
58
|
}
|
|
52
59
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,qBAAa,eAAe,CAAC,YAAY,SAAS,YAAY,CAC1D,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAgC;IAErD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG7C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACvC,WAAW,EAAE,UAAU,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAYlC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;YAuC3B,cAAc;IA4C5B,OAAO,CAAC,uBAAuB;CAalC"}
|
|
@@ -8,9 +8,19 @@ const moment_1 = __importDefault(require("moment"));
|
|
|
8
8
|
const async_sema_1 = require("async-sema");
|
|
9
9
|
const timeConvertions_1 = require("../../helpers/timeConvertions");
|
|
10
10
|
const noop_1 = require("../../helpers/noop");
|
|
11
|
+
const mapUtils_1 = require("../../helpers/mapUtils");
|
|
11
12
|
class ScheduledAction {
|
|
13
|
+
static locks = new Map();
|
|
14
|
+
name;
|
|
15
|
+
timeinHours;
|
|
16
|
+
active;
|
|
17
|
+
chatsWhitelist;
|
|
18
|
+
key;
|
|
19
|
+
cachedState = new Map();
|
|
20
|
+
stateConstructor;
|
|
21
|
+
cachedStateFactories;
|
|
22
|
+
handler;
|
|
12
23
|
constructor(name, handler, timeinHours, active, whitelist, cachedStateFactories, stateConstructor) {
|
|
13
|
-
this.cachedState = new Map();
|
|
14
24
|
this.name = name;
|
|
15
25
|
this.handler = handler;
|
|
16
26
|
this.timeinHours = timeinHours;
|
|
@@ -36,24 +46,14 @@ class ScheduledAction {
|
|
|
36
46
|
return ctx.responses;
|
|
37
47
|
}
|
|
38
48
|
async getCachedValue(key, botName, scheduler) {
|
|
39
|
-
|
|
40
|
-
throw new Error(`No shared cache was set up for the key [${key}] in action '${this.name}'`);
|
|
41
|
-
}
|
|
49
|
+
const cachedItemFactory = (0, mapUtils_1.getOrThrow)(this.cachedStateFactories, key, `No shared cache was set up for the key [${key}] in action '${this.name}'`);
|
|
42
50
|
const semaphoreKey = `${this.key}_cached:${key}`;
|
|
43
|
-
|
|
44
|
-
if (ScheduledAction.locks.has(semaphoreKey)) {
|
|
45
|
-
semaphore = ScheduledAction.locks.get(semaphoreKey);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
semaphore = new async_sema_1.Sema(1);
|
|
49
|
-
ScheduledAction.locks.set(semaphoreKey, semaphore);
|
|
50
|
-
}
|
|
51
|
+
const semaphore = (0, mapUtils_1.getOrSetIfNotExists)(ScheduledAction.locks, semaphoreKey, new async_sema_1.Sema(1));
|
|
51
52
|
await semaphore.acquire();
|
|
52
53
|
try {
|
|
53
54
|
if (this.cachedState.has(key)) {
|
|
54
55
|
return this.cachedState.get(key);
|
|
55
56
|
}
|
|
56
|
-
const cachedItemFactory = this.cachedStateFactories.get(key);
|
|
57
57
|
const value = await cachedItemFactory.getValue();
|
|
58
58
|
this.cachedState.set(key, value);
|
|
59
59
|
scheduler.createOnetimeTask(`Drop cached value [${this.name} : ${key}]`, () => this.cachedState.delete(key), (0, timeConvertions_1.hoursToMilliseconds)(cachedItemFactory.invalidationTimeoutInHours), botName);
|
|
@@ -76,4 +76,3 @@ class ScheduledAction {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
exports.ScheduledAction = ScheduledAction;
|
|
79
|
-
ScheduledAction.locks = new Map();
|
|
@@ -7,6 +7,11 @@ const nodeTimeoutScheduler_1 = require("../services/nodeTimeoutScheduler");
|
|
|
7
7
|
const traceFactory_1 = require("../helpers/traceFactory");
|
|
8
8
|
const actionProcessingService_1 = require("../services/actionProcessingService");
|
|
9
9
|
class BotInstance {
|
|
10
|
+
storage;
|
|
11
|
+
scheduler;
|
|
12
|
+
logger;
|
|
13
|
+
actionProcessingService;
|
|
14
|
+
name;
|
|
10
15
|
constructor(options) {
|
|
11
16
|
const actions = [
|
|
12
17
|
...options.actions.commands,
|
|
@@ -23,8 +28,8 @@ class BotInstance {
|
|
|
23
28
|
this.actionProcessingService = new actionProcessingService_1.ActionProcessingService(this.name, options.chats, this.storage, this.scheduler, this.logger);
|
|
24
29
|
}
|
|
25
30
|
async start(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage) {
|
|
26
|
-
this.actionProcessingService.initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage);
|
|
27
31
|
this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Start'), 'System', 'Starting bot...');
|
|
32
|
+
await this.actionProcessingService.initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage);
|
|
28
33
|
}
|
|
29
34
|
async stop(code) {
|
|
30
35
|
this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Stop'), 'System', 'Stopping bot...');
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CachedStateFactory = void 0;
|
|
4
4
|
class CachedStateFactory {
|
|
5
|
+
getValue;
|
|
6
|
+
invalidationTimeoutInHours;
|
|
5
7
|
constructor(itemFactory, invalidationTimeout) {
|
|
6
8
|
this.getValue = itemFactory;
|
|
7
9
|
this.invalidationTimeoutInHours = invalidationTimeout;
|
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BaseContext = void 0;
|
|
4
4
|
class BaseContext {
|
|
5
|
+
isInitialized = false;
|
|
6
|
+
_responses = [];
|
|
7
|
+
action;
|
|
8
|
+
/** Storage client instance for the bot executing this action. */
|
|
9
|
+
storage;
|
|
10
|
+
/** Scheduler instance for the bot executing this action */
|
|
11
|
+
scheduler;
|
|
12
|
+
logger;
|
|
13
|
+
/** Trace id of a action execution. */
|
|
14
|
+
traceId;
|
|
15
|
+
/** Name of a bot that executes this action. */
|
|
16
|
+
botName;
|
|
17
|
+
/** Chat information. */
|
|
18
|
+
chatInfo;
|
|
5
19
|
/** Ordered collection of responses to be processed */
|
|
6
20
|
get responses() {
|
|
7
21
|
return this._responses;
|
|
@@ -10,8 +24,6 @@ class BaseContext {
|
|
|
10
24
|
this._responses = value;
|
|
11
25
|
}
|
|
12
26
|
constructor(storage, scheduler) {
|
|
13
|
-
this.isInitialized = false;
|
|
14
|
-
this._responses = [];
|
|
15
27
|
this.storage = storage;
|
|
16
28
|
this.scheduler = scheduler;
|
|
17
29
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { IStorageClient } from '../../types/storage';
|
|
2
1
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
2
|
import { IActionWithState } from '../../types/action';
|
|
4
3
|
import { IActionState } from '../../types/actionState';
|
|
5
4
|
import { IReplyResponse } from '../../types/response';
|
|
6
5
|
import { Milliseconds } from '../../types/timeValues';
|
|
7
|
-
import { IScheduler } from '../../types/scheduler';
|
|
8
6
|
import { ICaptureController } from '../../types/capture';
|
|
9
7
|
import { BaseContext } from './baseContext';
|
|
10
8
|
import { ScheduledAction } from '../actions/scheduledAction';
|
|
@@ -12,7 +10,6 @@ import { ScheduledAction } from '../actions/scheduledAction';
|
|
|
12
10
|
* Context of action executed in chat.
|
|
13
11
|
*/
|
|
14
12
|
export declare class ChatContext<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> extends BaseContext<TAction> {
|
|
15
|
-
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
16
13
|
protected createCaptureController(response: IReplyResponse): ICaptureController;
|
|
17
14
|
/**
|
|
18
15
|
* Collection of actions that send something to chat as a standalone message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D;;GAEG;AACH,qBAAa,WAAW,CACpB,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,CAChF,SAAQ,WAAW,CAAC,OAAO,CAAC;IAC1B,SAAS,CAAC,uBAAuB,CAC7B,QAAQ,EAAE,cAAc,GACzB,kBAAkB;IAmBrB;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAexD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;QAerD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;MAcvD;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAK3B"}
|
|
@@ -12,47 +12,6 @@ const baseContext_1 = require("./baseContext");
|
|
|
12
12
|
* Context of action executed in chat.
|
|
13
13
|
*/
|
|
14
14
|
class ChatContext extends baseContext_1.BaseContext {
|
|
15
|
-
constructor(storage, scheduler) {
|
|
16
|
-
super(storage, scheduler);
|
|
17
|
-
/**
|
|
18
|
-
* Collection of actions that send something to chat as a standalone message.
|
|
19
|
-
*/
|
|
20
|
-
this.send = {
|
|
21
|
-
/**
|
|
22
|
-
* Sends text message to chat after action execution is finished.
|
|
23
|
-
* 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.
|
|
24
|
-
* @param text Message contents.
|
|
25
|
-
* @param options Message sending option.
|
|
26
|
-
*/
|
|
27
|
-
text: (text, options) => {
|
|
28
|
-
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
29
|
-
this.responses.push(response);
|
|
30
|
-
return this.createCaptureController(response);
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Sends image message to chat after action execution is finished.
|
|
34
|
-
* 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.
|
|
35
|
-
* @param name Message contents.
|
|
36
|
-
* @param options Message sending option.
|
|
37
|
-
*/
|
|
38
|
-
image: (name, options) => {
|
|
39
|
-
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
40
|
-
this.responses.push(response);
|
|
41
|
-
return this.createCaptureController(response);
|
|
42
|
-
},
|
|
43
|
-
/**
|
|
44
|
-
* Sends video/gif message to chat after action execution is finished.
|
|
45
|
-
* 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.
|
|
46
|
-
* @param name Message contents.
|
|
47
|
-
* @param options Message sending option.
|
|
48
|
-
*/
|
|
49
|
-
video: (name, options) => {
|
|
50
|
-
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
51
|
-
this.responses.push(response);
|
|
52
|
-
return this.createCaptureController(response);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
15
|
createCaptureController(response) {
|
|
57
16
|
return {
|
|
58
17
|
captureReplies: (trigger, handler, abortController) => {
|
|
@@ -65,6 +24,44 @@ class ChatContext extends baseContext_1.BaseContext {
|
|
|
65
24
|
}
|
|
66
25
|
};
|
|
67
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Collection of actions that send something to chat as a standalone message.
|
|
29
|
+
*/
|
|
30
|
+
send = {
|
|
31
|
+
/**
|
|
32
|
+
* Sends text message to chat 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
|
+
text: (text, options) => {
|
|
38
|
+
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
39
|
+
this.responses.push(response);
|
|
40
|
+
return this.createCaptureController(response);
|
|
41
|
+
},
|
|
42
|
+
/**
|
|
43
|
+
* Sends image message to chat after action execution is finished.
|
|
44
|
+
* 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.
|
|
45
|
+
* @param name Message contents.
|
|
46
|
+
* @param options Message sending option.
|
|
47
|
+
*/
|
|
48
|
+
image: (name, options) => {
|
|
49
|
+
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
50
|
+
this.responses.push(response);
|
|
51
|
+
return this.createCaptureController(response);
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Sends video/gif message to chat 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 name Message contents.
|
|
57
|
+
* @param options Message sending option.
|
|
58
|
+
*/
|
|
59
|
+
video: (name, options) => {
|
|
60
|
+
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
61
|
+
this.responses.push(response);
|
|
62
|
+
return this.createCaptureController(response);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
68
65
|
/**
|
|
69
66
|
* Unpins message after action execution is finished.
|
|
70
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.
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { InlineQueryResult } from 'telegraf/types';
|
|
2
2
|
import { BotResponse } from '../../types/response';
|
|
3
|
-
import { IScheduler } from '../../types/scheduler';
|
|
4
|
-
import { IStorageClient } from '../../types/storage';
|
|
5
3
|
import { InlineQueryAction } from '../actions/inlineQueryAction';
|
|
6
4
|
import { BaseContext } from './baseContext';
|
|
7
5
|
export declare class InlineQueryContext extends BaseContext<InlineQueryAction> {
|
|
@@ -19,7 +17,6 @@ export declare class InlineQueryContext extends BaseContext<InlineQueryAction> {
|
|
|
19
17
|
queryId: string;
|
|
20
18
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
21
19
|
matchResults: RegExpMatchArray[];
|
|
22
|
-
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
23
20
|
/**
|
|
24
21
|
* This result will be shown to user as a response to inline query.
|
|
25
22
|
* @param queryResult Inline query result to be shown to user.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,qBAAa,kBAAmB,SAAQ,WAAW,CAAC,iBAAiB,CAAC;IAClE,YAAY,EAAE,iBAAiB,EAAE,CAAM;IACvC;;;OAGG;IACH,WAAW,EAAG,WAAW,CAAC;IAE1B,uDAAuD;IACvD,IAAI,SAAS,IAAI,WAAW,EAAE,CAS7B;IACD,wBAAwB;IACxB,SAAS,EAAG,MAAM,CAAC;IACnB,wBAAwB;IACxB,OAAO,EAAG,MAAM,CAAC;IACjB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IAEtC;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,iBAAiB;CAGvD"}
|
|
@@ -4,18 +4,24 @@ exports.InlineQueryContext = void 0;
|
|
|
4
4
|
const inlineQueryResponse_1 = require("../../dtos/responses/inlineQueryResponse");
|
|
5
5
|
const baseContext_1 = require("./baseContext");
|
|
6
6
|
class InlineQueryContext extends baseContext_1.BaseContext {
|
|
7
|
+
queryResults = [];
|
|
8
|
+
/**
|
|
9
|
+
* Abort signal to be utilized in query handler.
|
|
10
|
+
* Signal will be aborted if new query comes from the same user.
|
|
11
|
+
*/
|
|
12
|
+
abortSignal;
|
|
7
13
|
/** Ordered collection of responses to be processed */
|
|
8
14
|
get responses() {
|
|
9
15
|
return [
|
|
10
16
|
new inlineQueryResponse_1.InlineQueryResponse(this.queryResults, this.queryId, this.traceId, this.action)
|
|
11
17
|
];
|
|
12
18
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
/** Inline query text */
|
|
20
|
+
queryText;
|
|
21
|
+
/** Internal query id */
|
|
22
|
+
queryId;
|
|
23
|
+
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
24
|
+
matchResults = [];
|
|
19
25
|
/**
|
|
20
26
|
* This result will be shown to user as a response to inline query.
|
|
21
27
|
* @param queryResult Inline query result to be shown to user.
|