chz-telegram-bot 0.0.20 → 0.0.21
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/entities/botInstance.d.ts +2 -0
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +29 -20
- package/dist/entities/context/chatContext.d.ts +4 -3
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +6 -6
- 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 +6 -6
- package/dist/entities/responses/imageMessage.d.ts +2 -1
- package/dist/entities/responses/imageMessage.d.ts.map +1 -1
- package/dist/entities/responses/imageMessage.js +2 -2
- package/dist/entities/responses/textMessage.d.ts +2 -1
- package/dist/entities/responses/textMessage.d.ts.map +1 -1
- package/dist/entities/responses/textMessage.js +3 -3
- package/dist/entities/responses/videoMessage.d.ts +2 -1
- package/dist/entities/responses/videoMessage.d.ts.map +1 -1
- package/dist/entities/responses/videoMessage.js +2 -2
- package/dist/types/messageSendingOptions.d.ts +7 -0
- package/dist/types/messageSendingOptions.d.ts.map +1 -0
- package/dist/types/messageSendingOptions.js +2 -0
- package/entities/botInstance.ts +51 -41
- package/entities/context/chatContext.ts +13 -14
- package/entities/context/messageContext.ts +13 -10
- package/entities/responses/imageMessage.ts +4 -3
- package/entities/responses/textMessage.ts +5 -5
- package/entities/responses/videoMessage.ts +4 -3
- package/package.json +1 -1
- package/types/messageSendingOptions.ts +7 -0
|
@@ -20,6 +20,8 @@ export declare class BotInstance {
|
|
|
20
20
|
storageClient?: IStorageClient;
|
|
21
21
|
storagePath?: string;
|
|
22
22
|
});
|
|
23
|
+
private initializeScheduledProcessing;
|
|
24
|
+
private initializeMessageProcessing;
|
|
23
25
|
stop(code: string): Promise<void>;
|
|
24
26
|
private runScheduled;
|
|
25
27
|
private processMessages;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"botInstance.d.ts","sourceRoot":"","sources":["../../entities/botInstance.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAK5D,qBAAa,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,EAAE,cAAc,CAAC;gBAEZ,OAAO,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;QAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB;
|
|
1
|
+
{"version":3,"file":"botInstance.d.ts","sourceRoot":"","sources":["../../entities/botInstance.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAK5D,qBAAa,WAAW;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,GAAG,CAAqB;IAChC,OAAO,CAAC,QAAQ,CAAW;IAC3B,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,SAAS,CAAkC;IACnD,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,EAAE,cAAc,CAAC;gBAEZ,OAAO,EAAE;QACjB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;QACxC,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,CAAC;QAC3C,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;QAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;KACxB;IAkCD,OAAO,CAAC,6BAA6B;IAcrC,OAAO,CAAC,2BAA2B;IAkC7B,IAAI,CAAC,IAAI,EAAE,MAAM;YAYT,YAAY;YAoBZ,eAAe;CAmBhC"}
|
|
@@ -21,26 +21,36 @@ class BotInstance {
|
|
|
21
21
|
options.storageClient ??
|
|
22
22
|
new jsonFileStorage_1.JsonFileStorage(options.name, options.storagePath);
|
|
23
23
|
this.api = new telegramApi_1.TelegramApiService(this.name, this.telegraf.telegram, this.storage, this.chats);
|
|
24
|
-
this.
|
|
25
|
-
|
|
26
|
-
const messageContent = msg.text || '<non-text message>';
|
|
27
|
-
const messageFromName = msg.from?.first_name ?? 'Unknown';
|
|
28
|
-
const messageFromId = msg.from?.id ?? 'Unknown';
|
|
29
|
-
logger_1.Logger.logWithTraceId(this.name, msg.traceId, msg.chatName, `${messageFromName} (${messageFromId}): ${messageContent}`);
|
|
30
|
-
if (msg.text) {
|
|
31
|
-
this.messageQueue.push(msg);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
this.telegraf.launch();
|
|
35
|
-
taskScheduler_1.Scheduler.createTask('MessageProcessing', async () => {
|
|
36
|
-
while (this.messageQueue.length > 0) {
|
|
37
|
-
await this.processMessages();
|
|
38
|
-
}
|
|
39
|
-
}, (0, timeConvertions_1.secondsToMilliseconds)(0.3), false, this.name);
|
|
40
|
-
taskScheduler_1.Scheduler.createTask('ScheduledProcessing', async () => {
|
|
41
|
-
await this.runScheduled();
|
|
42
|
-
}, (0, timeConvertions_1.hoursToMilliseconds)(0.5), true, this.name);
|
|
24
|
+
this.initializeMessageProcessing();
|
|
25
|
+
this.initializeScheduledProcessing();
|
|
43
26
|
this.storage.saveMetadata([...this.commands, ...this.scheduled], this.name);
|
|
27
|
+
this.telegraf.launch();
|
|
28
|
+
}
|
|
29
|
+
initializeScheduledProcessing() {
|
|
30
|
+
if (this.scheduled.length > 0) {
|
|
31
|
+
taskScheduler_1.Scheduler.createTask('ScheduledProcessing', async () => {
|
|
32
|
+
await this.runScheduled();
|
|
33
|
+
}, (0, timeConvertions_1.hoursToMilliseconds)(0.5), true, this.name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
initializeMessageProcessing() {
|
|
37
|
+
if (this.commands.length > 0) {
|
|
38
|
+
this.telegraf.on('message', async (ctx) => {
|
|
39
|
+
const msg = new incomingMessage_1.IncomingMessage(ctx.update.message);
|
|
40
|
+
const messageContent = msg.text || '<non-text message>';
|
|
41
|
+
const messageFromName = msg.from?.first_name ?? 'Unknown';
|
|
42
|
+
const messageFromId = msg.from?.id ?? 'Unknown';
|
|
43
|
+
logger_1.Logger.logWithTraceId(this.name, msg.traceId, msg.chatName, `${messageFromName} (${messageFromId}): ${messageContent}`);
|
|
44
|
+
if (msg.text) {
|
|
45
|
+
this.messageQueue.push(msg);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
taskScheduler_1.Scheduler.createTask('MessageProcessing', async () => {
|
|
49
|
+
while (this.messageQueue.length > 0) {
|
|
50
|
+
await this.processMessages();
|
|
51
|
+
}
|
|
52
|
+
}, (0, timeConvertions_1.secondsToMilliseconds)(0.3), false, this.name);
|
|
53
|
+
}
|
|
44
54
|
}
|
|
45
55
|
async stop(code) {
|
|
46
56
|
logger_1.Logger.logWithTraceId(this.name, `System:Bot-${this.name}-Stop`, 'System', 'Stopping bot...');
|
|
@@ -55,7 +65,6 @@ class BotInstance {
|
|
|
55
65
|
await trig.exec(ctx);
|
|
56
66
|
}
|
|
57
67
|
catch (error) {
|
|
58
|
-
console.dir(error);
|
|
59
68
|
logger_1.Logger.errorWithTraceId(ctx.botName, ctx.traceId, chatName, error, ctx);
|
|
60
69
|
}
|
|
61
70
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IBotApiInteractions } from '../../services/telegramApi';
|
|
2
2
|
import { IStorageClient } from '../../types/storage';
|
|
3
|
+
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
4
|
export declare class ChatContext {
|
|
4
5
|
botName: string;
|
|
5
6
|
actionKey: string;
|
|
@@ -9,9 +10,9 @@ export declare class ChatContext {
|
|
|
9
10
|
traceId: number | string;
|
|
10
11
|
storage: IStorageClient;
|
|
11
12
|
constructor(botName: string, actionKey: string, interactions: IBotApiInteractions, chatId: number, chatName: string, traceId: number | string, storage: IStorageClient);
|
|
12
|
-
sendTextToChat(text: string,
|
|
13
|
-
sendImageToChat(name: string,
|
|
14
|
-
sendVideoToChat(name: string,
|
|
13
|
+
sendTextToChat(text: string, options?: TextMessageSendingOptions): void;
|
|
14
|
+
sendImageToChat(name: string, options?: MessageSendingOptions): void;
|
|
15
|
+
sendVideoToChat(name: string, options?: MessageSendingOptions): void;
|
|
15
16
|
unpinMessage(messageId: number): void;
|
|
16
17
|
}
|
|
17
18
|
//# sourceMappingURL=chatContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,qBAAa,WAAW;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,mBAAmB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,OAAO,EAAE,cAAc,CAAC;gBAGpB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,EAAE,cAAc;IAW3B,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAahE,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D,YAAY,CAAC,SAAS,EAAE,MAAM;CAUjC"}
|
|
@@ -16,16 +16,16 @@ class ChatContext {
|
|
|
16
16
|
this.traceId = traceId;
|
|
17
17
|
this.storage = storage;
|
|
18
18
|
}
|
|
19
|
-
sendTextToChat(text,
|
|
20
|
-
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, undefined, this.traceId,
|
|
19
|
+
sendTextToChat(text, options) {
|
|
20
|
+
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, undefined, this.traceId, this.actionKey, options));
|
|
21
21
|
}
|
|
22
|
-
sendImageToChat(name,
|
|
22
|
+
sendImageToChat(name, options) {
|
|
23
23
|
const filePath = `./content/${name}.png`;
|
|
24
|
-
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId,
|
|
24
|
+
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId, this.actionKey, options));
|
|
25
25
|
}
|
|
26
|
-
sendVideoToChat(name,
|
|
26
|
+
sendVideoToChat(name, options) {
|
|
27
27
|
const filePath = `./content/${name}.mp4`;
|
|
28
|
-
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId,
|
|
28
|
+
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, undefined, this.traceId, this.actionKey, options));
|
|
29
29
|
}
|
|
30
30
|
unpinMessage(messageId) {
|
|
31
31
|
this.interactions.unpin(new unpin_1.UnpinResponse(messageId, this.chatId, this.traceId, this.actionKey));
|
|
@@ -3,6 +3,7 @@ import { TelegramEmoji } from 'telegraf/types';
|
|
|
3
3
|
import { IStorageClient } from '../../types/storage';
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
5
|
import { ChatContext } from './chatContext';
|
|
6
|
+
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
7
|
export declare class MessageContext<TActionState extends IActionState> extends ChatContext {
|
|
7
8
|
messageId: number;
|
|
8
9
|
messageText: string;
|
|
@@ -14,9 +15,9 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
14
15
|
constructor(botName: string, scheduledKey: string, interactions: IBotApiInteractions, chatId: number, chatName: string, messageId: number, messageText: string, fromUserId: number | undefined, traceId: number | string, fromUserName: string, storage: IStorageClient);
|
|
15
16
|
loadStateOf<TAnotherActionState extends IActionState>(commandName: string): Promise<TAnotherActionState>;
|
|
16
17
|
updateState(stateUpdateAction: (state: TActionState) => void): void;
|
|
17
|
-
replyWithText(text: string,
|
|
18
|
-
replyWithImage(name: string,
|
|
19
|
-
replyWithVideo(name: string,
|
|
18
|
+
replyWithText(text: string, options?: TextMessageSendingOptions): void;
|
|
19
|
+
replyWithImage(name: string, options?: MessageSendingOptions): void;
|
|
20
|
+
replyWithVideo(name: string, options?: MessageSendingOptions): void;
|
|
20
21
|
react(emoji: TelegramEmoji): void;
|
|
21
22
|
}
|
|
22
23
|
//# 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,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,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;
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,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,qBAAa,cAAc,CACvB,YAAY,SAAS,YAAY,CACnC,SAAQ,WAAW;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,aAAa,EAAE,OAAO,CAAQ;IAC9B,aAAa,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC,CAAM;IACzD,YAAY,EAAE,MAAM,CAAC;gBAGjB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,cAAc;IAkBrB,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAU/B,WAAW,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI;IAM5D,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAa/D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc5D,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc5D,KAAK,CAAC,KAAK,EAAE,aAAa;CAW7B"}
|
|
@@ -25,16 +25,16 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
25
25
|
updateState(stateUpdateAction) {
|
|
26
26
|
this.updateActions.push(stateUpdateAction);
|
|
27
27
|
}
|
|
28
|
-
replyWithText(text,
|
|
29
|
-
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, this.messageId, this.traceId,
|
|
28
|
+
replyWithText(text, options) {
|
|
29
|
+
this.interactions.respond(new textMessage_1.TextMessage(text, this.chatId, this.messageId, this.traceId, this.actionKey, options));
|
|
30
30
|
}
|
|
31
|
-
replyWithImage(name,
|
|
31
|
+
replyWithImage(name, options) {
|
|
32
32
|
const filePath = `./content/${name}.png`;
|
|
33
|
-
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId,
|
|
33
|
+
this.interactions.respond(new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId, this.actionKey, options));
|
|
34
34
|
}
|
|
35
|
-
replyWithVideo(name,
|
|
35
|
+
replyWithVideo(name, options) {
|
|
36
36
|
const filePath = `./content/${name}.mp4`;
|
|
37
|
-
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId,
|
|
37
|
+
this.interactions.respond(new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(filePath) }, this.chatId, this.messageId, this.traceId, this.actionKey, options));
|
|
38
38
|
}
|
|
39
39
|
react(emoji) {
|
|
40
40
|
this.interactions.react(new reaction_1.Reaction(this.traceId, this.chatId, this.messageId, emoji, this.actionKey));
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { IReplyMessage } from '../../types/response';
|
|
3
|
+
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
4
|
export declare class ImageMessage implements IReplyMessage<InputFile> {
|
|
4
5
|
kind: "image";
|
|
5
6
|
content: InputFile;
|
|
@@ -9,6 +10,6 @@ export declare class ImageMessage implements IReplyMessage<InputFile> {
|
|
|
9
10
|
disableWebPreview: boolean;
|
|
10
11
|
shouldPin: boolean;
|
|
11
12
|
sourceActionKey: string;
|
|
12
|
-
constructor(image: InputFile, chatId: number, replyId: number | undefined, traceId: number | string,
|
|
13
|
+
constructor(image: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, sourceActionKey: string, options?: MessageSendingOptions);
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=imageMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,IAAI,UAA0B;IAE9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -3,14 +3,14 @@ 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
|
-
constructor(image, chatId, replyId, traceId,
|
|
6
|
+
constructor(image, chatId, replyId, traceId, sourceActionKey, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.image;
|
|
8
8
|
this.disableWebPreview = false;
|
|
9
9
|
this.content = image;
|
|
10
10
|
this.chatId = chatId;
|
|
11
11
|
this.replyId = replyId;
|
|
12
12
|
this.traceId = traceId;
|
|
13
|
-
this.shouldPin =
|
|
13
|
+
this.shouldPin = options?.pin ?? false;
|
|
14
14
|
this.sourceActionKey = sourceActionKey;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
1
2
|
import { IReplyMessage } from '../../types/response';
|
|
2
3
|
export declare class TextMessage implements IReplyMessage<string> {
|
|
3
4
|
kind: "text";
|
|
@@ -8,6 +9,6 @@ export declare class TextMessage implements IReplyMessage<string> {
|
|
|
8
9
|
disableWebPreview: boolean;
|
|
9
10
|
shouldPin: boolean;
|
|
10
11
|
sourceActionKey: string;
|
|
11
|
-
constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number,
|
|
12
|
+
constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number, sourceActionKey: string, options?: TextMessageSendingOptions);
|
|
12
13
|
}
|
|
13
14
|
//# sourceMappingURL=textMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,IAAI,SAAyB;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,
|
|
1
|
+
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,IAAI,SAAyB;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
|
|
@@ -3,14 +3,14 @@ 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
|
-
constructor(text, chatId, replyId, traceId,
|
|
6
|
+
constructor(text, chatId, replyId, traceId, sourceActionKey, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.text;
|
|
8
8
|
this.content = text;
|
|
9
9
|
this.chatId = chatId;
|
|
10
10
|
this.replyId = replyId;
|
|
11
11
|
this.traceId = traceId;
|
|
12
|
-
this.disableWebPreview = disableWebPreview;
|
|
13
|
-
this.shouldPin =
|
|
12
|
+
this.disableWebPreview = options?.disableWebPreview ?? false;
|
|
13
|
+
this.shouldPin = options?.pin ?? false;
|
|
14
14
|
this.sourceActionKey = sourceActionKey;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { IReplyMessage } from '../../types/response';
|
|
3
|
+
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
4
|
export declare class VideoMessage implements IReplyMessage<InputFile> {
|
|
4
5
|
kind: "video";
|
|
5
6
|
content: InputFile;
|
|
@@ -9,6 +10,6 @@ export declare class VideoMessage implements IReplyMessage<InputFile> {
|
|
|
9
10
|
disableWebPreview: boolean;
|
|
10
11
|
shouldPin: boolean;
|
|
11
12
|
sourceActionKey: string;
|
|
12
|
-
constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string,
|
|
13
|
+
constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, sourceActionKey: string, options?: MessageSendingOptions);
|
|
13
14
|
}
|
|
14
15
|
//# sourceMappingURL=videoMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,IAAI,UAA0B;IAE9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,eAAe,EAAE,MAAM,EACvB,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -3,14 +3,14 @@ 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
|
-
constructor(video, chatId, replyId, traceId,
|
|
6
|
+
constructor(video, chatId, replyId, traceId, sourceActionKey, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.video;
|
|
8
8
|
this.disableWebPreview = false;
|
|
9
9
|
this.content = video;
|
|
10
10
|
this.chatId = chatId;
|
|
11
11
|
this.replyId = replyId;
|
|
12
12
|
this.traceId = traceId;
|
|
13
|
-
this.shouldPin =
|
|
13
|
+
this.shouldPin = options?.pin ?? false;
|
|
14
14
|
this.sourceActionKey = sourceActionKey;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messageSendingOptions.d.ts","sourceRoot":"","sources":["../../types/messageSendingOptions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,qBAAqB;IAClC,GAAG,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,yBAA0B,SAAQ,qBAAqB;IACpE,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B"}
|
package/entities/botInstance.ts
CHANGED
|
@@ -55,52 +55,63 @@ export class BotInstance {
|
|
|
55
55
|
this.chats
|
|
56
56
|
);
|
|
57
57
|
|
|
58
|
-
this.
|
|
59
|
-
|
|
60
|
-
const messageContent = msg.text || '<non-text message>';
|
|
61
|
-
|
|
62
|
-
const messageFromName = msg.from?.first_name ?? 'Unknown';
|
|
63
|
-
const messageFromId = msg.from?.id ?? 'Unknown';
|
|
64
|
-
Logger.logWithTraceId(
|
|
65
|
-
this.name,
|
|
66
|
-
msg.traceId,
|
|
67
|
-
msg.chatName,
|
|
68
|
-
`${messageFromName} (${messageFromId}): ${messageContent}`
|
|
69
|
-
);
|
|
58
|
+
this.initializeMessageProcessing();
|
|
59
|
+
this.initializeScheduledProcessing();
|
|
70
60
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
61
|
+
this.storage.saveMetadata(
|
|
62
|
+
[...this.commands, ...this.scheduled],
|
|
63
|
+
this.name
|
|
64
|
+
);
|
|
75
65
|
|
|
76
66
|
this.telegraf.launch();
|
|
67
|
+
}
|
|
77
68
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
69
|
+
private initializeScheduledProcessing() {
|
|
70
|
+
if (this.scheduled.length > 0) {
|
|
71
|
+
Scheduler.createTask(
|
|
72
|
+
'ScheduledProcessing',
|
|
73
|
+
async () => {
|
|
74
|
+
await this.runScheduled();
|
|
75
|
+
},
|
|
76
|
+
hoursToMilliseconds(0.5 as Hours),
|
|
77
|
+
true,
|
|
78
|
+
this.name
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
async () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
private initializeMessageProcessing() {
|
|
84
|
+
if (this.commands.length > 0) {
|
|
85
|
+
this.telegraf.on('message', async (ctx) => {
|
|
86
|
+
const msg = new IncomingMessage(ctx.update.message);
|
|
87
|
+
const messageContent = msg.text || '<non-text message>';
|
|
88
|
+
|
|
89
|
+
const messageFromName = msg.from?.first_name ?? 'Unknown';
|
|
90
|
+
const messageFromId = msg.from?.id ?? 'Unknown';
|
|
91
|
+
Logger.logWithTraceId(
|
|
92
|
+
this.name,
|
|
93
|
+
msg.traceId,
|
|
94
|
+
msg.chatName,
|
|
95
|
+
`${messageFromName} (${messageFromId}): ${messageContent}`
|
|
96
|
+
);
|
|
99
97
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
if (msg.text) {
|
|
99
|
+
this.messageQueue.push(msg);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
Scheduler.createTask(
|
|
104
|
+
'MessageProcessing',
|
|
105
|
+
async () => {
|
|
106
|
+
while (this.messageQueue.length > 0) {
|
|
107
|
+
await this.processMessages();
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
secondsToMilliseconds(0.3 as Seconds),
|
|
111
|
+
false,
|
|
112
|
+
this.name
|
|
113
|
+
);
|
|
114
|
+
}
|
|
104
115
|
}
|
|
105
116
|
|
|
106
117
|
async stop(code: string) {
|
|
@@ -123,7 +134,6 @@ export class BotInstance {
|
|
|
123
134
|
try {
|
|
124
135
|
await trig.exec(ctx);
|
|
125
136
|
} catch (error) {
|
|
126
|
-
console.dir(error);
|
|
127
137
|
Logger.errorWithTraceId(
|
|
128
138
|
ctx.botName,
|
|
129
139
|
ctx.traceId,
|
|
@@ -5,6 +5,10 @@ import { ImageMessage } from '../responses/imageMessage';
|
|
|
5
5
|
import { TextMessage } from '../responses/textMessage';
|
|
6
6
|
import { VideoMessage } from '../responses/videoMessage';
|
|
7
7
|
import { UnpinResponse } from '../responses/unpin';
|
|
8
|
+
import {
|
|
9
|
+
MessageSendingOptions,
|
|
10
|
+
TextMessageSendingOptions
|
|
11
|
+
} from '../../types/messageSendingOptions';
|
|
8
12
|
|
|
9
13
|
export class ChatContext {
|
|
10
14
|
botName: string;
|
|
@@ -33,25 +37,20 @@ export class ChatContext {
|
|
|
33
37
|
this.storage = storage;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
sendTextToChat(
|
|
37
|
-
text: string,
|
|
38
|
-
disableWebPreview?: boolean,
|
|
39
|
-
pinned?: boolean
|
|
40
|
-
) {
|
|
40
|
+
sendTextToChat(text: string, options?: TextMessageSendingOptions) {
|
|
41
41
|
this.interactions.respond(
|
|
42
42
|
new TextMessage(
|
|
43
43
|
text,
|
|
44
44
|
this.chatId,
|
|
45
45
|
undefined,
|
|
46
46
|
this.traceId,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.actionKey
|
|
47
|
+
this.actionKey,
|
|
48
|
+
options
|
|
50
49
|
)
|
|
51
50
|
);
|
|
52
51
|
}
|
|
53
52
|
|
|
54
|
-
sendImageToChat(name: string,
|
|
53
|
+
sendImageToChat(name: string, options?: MessageSendingOptions) {
|
|
55
54
|
const filePath = `./content/${name}.png`;
|
|
56
55
|
this.interactions.respond(
|
|
57
56
|
new ImageMessage(
|
|
@@ -59,13 +58,13 @@ export class ChatContext {
|
|
|
59
58
|
this.chatId,
|
|
60
59
|
undefined,
|
|
61
60
|
this.traceId,
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
this.actionKey,
|
|
62
|
+
options
|
|
64
63
|
)
|
|
65
64
|
);
|
|
66
65
|
}
|
|
67
66
|
|
|
68
|
-
sendVideoToChat(name: string,
|
|
67
|
+
sendVideoToChat(name: string, options?: MessageSendingOptions) {
|
|
69
68
|
const filePath = `./content/${name}.mp4`;
|
|
70
69
|
this.interactions.respond(
|
|
71
70
|
new VideoMessage(
|
|
@@ -73,8 +72,8 @@ export class ChatContext {
|
|
|
73
72
|
this.chatId,
|
|
74
73
|
undefined,
|
|
75
74
|
this.traceId,
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
this.actionKey,
|
|
76
|
+
options
|
|
78
77
|
)
|
|
79
78
|
);
|
|
80
79
|
}
|
|
@@ -9,6 +9,10 @@ import { TextMessage } from '../responses/textMessage';
|
|
|
9
9
|
import { VideoMessage } from '../responses/videoMessage';
|
|
10
10
|
import { ActionStateBase } from '../states/actionStateBase';
|
|
11
11
|
import { ChatContext } from './chatContext';
|
|
12
|
+
import {
|
|
13
|
+
MessageSendingOptions,
|
|
14
|
+
TextMessageSendingOptions
|
|
15
|
+
} from '../../types/messageSendingOptions';
|
|
12
16
|
|
|
13
17
|
export class MessageContext<
|
|
14
18
|
TActionState extends IActionState
|
|
@@ -68,21 +72,20 @@ export class MessageContext<
|
|
|
68
72
|
);
|
|
69
73
|
}
|
|
70
74
|
|
|
71
|
-
replyWithText(text: string,
|
|
75
|
+
replyWithText(text: string, options?: TextMessageSendingOptions) {
|
|
72
76
|
this.interactions.respond(
|
|
73
77
|
new TextMessage(
|
|
74
78
|
text,
|
|
75
79
|
this.chatId,
|
|
76
80
|
this.messageId,
|
|
77
81
|
this.traceId,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.actionKey
|
|
82
|
+
this.actionKey,
|
|
83
|
+
options
|
|
81
84
|
)
|
|
82
85
|
);
|
|
83
86
|
}
|
|
84
87
|
|
|
85
|
-
replyWithImage(name: string,
|
|
88
|
+
replyWithImage(name: string, options?: MessageSendingOptions) {
|
|
86
89
|
const filePath = `./content/${name}.png`;
|
|
87
90
|
this.interactions.respond(
|
|
88
91
|
new ImageMessage(
|
|
@@ -90,13 +93,13 @@ export class MessageContext<
|
|
|
90
93
|
this.chatId,
|
|
91
94
|
this.messageId,
|
|
92
95
|
this.traceId,
|
|
93
|
-
|
|
94
|
-
|
|
96
|
+
this.actionKey,
|
|
97
|
+
options
|
|
95
98
|
)
|
|
96
99
|
);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
|
-
replyWithVideo(name: string,
|
|
102
|
+
replyWithVideo(name: string, options?: MessageSendingOptions) {
|
|
100
103
|
const filePath = `./content/${name}.mp4`;
|
|
101
104
|
this.interactions.respond(
|
|
102
105
|
new VideoMessage(
|
|
@@ -104,8 +107,8 @@ export class MessageContext<
|
|
|
104
107
|
this.chatId,
|
|
105
108
|
this.messageId,
|
|
106
109
|
this.traceId,
|
|
107
|
-
|
|
108
|
-
|
|
110
|
+
this.actionKey,
|
|
111
|
+
options
|
|
109
112
|
)
|
|
110
113
|
);
|
|
111
114
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
3
|
+
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
4
|
|
|
4
5
|
export class ImageMessage implements IReplyMessage<InputFile> {
|
|
5
6
|
kind = BotResponseTypes.image;
|
|
@@ -17,14 +18,14 @@ export class ImageMessage implements IReplyMessage<InputFile> {
|
|
|
17
18
|
chatId: number,
|
|
18
19
|
replyId: number | undefined,
|
|
19
20
|
traceId: number | string,
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
sourceActionKey: string,
|
|
22
|
+
options?: MessageSendingOptions
|
|
22
23
|
) {
|
|
23
24
|
this.content = image;
|
|
24
25
|
this.chatId = chatId;
|
|
25
26
|
this.replyId = replyId;
|
|
26
27
|
this.traceId = traceId;
|
|
27
|
-
this.shouldPin =
|
|
28
|
+
this.shouldPin = options?.pin ?? false;
|
|
28
29
|
this.sourceActionKey = sourceActionKey;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
1
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
2
3
|
|
|
3
4
|
export class TextMessage implements IReplyMessage<string> {
|
|
@@ -16,16 +17,15 @@ export class TextMessage implements IReplyMessage<string> {
|
|
|
16
17
|
chatId: number,
|
|
17
18
|
replyId: number | undefined,
|
|
18
19
|
traceId: string | number,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
sourceActionKey: string
|
|
20
|
+
sourceActionKey: string,
|
|
21
|
+
options?: TextMessageSendingOptions
|
|
22
22
|
) {
|
|
23
23
|
this.content = text;
|
|
24
24
|
this.chatId = chatId;
|
|
25
25
|
this.replyId = replyId;
|
|
26
26
|
this.traceId = traceId;
|
|
27
|
-
this.disableWebPreview = disableWebPreview;
|
|
28
|
-
this.shouldPin =
|
|
27
|
+
this.disableWebPreview = options?.disableWebPreview ?? false;
|
|
28
|
+
this.shouldPin = options?.pin ?? false;
|
|
29
29
|
this.sourceActionKey = sourceActionKey;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
2
|
import { BotResponseTypes, IReplyMessage } from '../../types/response';
|
|
3
|
+
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
4
|
|
|
4
5
|
export class VideoMessage implements IReplyMessage<InputFile> {
|
|
5
6
|
kind = BotResponseTypes.video;
|
|
@@ -17,14 +18,14 @@ export class VideoMessage implements IReplyMessage<InputFile> {
|
|
|
17
18
|
chatId: number,
|
|
18
19
|
replyId: number | undefined,
|
|
19
20
|
traceId: number | string,
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
sourceActionKey: string,
|
|
22
|
+
options?: MessageSendingOptions
|
|
22
23
|
) {
|
|
23
24
|
this.content = video;
|
|
24
25
|
this.chatId = chatId;
|
|
25
26
|
this.replyId = replyId;
|
|
26
27
|
this.traceId = traceId;
|
|
27
|
-
this.shouldPin =
|
|
28
|
+
this.shouldPin = options?.pin ?? false;
|
|
28
29
|
this.sourceActionKey = sourceActionKey;
|
|
29
30
|
}
|
|
30
31
|
}
|
package/package.json
CHANGED