chz-telegram-bot 0.1.20 → 0.2.1
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/bun.lock +307 -0
- package/dist/builtin/helpAction.js +1 -1
- package/dist/dtos/responses/imageMessage.d.ts +5 -4
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.js +2 -2
- package/dist/dtos/responses/textMessage.d.ts +5 -4
- package/dist/dtos/responses/textMessage.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.js +2 -2
- package/dist/dtos/responses/videoMessage.d.ts +5 -4
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.js +2 -2
- package/dist/entities/botInstance.d.ts +2 -0
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +23 -2
- package/dist/entities/context/chatContext.d.ts +25 -21
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +32 -38
- package/dist/entities/context/messageContext.d.ts +60 -28
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +79 -49
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +27 -11
- package/dist/types/replyInfo.d.ts +6 -0
- package/dist/types/replyInfo.d.ts.map +1 -0
- package/dist/types/replyInfo.js +10 -0
- package/dist/types/response.d.ts +3 -2
- package/dist/types/response.d.ts.map +1 -1
- package/dtos/responses/imageMessage.ts +6 -5
- package/dtos/responses/textMessage.ts +6 -5
- package/dtos/responses/videoMessage.ts +6 -5
- package/entities/botInstance.ts +44 -3
- package/entities/context/chatContext.ts +58 -72
- package/entities/context/messageContext.ts +133 -88
- package/package.json +30 -29
- package/services/telegramApi.ts +30 -14
- package/types/replyInfo.ts +9 -0
- package/types/response.ts +3 -2
|
@@ -12,7 +12,7 @@ import { TraceId } from '../../types/trace';
|
|
|
12
12
|
* Context of action executed in chat.
|
|
13
13
|
*/
|
|
14
14
|
export declare class ChatContext<TActionState extends IActionState> {
|
|
15
|
-
|
|
15
|
+
action: IActionWithState<TActionState>;
|
|
16
16
|
/** Storage client instance for the bot executing this action. */
|
|
17
17
|
readonly storage: IStorageClient;
|
|
18
18
|
/** Logger instance for the bot executing this action */
|
|
@@ -29,28 +29,32 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
29
29
|
responses: BotResponse[];
|
|
30
30
|
isInitialized: boolean;
|
|
31
31
|
constructor(storage: IStorageClient, logger: ILogger, scheduler: IScheduler);
|
|
32
|
-
initializeChatContext(botName: string, action: IActionWithState<TActionState>, chatInfo: ChatInfo, traceId: TraceId): this;
|
|
33
32
|
/**
|
|
34
|
-
*
|
|
35
|
-
* 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.
|
|
36
|
-
* @param text Message contents.
|
|
37
|
-
* @param options Message sending option.
|
|
38
|
-
*/
|
|
39
|
-
sendTextToChat(text: string, options?: TextMessageSendingOptions): void;
|
|
40
|
-
/**
|
|
41
|
-
* Sends image message to chat after action execution is finished.
|
|
42
|
-
* 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.
|
|
43
|
-
* @param name Message contents.
|
|
44
|
-
* @param options Message sending option.
|
|
45
|
-
*/
|
|
46
|
-
sendImageToChat(name: string, options?: MessageSendingOptions): void;
|
|
47
|
-
/**
|
|
48
|
-
* Sends video/gif message to chat after action execution is finished.
|
|
49
|
-
* 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.
|
|
50
|
-
* @param name Message contents.
|
|
51
|
-
* @param options Message sending option.
|
|
33
|
+
* Collection of actions that send something to chat as a standalone message.
|
|
52
34
|
*/
|
|
53
|
-
|
|
35
|
+
send: {
|
|
36
|
+
/**
|
|
37
|
+
* Sends text message to chat after action execution is finished.
|
|
38
|
+
* 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.
|
|
39
|
+
* @param text Message contents.
|
|
40
|
+
* @param options Message sending option.
|
|
41
|
+
*/
|
|
42
|
+
text: (text: string, options?: TextMessageSendingOptions) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Sends image 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
|
+
image: (name: string, options?: MessageSendingOptions) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Sends video/gif message to chat after action execution is finished.
|
|
52
|
+
* 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.
|
|
53
|
+
* @param name Message contents.
|
|
54
|
+
* @param options Message sending option.
|
|
55
|
+
*/
|
|
56
|
+
video: (name: string, options?: MessageSendingOptions) => void;
|
|
57
|
+
};
|
|
54
58
|
/**
|
|
55
59
|
* Unpins message after action execution is finished.
|
|
56
60
|
* 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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBAAa,WAAW,CAAC,YAAY,SAAS,YAAY;IACtD,
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBAAa,WAAW,CAAC,YAAY,SAAS,YAAY;IACtD,MAAM,EAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAExC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAE/B,sCAAsC;IACtC,OAAO,EAAG,OAAO,CAAC;IAClB,+CAA+C;IAC/C,OAAO,EAAG,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAG,QAAQ,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,WAAW,EAAE,CAAM;IAE9B,aAAa,UAAS;gBAGlB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAOzB;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAaxD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;QAarD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;MAYvD;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAK3B"}
|
|
@@ -15,48 +15,42 @@ class ChatContext {
|
|
|
15
15
|
/** Ordered collection of responses to be processed */
|
|
16
16
|
this.responses = [];
|
|
17
17
|
this.isInitialized = false;
|
|
18
|
+
/**
|
|
19
|
+
* Collection of actions that send something to chat as a standalone message.
|
|
20
|
+
*/
|
|
21
|
+
this.send = {
|
|
22
|
+
/**
|
|
23
|
+
* Sends text message to chat after action execution is finished.
|
|
24
|
+
* 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.
|
|
25
|
+
* @param text Message contents.
|
|
26
|
+
* @param options Message sending option.
|
|
27
|
+
*/
|
|
28
|
+
text: (text, options) => {
|
|
29
|
+
this.responses.push(new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options));
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Sends image 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 name Message contents.
|
|
35
|
+
* @param options Message sending option.
|
|
36
|
+
*/
|
|
37
|
+
image: (name, options) => {
|
|
38
|
+
this.responses.push(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options));
|
|
39
|
+
},
|
|
40
|
+
/**
|
|
41
|
+
* Sends video/gif message to chat after action execution is finished.
|
|
42
|
+
* 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.
|
|
43
|
+
* @param name Message contents.
|
|
44
|
+
* @param options Message sending option.
|
|
45
|
+
*/
|
|
46
|
+
video: (name, options) => {
|
|
47
|
+
this.responses.push(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options));
|
|
48
|
+
}
|
|
49
|
+
};
|
|
18
50
|
this.storage = storage;
|
|
19
51
|
this.logger = logger;
|
|
20
52
|
this.scheduler = scheduler;
|
|
21
53
|
}
|
|
22
|
-
initializeChatContext(botName, action, chatInfo, traceId) {
|
|
23
|
-
this.botName = botName;
|
|
24
|
-
this.action = action;
|
|
25
|
-
this.chatInfo = chatInfo;
|
|
26
|
-
this.traceId = traceId;
|
|
27
|
-
this.isInitialized = true;
|
|
28
|
-
this.responses = [];
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
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
|
-
sendTextToChat(text, options) {
|
|
38
|
-
this.responses.push(new textMessage_1.TextMessage(text, this.chatInfo, undefined, this.traceId, this.action, options));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Sends image message to chat after action execution is finished.
|
|
42
|
-
* 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.
|
|
43
|
-
* @param name Message contents.
|
|
44
|
-
* @param options Message sending option.
|
|
45
|
-
*/
|
|
46
|
-
sendImageToChat(name, options) {
|
|
47
|
-
const filePath = `./content/${name}.png`;
|
|
48
|
-
this.responses.push(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatInfo, undefined, this.traceId, this.action, options));
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Sends video/gif message to chat after action execution is finished.
|
|
52
|
-
* 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.
|
|
53
|
-
* @param name Message contents.
|
|
54
|
-
* @param options Message sending option.
|
|
55
|
-
*/
|
|
56
|
-
sendVideoToChat(name, options) {
|
|
57
|
-
const filePath = `./content/${name}.mp4`;
|
|
58
|
-
this.responses.push(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatInfo, undefined, this.traceId, this.action, options));
|
|
59
|
-
}
|
|
60
54
|
/**
|
|
61
55
|
* Unpins message after action execution is finished.
|
|
62
56
|
* 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.
|
|
@@ -2,9 +2,7 @@ import { TelegramEmoji } from 'telegraf/types';
|
|
|
2
2
|
import { IStorageClient } from '../../types/storage';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
4
|
import { ChatContext } from './chatContext';
|
|
5
|
-
import { IncomingMessage } from '../../dtos/incomingMessage';
|
|
6
5
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
7
|
-
import { IActionWithState } from '../../types/statefulAction';
|
|
8
6
|
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
9
7
|
import { ILogger } from '../../types/logger';
|
|
10
8
|
import { IScheduler } from '../../types/scheduler';
|
|
@@ -29,7 +27,9 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
29
27
|
/** Message object recieved from Telegram */
|
|
30
28
|
messageUpdateObject: TelegrafContextMessage;
|
|
31
29
|
constructor(storage: IStorageClient, logger: ILogger, scheduler: IScheduler);
|
|
32
|
-
|
|
30
|
+
private replyWithText;
|
|
31
|
+
private replyWithImage;
|
|
32
|
+
private replyWithVideo;
|
|
33
33
|
/**
|
|
34
34
|
* Loads state of another action. Changes to the loaded state will no affect actual state of other action.
|
|
35
35
|
* @param commandName Name of an action to load state of.
|
|
@@ -37,31 +37,63 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
37
37
|
*/
|
|
38
38
|
loadStateOf<TAnotherActionState extends IActionState>(commandName: string): Promise<TAnotherActionState>;
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
41
|
-
* 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.
|
|
42
|
-
* @param text Message contents.
|
|
43
|
-
* @param options Message sending option.
|
|
40
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
44
41
|
*/
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
42
|
+
reply: {
|
|
43
|
+
/**
|
|
44
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
45
|
+
* If regex is matched, first match will be quoted
|
|
46
|
+
*/
|
|
47
|
+
andQuote: {
|
|
48
|
+
/**
|
|
49
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
50
|
+
* 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
|
+
* @param text Message contents.
|
|
52
|
+
* @param options Message sending option.
|
|
53
|
+
*/
|
|
54
|
+
withText: (text: string, options?: TextMessageSendingOptions) => void;
|
|
55
|
+
/**
|
|
56
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
57
|
+
* 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
|
+
* @param text Message contents.
|
|
59
|
+
* @param options Message sending option.
|
|
60
|
+
*/
|
|
61
|
+
withImage: (name: string, options?: MessageSendingOptions) => void;
|
|
62
|
+
/**
|
|
63
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
64
|
+
* 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.
|
|
65
|
+
* @param text Message contents.
|
|
66
|
+
* @param options Message sending option.
|
|
67
|
+
*/
|
|
68
|
+
withVideo: (name: string, options?: MessageSendingOptions) => void;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
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.
|
|
73
|
+
* @param text Message contents.
|
|
74
|
+
* @param options Message sending option.
|
|
75
|
+
*/
|
|
76
|
+
withText: (text: string, options?: TextMessageSendingOptions) => void;
|
|
77
|
+
/**
|
|
78
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
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.
|
|
80
|
+
* @param text Message contents.
|
|
81
|
+
* @param options Message sending option.
|
|
82
|
+
*/
|
|
83
|
+
withImage: (name: string, options?: MessageSendingOptions) => void;
|
|
84
|
+
/**
|
|
85
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
86
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
87
|
+
* @param text Message contents.
|
|
88
|
+
* @param options Message sending option.
|
|
89
|
+
*/
|
|
90
|
+
withVideo: (name: string, options?: MessageSendingOptions) => void;
|
|
91
|
+
/**
|
|
92
|
+
* React to the message that triggered this action after action execution is finished.
|
|
93
|
+
* 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.
|
|
94
|
+
* @param emoji Telegram emoji to react with.
|
|
95
|
+
*/
|
|
96
|
+
withReaction: (emoji: TelegramEmoji) => void;
|
|
97
|
+
};
|
|
66
98
|
}
|
|
67
99
|
//# sourceMappingURL=messageContext.d.ts.map
|
|
@@ -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;AAMvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,
|
|
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;AAMvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD;;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;gBAGzC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAKzB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,cAAc;IAsBtB;;;;OAIG;IACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAe/B;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BACc,MAAM,YAAY,yBAAyB;YAE5D;;;;;eAKG;8BACe,MAAM,YAAY,qBAAqB;YAGzD;;;;;eAKG;8BACe,MAAM,YAAY,qBAAqB;;QAI7D;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -8,6 +8,7 @@ const textMessage_1 = require("../../dtos/responses/textMessage");
|
|
|
8
8
|
const videoMessage_1 = require("../../dtos/responses/videoMessage");
|
|
9
9
|
const actionStateBase_1 = require("../states/actionStateBase");
|
|
10
10
|
const chatContext_1 = require("./chatContext");
|
|
11
|
+
const replyInfo_1 = require("../../types/replyInfo");
|
|
11
12
|
/**
|
|
12
13
|
* Context of action executed in chat, in response to a message
|
|
13
14
|
*/
|
|
@@ -18,19 +19,85 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
18
19
|
this.matchResults = [];
|
|
19
20
|
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
20
21
|
this.startCooldown = true;
|
|
22
|
+
/**
|
|
23
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
24
|
+
*/
|
|
25
|
+
this.reply = {
|
|
26
|
+
/**
|
|
27
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
28
|
+
* If regex is matched, first match will be quoted
|
|
29
|
+
*/
|
|
30
|
+
andQuote: {
|
|
31
|
+
/**
|
|
32
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
33
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
34
|
+
* @param text Message contents.
|
|
35
|
+
* @param options Message sending option.
|
|
36
|
+
*/
|
|
37
|
+
withText: (text, options) => this.replyWithText(text, true, options),
|
|
38
|
+
/**
|
|
39
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
40
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
41
|
+
* @param text Message contents.
|
|
42
|
+
* @param options Message sending option.
|
|
43
|
+
*/
|
|
44
|
+
withImage: (name, options) => this.replyWithImage(name, true, options),
|
|
45
|
+
/**
|
|
46
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
47
|
+
* 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.
|
|
48
|
+
* @param text Message contents.
|
|
49
|
+
* @param options Message sending option.
|
|
50
|
+
*/
|
|
51
|
+
withVideo: (name, options) => this.replyWithVideo(name, true, options)
|
|
52
|
+
},
|
|
53
|
+
/**
|
|
54
|
+
* Reply with text message to message that triggered this action after action execution is finished.
|
|
55
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
56
|
+
* @param text Message contents.
|
|
57
|
+
* @param options Message sending option.
|
|
58
|
+
*/
|
|
59
|
+
withText: (text, options) => this.replyWithText(text, false, options),
|
|
60
|
+
/**
|
|
61
|
+
* Reply with image 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
|
+
withImage: (name, options) => this.replyWithImage(name, false, options),
|
|
67
|
+
/**
|
|
68
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
69
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
70
|
+
* @param text Message contents.
|
|
71
|
+
* @param options Message sending option.
|
|
72
|
+
*/
|
|
73
|
+
withVideo: (name, options) => this.replyWithVideo(name, false, options),
|
|
74
|
+
/**
|
|
75
|
+
* React to the message that triggered this action after action execution is finished.
|
|
76
|
+
* 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.
|
|
77
|
+
* @param emoji Telegram emoji to react with.
|
|
78
|
+
*/
|
|
79
|
+
withReaction: (emoji) => {
|
|
80
|
+
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
81
|
+
}
|
|
82
|
+
};
|
|
21
83
|
}
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
84
|
+
replyWithText(text, quote, options) {
|
|
85
|
+
const quotedPart = this.matchResults.length != 0
|
|
86
|
+
? this.matchResults[0][1]
|
|
87
|
+
: this.messageText;
|
|
88
|
+
this.responses.push(new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options));
|
|
89
|
+
}
|
|
90
|
+
replyWithImage(name, quote, options) {
|
|
91
|
+
const quotedPart = this.matchResults.length != 0
|
|
92
|
+
? this.matchResults[0][1]
|
|
93
|
+
: this.messageText;
|
|
94
|
+
this.responses.push(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));
|
|
95
|
+
}
|
|
96
|
+
replyWithVideo(name, quote, options) {
|
|
97
|
+
const quotedPart = this.matchResults.length != 0
|
|
98
|
+
? this.matchResults[0][1]
|
|
99
|
+
: this.messageText;
|
|
100
|
+
this.responses.push(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));
|
|
34
101
|
}
|
|
35
102
|
/**
|
|
36
103
|
* Loads state of another action. Changes to the loaded state will no affect actual state of other action.
|
|
@@ -46,42 +113,5 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
46
113
|
}
|
|
47
114
|
return stateForChat;
|
|
48
115
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Reply with text message to message that triggered this action after action execution is finished.
|
|
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.
|
|
52
|
-
* @param text Message contents.
|
|
53
|
-
* @param options Message sending option.
|
|
54
|
-
*/
|
|
55
|
-
replyWithText(text, options) {
|
|
56
|
-
this.responses.push(new textMessage_1.TextMessage(text, this.chatInfo, this.messageId, this.traceId, this.action, options));
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Reply with image message to message that triggered this action after action execution is finished.
|
|
60
|
-
* 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.
|
|
61
|
-
* @param text Message contents.
|
|
62
|
-
* @param options Message sending option.
|
|
63
|
-
*/
|
|
64
|
-
replyWithImage(name, options) {
|
|
65
|
-
const filePath = `./content/${name}.png`;
|
|
66
|
-
this.responses.push(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatInfo, this.messageId, this.traceId, this.action, options));
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
70
|
-
* 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.
|
|
71
|
-
* @param text Message contents.
|
|
72
|
-
* @param options Message sending option.
|
|
73
|
-
*/
|
|
74
|
-
replyWithVideo(name, options) {
|
|
75
|
-
const filePath = `./content/${name}.mp4`;
|
|
76
|
-
this.responses.push(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatInfo, this.messageId, this.traceId, this.action, options));
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* React to the 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 emoji Telegram emoji to react with.
|
|
82
|
-
*/
|
|
83
|
-
react(emoji) {
|
|
84
|
-
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageId, emoji, this.action));
|
|
85
|
-
}
|
|
86
116
|
}
|
|
87
117
|
exports.MessageContext = MessageContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO;IAQnB,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE;IA8BhD,cAAc;YAIA,WAAW;YAqBX,eAAe;CAmGhC"}
|
|
@@ -49,25 +49,41 @@ class TelegramApiService {
|
|
|
49
49
|
switch (response.kind) {
|
|
50
50
|
case 'text':
|
|
51
51
|
sentMessage = await this.telegram.sendMessage(response.chatInfo.id, response.content, {
|
|
52
|
-
|
|
52
|
+
reply_parameters: response.replyInfo
|
|
53
|
+
? {
|
|
54
|
+
message_id: response.replyInfo.id,
|
|
55
|
+
quote: response.replyInfo.quote
|
|
56
|
+
}
|
|
57
|
+
: undefined,
|
|
53
58
|
parse_mode: 'MarkdownV2',
|
|
54
|
-
|
|
55
|
-
|
|
59
|
+
link_preview_options: {
|
|
60
|
+
is_disabled: response.disableWebPreview
|
|
61
|
+
}
|
|
56
62
|
});
|
|
57
63
|
await this.pinIfShould(response, sentMessage);
|
|
58
64
|
break;
|
|
59
65
|
case 'image':
|
|
60
|
-
sentMessage = await this.telegram.sendPhoto(response.chatInfo.id, response.content,
|
|
61
|
-
|
|
62
|
-
{
|
|
63
|
-
|
|
66
|
+
sentMessage = await this.telegram.sendPhoto(response.chatInfo.id, response.content, {
|
|
67
|
+
reply_parameters: response.replyInfo
|
|
68
|
+
? {
|
|
69
|
+
message_id: response.replyInfo.id,
|
|
70
|
+
quote: response.replyInfo.quote
|
|
71
|
+
}
|
|
72
|
+
: undefined,
|
|
73
|
+
parse_mode: 'MarkdownV2'
|
|
74
|
+
});
|
|
64
75
|
await this.pinIfShould(response, sentMessage);
|
|
65
76
|
break;
|
|
66
77
|
case 'video':
|
|
67
|
-
sentMessage = await this.telegram.sendVideo(response.chatInfo.id, response.content,
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
78
|
+
sentMessage = await this.telegram.sendVideo(response.chatInfo.id, response.content, {
|
|
79
|
+
reply_parameters: response.replyInfo
|
|
80
|
+
? {
|
|
81
|
+
message_id: response.replyInfo.id,
|
|
82
|
+
quote: response.replyInfo.quote
|
|
83
|
+
}
|
|
84
|
+
: undefined,
|
|
85
|
+
parse_mode: 'MarkdownV2'
|
|
86
|
+
});
|
|
71
87
|
await this.pinIfShould(response, sentMessage);
|
|
72
88
|
break;
|
|
73
89
|
case 'react':
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replyInfo.d.ts","sourceRoot":"","sources":["../../types/replyInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,SAAS;IAClB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEvB,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAIzC"}
|
package/dist/types/response.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { TextMessage } from '../dtos/responses/textMessage';
|
|
|
7
7
|
import { UnpinResponse } from '../dtos/responses/unpin';
|
|
8
8
|
import { VideoMessage } from '../dtos/responses/videoMessage';
|
|
9
9
|
import { IActionState } from './actionState';
|
|
10
|
+
import { ReplyInfo } from './replyInfo';
|
|
10
11
|
import { IActionWithState } from './statefulAction';
|
|
11
12
|
import { TraceId } from './trace';
|
|
12
13
|
export declare const BotResponseTypes: {
|
|
@@ -26,9 +27,9 @@ export interface IChatResponse {
|
|
|
26
27
|
readonly createdAt: number;
|
|
27
28
|
readonly action: IActionWithState<IActionState>;
|
|
28
29
|
}
|
|
29
|
-
export interface
|
|
30
|
+
export interface IReplyResponse<TType> extends IChatResponse {
|
|
30
31
|
readonly content: TType;
|
|
31
|
-
readonly
|
|
32
|
+
readonly replyInfo: ReplyInfo | undefined;
|
|
32
33
|
readonly disableWebPreview: boolean;
|
|
33
34
|
readonly shouldPin: boolean;
|
|
34
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;CAQnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;;CAQnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,mBAAmB,GACnB,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,cAAc,CAAC,KAAK,CAAE,SAAQ,aAAa;IACxD,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC/B"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
|
-
import { BotResponseTypes,
|
|
2
|
+
import { BotResponseTypes, IReplyResponse } from '../../types/response';
|
|
3
3
|
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
4
|
import { IActionWithState } from '../../types/statefulAction';
|
|
5
5
|
import { IActionState } from '../../types/actionState';
|
|
6
6
|
import { ChatInfo } from '../chatInfo';
|
|
7
7
|
import { TraceId } from '../../types/trace';
|
|
8
|
+
import { ReplyInfo } from '../../types/replyInfo';
|
|
8
9
|
|
|
9
|
-
export class ImageMessage implements
|
|
10
|
+
export class ImageMessage implements IReplyResponse<InputFile> {
|
|
10
11
|
readonly kind = BotResponseTypes.image;
|
|
11
12
|
readonly createdAt = Date.now();
|
|
12
13
|
|
|
13
14
|
readonly content: InputFile;
|
|
14
15
|
readonly chatInfo: ChatInfo;
|
|
15
|
-
readonly
|
|
16
|
+
readonly replyInfo: ReplyInfo | undefined;
|
|
16
17
|
readonly traceId: TraceId;
|
|
17
18
|
readonly disableWebPreview = false;
|
|
18
19
|
readonly shouldPin: boolean;
|
|
@@ -21,14 +22,14 @@ export class ImageMessage implements IReplyMessage<InputFile> {
|
|
|
21
22
|
constructor(
|
|
22
23
|
image: InputFile,
|
|
23
24
|
chatInfo: ChatInfo,
|
|
24
|
-
replyId: number | undefined,
|
|
25
25
|
traceId: TraceId,
|
|
26
26
|
action: IActionWithState<IActionState>,
|
|
27
|
+
replyInfo: ReplyInfo | undefined,
|
|
27
28
|
options?: MessageSendingOptions
|
|
28
29
|
) {
|
|
29
30
|
this.content = image;
|
|
30
31
|
this.chatInfo = chatInfo;
|
|
31
|
-
this.
|
|
32
|
+
this.replyInfo = replyInfo;
|
|
32
33
|
this.traceId = traceId;
|
|
33
34
|
this.shouldPin = options?.pin ?? false;
|
|
34
35
|
this.action = action;
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
|
-
import { BotResponseTypes,
|
|
2
|
+
import { BotResponseTypes, IReplyResponse } from '../../types/response';
|
|
3
3
|
import { IActionWithState } from '../../types/statefulAction';
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
5
|
import { ChatInfo } from '../chatInfo';
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
|
7
|
+
import { ReplyInfo } from '../../types/replyInfo';
|
|
7
8
|
|
|
8
|
-
export class TextMessage implements
|
|
9
|
+
export class TextMessage implements IReplyResponse<string> {
|
|
9
10
|
readonly kind = BotResponseTypes.text;
|
|
10
11
|
readonly createdAt = Date.now();
|
|
11
12
|
|
|
12
13
|
readonly content: string;
|
|
13
14
|
readonly chatInfo: ChatInfo;
|
|
14
|
-
readonly
|
|
15
|
+
readonly replyInfo: ReplyInfo | undefined;
|
|
15
16
|
readonly traceId: TraceId;
|
|
16
17
|
readonly disableWebPreview: boolean;
|
|
17
18
|
readonly shouldPin: boolean;
|
|
@@ -20,14 +21,14 @@ export class TextMessage implements IReplyMessage<string> {
|
|
|
20
21
|
constructor(
|
|
21
22
|
text: string,
|
|
22
23
|
chatInfo: ChatInfo,
|
|
23
|
-
replyId: number | undefined,
|
|
24
24
|
traceId: TraceId,
|
|
25
25
|
action: IActionWithState<IActionState>,
|
|
26
|
+
replyInfo?: ReplyInfo,
|
|
26
27
|
options?: TextMessageSendingOptions
|
|
27
28
|
) {
|
|
28
29
|
this.content = text;
|
|
29
30
|
this.chatInfo = chatInfo;
|
|
30
|
-
this.
|
|
31
|
+
this.replyInfo = replyInfo;
|
|
31
32
|
this.traceId = traceId;
|
|
32
33
|
this.disableWebPreview = options?.disableWebPreview ?? false;
|
|
33
34
|
this.shouldPin = options?.pin ?? false;
|