chz-telegram-bot 0.3.4 → 0.3.6
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/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.js +2 -0
- package/dist/entities/context/messageContext.d.ts +4 -3
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +13 -12
- package/dist/entities/context/replyContext.d.ts +4 -3
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +13 -12
- package/dist/helpers/objectFromEntries.d.ts +2 -0
- package/dist/helpers/objectFromEntries.d.ts.map +1 -0
- package/dist/helpers/objectFromEntries.js +7 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +5 -16
- package/dist/types/messageTypes.d.ts +1 -0
- package/dist/types/messageTypes.d.ts.map +1 -1
- package/dist/types/messageTypes.js +1 -0
- package/dtos/incomingMessage.ts +1 -0
- package/entities/context/messageContext.ts +29 -21
- package/entities/context/replyContext.ts +29 -21
- package/helpers/objectFromEntries.ts +7 -0
- package/package.json +1 -1
- package/services/actionProcessors/commandActionProcessor.ts +8 -19
- package/types/messageTypes.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../dtos/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAEH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,eAAe;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,Q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text' in message)
|
|
13
13
|
return messageTypes_1.MessageType.Text;
|
|
14
|
+
if ('video' in message)
|
|
15
|
+
return messageTypes_1.MessageType.Video;
|
|
14
16
|
if ('photo' in message)
|
|
15
17
|
return messageTypes_1.MessageType.Photo;
|
|
16
18
|
if ('sticker' in message)
|
|
@@ -26,6 +26,7 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
26
26
|
/** Message object recieved from Telegram */
|
|
27
27
|
messageUpdateObject: TelegrafContextMessage;
|
|
28
28
|
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
29
|
+
private getQuotePart;
|
|
29
30
|
private replyWithText;
|
|
30
31
|
private replyWithImage;
|
|
31
32
|
private replyWithVideo;
|
|
@@ -44,21 +45,21 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
44
45
|
* @param text Message contents.
|
|
45
46
|
* @param options Message sending option.
|
|
46
47
|
*/
|
|
47
|
-
withText: (text: string, options?: TextMessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
48
|
+
withText: (text: string, quote?: string, options?: TextMessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
48
49
|
/**
|
|
49
50
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
50
51
|
* 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.
|
|
51
52
|
* @param text Message contents.
|
|
52
53
|
* @param options Message sending option.
|
|
53
54
|
*/
|
|
54
|
-
withImage: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
55
|
+
withImage: (name: string, quote?: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
55
56
|
/**
|
|
56
57
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
57
58
|
* 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.
|
|
58
59
|
* @param text Message contents.
|
|
59
60
|
* @param options Message sending option.
|
|
60
61
|
*/
|
|
61
|
-
withVideo: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
62
|
+
withVideo: (name: string, quote?: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
62
63
|
};
|
|
63
64
|
/**
|
|
64
65
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -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,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,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;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;GAEG;AACH,qBAAa,cAAc,CACvB,YAAY,SAAS,YAAY,CACnC,SAAQ,WAAW,CAAC,YAAY,CAAC;IAC/B,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;gBAEjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAI1D,OAAO,CAAC,aAAa;
|
|
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AAM,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"}
|
|
@@ -33,21 +33,21 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
33
33
|
* @param text Message contents.
|
|
34
34
|
* @param options Message sending option.
|
|
35
35
|
*/
|
|
36
|
-
withText: (text, options) => this.replyWithText(text, true, options),
|
|
36
|
+
withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
|
|
37
37
|
/**
|
|
38
38
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
39
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
40
|
* @param text Message contents.
|
|
41
41
|
* @param options Message sending option.
|
|
42
42
|
*/
|
|
43
|
-
withImage: (name, options) => this.replyWithImage(name, true, options),
|
|
43
|
+
withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
|
|
44
44
|
/**
|
|
45
45
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
46
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
47
|
* @param text Message contents.
|
|
48
48
|
* @param options Message sending option.
|
|
49
49
|
*/
|
|
50
|
-
withVideo: (name, options) => this.replyWithVideo(name, true, options)
|
|
50
|
+
withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
|
|
51
51
|
},
|
|
52
52
|
/**
|
|
53
53
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -80,26 +80,27 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
80
80
|
}
|
|
81
81
|
};
|
|
82
82
|
}
|
|
83
|
+
getQuotePart(quote) {
|
|
84
|
+
return typeof quote == 'boolean'
|
|
85
|
+
? this.matchResults.length != 0
|
|
86
|
+
? this.matchResults[0][1]
|
|
87
|
+
: this.messageText
|
|
88
|
+
: quote;
|
|
89
|
+
}
|
|
83
90
|
replyWithText(text, quote, options) {
|
|
84
|
-
const quotedPart = this.
|
|
85
|
-
? this.matchResults[0][1]
|
|
86
|
-
: this.messageText;
|
|
91
|
+
const quotedPart = this.getQuotePart(quote);
|
|
87
92
|
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
88
93
|
this.responses.push(response);
|
|
89
94
|
return this.createCaptureController(response);
|
|
90
95
|
}
|
|
91
96
|
replyWithImage(name, quote, options) {
|
|
92
|
-
const quotedPart = this.
|
|
93
|
-
? this.matchResults[0][1]
|
|
94
|
-
: this.messageText;
|
|
97
|
+
const quotedPart = this.getQuotePart(quote);
|
|
95
98
|
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
96
99
|
this.responses.push(response);
|
|
97
100
|
return this.createCaptureController(response);
|
|
98
101
|
}
|
|
99
102
|
replyWithVideo(name, quote, options) {
|
|
100
|
-
const quotedPart = this.
|
|
101
|
-
? this.matchResults[0][1]
|
|
102
|
-
: this.messageText;
|
|
103
|
+
const quotedPart = this.getQuotePart(quote);
|
|
103
104
|
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
104
105
|
this.responses.push(response);
|
|
105
106
|
return this.createCaptureController(response);
|
|
@@ -43,6 +43,7 @@ export declare class ReplyContext<TParentActionState extends IActionState> {
|
|
|
43
43
|
messageUpdateObject: TelegrafContextMessage;
|
|
44
44
|
isInitialized: boolean;
|
|
45
45
|
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
46
|
+
private getQuotePart;
|
|
46
47
|
private replyWithText;
|
|
47
48
|
private replyWithImage;
|
|
48
49
|
private replyWithVideo;
|
|
@@ -65,21 +66,21 @@ export declare class ReplyContext<TParentActionState extends IActionState> {
|
|
|
65
66
|
* @param text Message contents.
|
|
66
67
|
* @param options Message sending option.
|
|
67
68
|
*/
|
|
68
|
-
withText: (text: string, options?: TextMessageSendingOptions) => void;
|
|
69
|
+
withText: (text: string, quote?: string, options?: TextMessageSendingOptions) => void;
|
|
69
70
|
/**
|
|
70
71
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
71
72
|
* 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
73
|
* @param text Message contents.
|
|
73
74
|
* @param options Message sending option.
|
|
74
75
|
*/
|
|
75
|
-
withImage: (name: string, options?: MessageSendingOptions) => void;
|
|
76
|
+
withImage: (name: string, quote?: string, options?: MessageSendingOptions) => void;
|
|
76
77
|
/**
|
|
77
78
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
78
79
|
* 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.
|
|
79
80
|
* @param text Message contents.
|
|
80
81
|
* @param options Message sending option.
|
|
81
82
|
*/
|
|
82
|
-
withVideo: (name: string, options?: MessageSendingOptions) => void;
|
|
83
|
+
withVideo: (name: string, quote?: string, options?: MessageSendingOptions) => void;
|
|
83
84
|
};
|
|
84
85
|
/**
|
|
85
86
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -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;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAq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M,EAAG,aAAa,CAAC;IAEvB,uDAAuD;IACvD,SAAS,EAAE,WAAW,EAAE,CAAM;IAC9B,wBAAwB;IACxB,QAAQ,EAAG,QAAQ,CAAC;IACpB,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;gBAEV,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAK1D,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;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"}
|
|
@@ -27,21 +27,21 @@ class ReplyContext {
|
|
|
27
27
|
* @param text Message contents.
|
|
28
28
|
* @param options Message sending option.
|
|
29
29
|
*/
|
|
30
|
-
withText: (text, options) => this.replyWithText(text, true, options),
|
|
30
|
+
withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
|
|
31
31
|
/**
|
|
32
32
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
33
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
34
|
* @param text Message contents.
|
|
35
35
|
* @param options Message sending option.
|
|
36
36
|
*/
|
|
37
|
-
withImage: (name, options) => this.replyWithImage(name, true, options),
|
|
37
|
+
withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
|
|
38
38
|
/**
|
|
39
39
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
40
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
41
|
* @param text Message contents.
|
|
42
42
|
* @param options Message sending option.
|
|
43
43
|
*/
|
|
44
|
-
withVideo: (name, options) => this.replyWithVideo(name, true, options)
|
|
44
|
+
withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
|
|
45
45
|
},
|
|
46
46
|
/**
|
|
47
47
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -76,24 +76,25 @@ class ReplyContext {
|
|
|
76
76
|
this.storage = storage;
|
|
77
77
|
this.scheduler = scheduler;
|
|
78
78
|
}
|
|
79
|
+
getQuotePart(quote) {
|
|
80
|
+
return typeof quote == 'boolean'
|
|
81
|
+
? this.matchResults.length != 0
|
|
82
|
+
? this.matchResults[0][1]
|
|
83
|
+
: this.messageText
|
|
84
|
+
: quote;
|
|
85
|
+
}
|
|
79
86
|
replyWithText(text, quote, options) {
|
|
80
|
-
const quotedPart = this.
|
|
81
|
-
? this.matchResults[0][1]
|
|
82
|
-
: this.messageText;
|
|
87
|
+
const quotedPart = this.getQuotePart(quote);
|
|
83
88
|
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
84
89
|
this.responses.push(response);
|
|
85
90
|
}
|
|
86
91
|
replyWithImage(name, quote, options) {
|
|
87
|
-
const quotedPart = this.
|
|
88
|
-
? this.matchResults[0][1]
|
|
89
|
-
: this.messageText;
|
|
92
|
+
const quotedPart = this.getQuotePart(quote);
|
|
90
93
|
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
91
94
|
this.responses.push(response);
|
|
92
95
|
}
|
|
93
96
|
replyWithVideo(name, quote, options) {
|
|
94
|
-
const quotedPart = this.
|
|
95
|
-
? this.matchResults[0][1]
|
|
96
|
-
: this.messageText;
|
|
97
|
+
const quotedPart = this.getQuotePart(quote);
|
|
97
98
|
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
98
99
|
this.responses.push(response);
|
|
99
100
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objectFromEntries.d.ts","sourceRoot":"","sources":["../../helpers/objectFromEntries.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,GAClC,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,EAE9D,SAAS,CAAC,KACX,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAElC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.typeSafeObjectFromEntries = void 0;
|
|
4
|
+
const typeSafeObjectFromEntries = (entries) => {
|
|
5
|
+
return Object.fromEntries(entries);
|
|
6
|
+
};
|
|
7
|
+
exports.typeSafeObjectFromEntries = typeSafeObjectFromEntries;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/commandActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAKrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAO/C,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAa;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IAEnE,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,QAAQ,
|
|
1
|
+
{"version":3,"file":"commandActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/commandActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CA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../../entities/actions/replyCaptureAction"
|
|
|
6
6
|
const messageContext_1 = require("../../entities/context/messageContext");
|
|
7
7
|
const replyContext_1 = require("../../entities/context/replyContext");
|
|
8
8
|
const messageTypes_1 = require("../../types/messageTypes");
|
|
9
|
+
const objectFromEntries_1 = require("../../helpers/objectFromEntries");
|
|
9
10
|
class CommandActionProcessor {
|
|
10
11
|
constructor(botName, storage, scheduler, logger) {
|
|
11
|
-
this.commands =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'__msg:Animation': [],
|
|
16
|
-
'__msg:Document': [],
|
|
17
|
-
'__msg:Voice': [],
|
|
18
|
-
'__msg:Audio': [],
|
|
19
|
-
'__msg:LeftChatMember': [],
|
|
20
|
-
'__msg:NewChatMember': [],
|
|
21
|
-
'__msg:Poll': [],
|
|
22
|
-
'__msg:Location': [],
|
|
23
|
-
'__msg:Photo': [],
|
|
24
|
-
'__msg:Forward': [],
|
|
25
|
-
'__msg:Unknown': []
|
|
26
|
-
};
|
|
12
|
+
this.commands = (0, objectFromEntries_1.typeSafeObjectFromEntries)(Object.values(messageTypes_1.MessageType).map((x) => [
|
|
13
|
+
x,
|
|
14
|
+
[]
|
|
15
|
+
]));
|
|
27
16
|
this.storage = storage;
|
|
28
17
|
this.scheduler = scheduler;
|
|
29
18
|
this.logger = logger;
|
|
@@ -14,6 +14,7 @@ export declare const MessageType: {
|
|
|
14
14
|
readonly Location: "__msg:Location";
|
|
15
15
|
readonly Photo: "__msg:Photo";
|
|
16
16
|
readonly Forward: "__msg:Forward";
|
|
17
|
+
readonly Video: "__msg:Video";
|
|
17
18
|
readonly Unknown: "__msg:Unknown";
|
|
18
19
|
};
|
|
19
20
|
export type MessageTypeValue = (typeof MessageType)[keyof typeof MessageType];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../types/messageTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD,eAAO,MAAM,WAAW
|
|
1
|
+
{"version":3,"file":"messageTypes.d.ts","sourceRoot":"","sources":["../../types/messageTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEjD,eAAO,MAAM,4BAA4B,WAAW,CAAC;AAErD,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;CAgBd,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,WAAW,CAAC,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE9E,MAAM,MAAM,sBAAsB,GAAG,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC"}
|
|
@@ -16,5 +16,6 @@ exports.MessageType = {
|
|
|
16
16
|
Location: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Location`,
|
|
17
17
|
Photo: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Photo`,
|
|
18
18
|
Forward: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Forward`,
|
|
19
|
+
Video: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Video`,
|
|
19
20
|
Unknown: `${exports.INTERNAL_MESSAGE_TYPE_PREFIX}Unknown`
|
|
20
21
|
};
|
package/dtos/incomingMessage.ts
CHANGED
|
@@ -25,6 +25,7 @@ export class IncomingMessage {
|
|
|
25
25
|
) {
|
|
26
26
|
if ('forward_origin' in message) return MessageType.Forward;
|
|
27
27
|
if ('text' in message) return MessageType.Text;
|
|
28
|
+
if ('video' in message) return MessageType.Video;
|
|
28
29
|
if ('photo' in message) return MessageType.Photo;
|
|
29
30
|
if ('sticker' in message) return MessageType.Sticker;
|
|
30
31
|
if ('animation' in message) return MessageType.Animation;
|
|
@@ -45,15 +45,20 @@ export class MessageContext<
|
|
|
45
45
|
super(storage, scheduler);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
+
private getQuotePart(quote: boolean | string) {
|
|
49
|
+
return typeof quote == 'boolean'
|
|
50
|
+
? this.matchResults.length != 0
|
|
51
|
+
? this.matchResults[0][1]
|
|
52
|
+
: this.messageText
|
|
53
|
+
: quote;
|
|
54
|
+
}
|
|
55
|
+
|
|
48
56
|
private replyWithText(
|
|
49
57
|
text: string,
|
|
50
|
-
quote: boolean,
|
|
58
|
+
quote: boolean | string,
|
|
51
59
|
options?: TextMessageSendingOptions
|
|
52
60
|
) {
|
|
53
|
-
const quotedPart =
|
|
54
|
-
this.matchResults.length != 0
|
|
55
|
-
? this.matchResults[0][1]
|
|
56
|
-
: this.messageText;
|
|
61
|
+
const quotedPart = this.getQuotePart(quote);
|
|
57
62
|
|
|
58
63
|
const response = new TextMessage(
|
|
59
64
|
text,
|
|
@@ -71,13 +76,10 @@ export class MessageContext<
|
|
|
71
76
|
|
|
72
77
|
private replyWithImage(
|
|
73
78
|
name: string,
|
|
74
|
-
quote: boolean,
|
|
79
|
+
quote: boolean | string,
|
|
75
80
|
options?: MessageSendingOptions
|
|
76
81
|
) {
|
|
77
|
-
const quotedPart =
|
|
78
|
-
this.matchResults.length != 0
|
|
79
|
-
? this.matchResults[0][1]
|
|
80
|
-
: this.messageText;
|
|
82
|
+
const quotedPart = this.getQuotePart(quote);
|
|
81
83
|
|
|
82
84
|
const response = new ImageMessage(
|
|
83
85
|
{ source: resolve(`./content/${name}.png`) },
|
|
@@ -95,13 +97,10 @@ export class MessageContext<
|
|
|
95
97
|
|
|
96
98
|
private replyWithVideo(
|
|
97
99
|
name: string,
|
|
98
|
-
quote: boolean,
|
|
100
|
+
quote: boolean | string,
|
|
99
101
|
options?: MessageSendingOptions
|
|
100
102
|
) {
|
|
101
|
-
const quotedPart =
|
|
102
|
-
this.matchResults.length != 0
|
|
103
|
-
? this.matchResults[0][1]
|
|
104
|
-
: this.messageText;
|
|
103
|
+
const quotedPart = this.getQuotePart(quote);
|
|
105
104
|
|
|
106
105
|
const response = new VideoMessage(
|
|
107
106
|
{ source: resolve(`./content/${name}.mp4`) },
|
|
@@ -132,16 +131,22 @@ export class MessageContext<
|
|
|
132
131
|
* @param text Message contents.
|
|
133
132
|
* @param options Message sending option.
|
|
134
133
|
*/
|
|
135
|
-
withText: (
|
|
136
|
-
|
|
134
|
+
withText: (
|
|
135
|
+
text: string,
|
|
136
|
+
quote?: string,
|
|
137
|
+
options?: TextMessageSendingOptions
|
|
138
|
+
) => this.replyWithText(text, quote ?? true, options),
|
|
137
139
|
/**
|
|
138
140
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
139
141
|
* 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.
|
|
140
142
|
* @param text Message contents.
|
|
141
143
|
* @param options Message sending option.
|
|
142
144
|
*/
|
|
143
|
-
withImage: (
|
|
144
|
-
|
|
145
|
+
withImage: (
|
|
146
|
+
name: string,
|
|
147
|
+
quote?: string,
|
|
148
|
+
options?: MessageSendingOptions
|
|
149
|
+
) => this.replyWithImage(name, quote ?? true, options),
|
|
145
150
|
|
|
146
151
|
/**
|
|
147
152
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
@@ -149,8 +154,11 @@ export class MessageContext<
|
|
|
149
154
|
* @param text Message contents.
|
|
150
155
|
* @param options Message sending option.
|
|
151
156
|
*/
|
|
152
|
-
withVideo: (
|
|
153
|
-
|
|
157
|
+
withVideo: (
|
|
158
|
+
name: string,
|
|
159
|
+
quote?: string,
|
|
160
|
+
options?: MessageSendingOptions
|
|
161
|
+
) => this.replyWithVideo(name, quote ?? true, options)
|
|
154
162
|
},
|
|
155
163
|
|
|
156
164
|
/**
|
|
@@ -65,15 +65,20 @@ export class ReplyContext<TParentActionState extends IActionState> {
|
|
|
65
65
|
this.scheduler = scheduler;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
private getQuotePart(quote: boolean | string) {
|
|
69
|
+
return typeof quote == 'boolean'
|
|
70
|
+
? this.matchResults.length != 0
|
|
71
|
+
? this.matchResults[0][1]
|
|
72
|
+
: this.messageText
|
|
73
|
+
: quote;
|
|
74
|
+
}
|
|
75
|
+
|
|
68
76
|
private replyWithText(
|
|
69
77
|
text: string,
|
|
70
|
-
quote: boolean,
|
|
78
|
+
quote: boolean | string,
|
|
71
79
|
options?: TextMessageSendingOptions
|
|
72
80
|
) {
|
|
73
|
-
const quotedPart =
|
|
74
|
-
this.matchResults.length != 0
|
|
75
|
-
? this.matchResults[0][1]
|
|
76
|
-
: this.messageText;
|
|
81
|
+
const quotedPart = this.getQuotePart(quote);
|
|
77
82
|
|
|
78
83
|
const response = new TextMessage(
|
|
79
84
|
text,
|
|
@@ -89,13 +94,10 @@ export class ReplyContext<TParentActionState extends IActionState> {
|
|
|
89
94
|
|
|
90
95
|
private replyWithImage(
|
|
91
96
|
name: string,
|
|
92
|
-
quote: boolean,
|
|
97
|
+
quote: boolean | string,
|
|
93
98
|
options?: MessageSendingOptions
|
|
94
99
|
) {
|
|
95
|
-
const quotedPart =
|
|
96
|
-
this.matchResults.length != 0
|
|
97
|
-
? this.matchResults[0][1]
|
|
98
|
-
: this.messageText;
|
|
100
|
+
const quotedPart = this.getQuotePart(quote);
|
|
99
101
|
|
|
100
102
|
const response = new ImageMessage(
|
|
101
103
|
{ source: resolve(`./content/${name}.png`) },
|
|
@@ -111,13 +113,10 @@ export class ReplyContext<TParentActionState extends IActionState> {
|
|
|
111
113
|
|
|
112
114
|
private replyWithVideo(
|
|
113
115
|
name: string,
|
|
114
|
-
quote: boolean,
|
|
116
|
+
quote: boolean | string,
|
|
115
117
|
options?: MessageSendingOptions
|
|
116
118
|
) {
|
|
117
|
-
const quotedPart =
|
|
118
|
-
this.matchResults.length != 0
|
|
119
|
-
? this.matchResults[0][1]
|
|
120
|
-
: this.messageText;
|
|
119
|
+
const quotedPart = this.getQuotePart(quote);
|
|
121
120
|
|
|
122
121
|
const response = new VideoMessage(
|
|
123
122
|
{ source: resolve(`./content/${name}.mp4`) },
|
|
@@ -153,16 +152,22 @@ export class ReplyContext<TParentActionState extends IActionState> {
|
|
|
153
152
|
* @param text Message contents.
|
|
154
153
|
* @param options Message sending option.
|
|
155
154
|
*/
|
|
156
|
-
withText: (
|
|
157
|
-
|
|
155
|
+
withText: (
|
|
156
|
+
text: string,
|
|
157
|
+
quote?: string,
|
|
158
|
+
options?: TextMessageSendingOptions
|
|
159
|
+
) => this.replyWithText(text, quote ?? true, options),
|
|
158
160
|
/**
|
|
159
161
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
160
162
|
* 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.
|
|
161
163
|
* @param text Message contents.
|
|
162
164
|
* @param options Message sending option.
|
|
163
165
|
*/
|
|
164
|
-
withImage: (
|
|
165
|
-
|
|
166
|
+
withImage: (
|
|
167
|
+
name: string,
|
|
168
|
+
quote?: string,
|
|
169
|
+
options?: MessageSendingOptions
|
|
170
|
+
) => this.replyWithImage(name, quote ?? true, options),
|
|
166
171
|
|
|
167
172
|
/**
|
|
168
173
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
@@ -170,8 +175,11 @@ export class ReplyContext<TParentActionState extends IActionState> {
|
|
|
170
175
|
* @param text Message contents.
|
|
171
176
|
* @param options Message sending option.
|
|
172
177
|
*/
|
|
173
|
-
withVideo: (
|
|
174
|
-
|
|
178
|
+
withVideo: (
|
|
179
|
+
name: string,
|
|
180
|
+
quote?: string,
|
|
181
|
+
options?: MessageSendingOptions
|
|
182
|
+
) => this.replyWithVideo(name, quote ?? true, options)
|
|
175
183
|
},
|
|
176
184
|
|
|
177
185
|
/**
|
package/package.json
CHANGED
|
@@ -15,9 +15,9 @@ import { TraceId } from '../../types/trace';
|
|
|
15
15
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
16
16
|
import {
|
|
17
17
|
INTERNAL_MESSAGE_TYPE_PREFIX,
|
|
18
|
-
MessageType
|
|
19
|
-
MessageTypeValue
|
|
18
|
+
MessageType
|
|
20
19
|
} from '../../types/messageTypes';
|
|
20
|
+
import { typeSafeObjectFromEntries } from '../../helpers/objectFromEntries';
|
|
21
21
|
|
|
22
22
|
export class CommandActionProcessor {
|
|
23
23
|
private readonly storage: IStorageClient;
|
|
@@ -29,23 +29,12 @@ export class CommandActionProcessor {
|
|
|
29
29
|
|
|
30
30
|
private api!: TelegramApiService;
|
|
31
31
|
private telegraf!: Telegraf;
|
|
32
|
-
private commands
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
'__msg:Document': [],
|
|
39
|
-
'__msg:Voice': [],
|
|
40
|
-
'__msg:Audio': [],
|
|
41
|
-
'__msg:LeftChatMember': [],
|
|
42
|
-
'__msg:NewChatMember': [],
|
|
43
|
-
'__msg:Poll': [],
|
|
44
|
-
'__msg:Location': [],
|
|
45
|
-
'__msg:Photo': [],
|
|
46
|
-
'__msg:Forward': [],
|
|
47
|
-
'__msg:Unknown': []
|
|
48
|
-
};
|
|
32
|
+
private commands = typeSafeObjectFromEntries(
|
|
33
|
+
Object.values(MessageType).map((x) => [
|
|
34
|
+
x,
|
|
35
|
+
[] as CommandAction<IActionState>[]
|
|
36
|
+
])
|
|
37
|
+
);
|
|
49
38
|
|
|
50
39
|
constructor(
|
|
51
40
|
botName: string,
|
package/types/messageTypes.ts
CHANGED
|
@@ -16,6 +16,7 @@ export const MessageType = {
|
|
|
16
16
|
Location: `${INTERNAL_MESSAGE_TYPE_PREFIX}Location`,
|
|
17
17
|
Photo: `${INTERNAL_MESSAGE_TYPE_PREFIX}Photo`,
|
|
18
18
|
Forward: `${INTERNAL_MESSAGE_TYPE_PREFIX}Forward`,
|
|
19
|
+
Video: `${INTERNAL_MESSAGE_TYPE_PREFIX}Video`,
|
|
19
20
|
Unknown: `${INTERNAL_MESSAGE_TYPE_PREFIX}Unknown`
|
|
20
21
|
} as const;
|
|
21
22
|
|