chz-telegram-bot 0.2.0 → 0.3.0
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/commandTriggerCheckResult.d.ts +1 -0
- package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -1
- package/dist/dtos/commandTriggerCheckResult.js +3 -0
- package/dist/dtos/incomingMessage.d.ts +2 -1
- package/dist/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.js +5 -1
- package/dist/dtos/incomingQuery.d.ts +1 -0
- package/dist/dtos/incomingQuery.d.ts.map +1 -1
- package/dist/dtos/incomingQuery.js +1 -0
- package/dist/dtos/replyInfo.d.ts.map +1 -0
- package/dist/dtos/responses/delay.d.ts +1 -1
- package/dist/dtos/responses/delay.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.d.ts +8 -7
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.js +1 -0
- package/dist/dtos/responses/reaction.d.ts +3 -4
- package/dist/dtos/responses/reaction.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.d.ts +8 -7
- package/dist/dtos/responses/textMessage.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.js +1 -0
- package/dist/dtos/responses/unpin.d.ts +1 -1
- package/dist/dtos/responses/unpin.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.d.ts +8 -7
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.js +1 -0
- package/dist/entities/actions/commandAction.d.ts +1 -1
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +6 -11
- package/dist/entities/actions/inlineQueryAction.d.ts +2 -3
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.d.ts +15 -0
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -0
- package/dist/entities/actions/replyCaptureAction.js +56 -0
- package/dist/entities/actions/scheduledAction.d.ts +1 -1
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/botInstance.d.ts +7 -36
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +5 -162
- package/dist/entities/context/chatContext.d.ts +7 -5
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +21 -3
- package/dist/entities/context/inlineQueryContext.d.ts +7 -3
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.js +0 -11
- package/dist/entities/context/messageContext.d.ts +6 -6
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +10 -4
- package/dist/entities/context/replyContext.d.ts +113 -0
- package/dist/entities/context/replyContext.d.ts.map +1 -0
- package/dist/entities/context/replyContext.js +108 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +5 -9
- package/dist/services/actionProcessingService.d.ts +25 -0
- package/dist/services/actionProcessingService.d.ts.map +1 -0
- package/dist/services/actionProcessingService.js +40 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +28 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/commandActionProcessor.js +116 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +20 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +74 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts +21 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -0
- package/dist/services/actionProcessors/scheduledActionProcessor.js +69 -0
- package/dist/services/jsonFileStorage.d.ts +1 -1
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/telegramApi.d.ts +5 -1
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +18 -8
- package/dist/types/{actionWithState.d.ts → action.d.ts} +5 -3
- package/dist/types/action.d.ts.map +1 -0
- package/dist/types/capture.d.ts +14 -0
- package/dist/types/capture.d.ts.map +1 -0
- package/dist/types/response.d.ts +9 -6
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/storage.d.ts +1 -1
- package/dist/types/storage.d.ts.map +1 -1
- package/dtos/commandTriggerCheckResult.ts +3 -0
- package/dtos/incomingMessage.ts +7 -2
- package/dtos/incomingQuery.ts +2 -0
- package/dtos/responses/delay.ts +1 -1
- package/dtos/responses/imageMessage.ts +11 -7
- package/dtos/responses/reaction.ts +3 -4
- package/dtos/responses/textMessage.ts +11 -7
- package/dtos/responses/unpin.ts +1 -1
- package/dtos/responses/videoMessage.ts +11 -7
- package/entities/actions/commandAction.ts +11 -18
- package/entities/actions/inlineQueryAction.ts +2 -3
- package/entities/actions/replyCaptureAction.ts +104 -0
- package/entities/actions/scheduledAction.ts +1 -1
- package/entities/botInstance.ts +19 -347
- package/entities/context/chatContext.ts +59 -29
- package/entities/context/inlineQueryContext.ts +7 -22
- package/entities/context/messageContext.ts +36 -29
- package/entities/context/replyContext.ts +225 -0
- package/main.ts +11 -10
- package/package.json +1 -1
- package/services/actionProcessingService.ts +123 -0
- package/services/actionProcessors/commandActionProcessor.ts +242 -0
- package/services/actionProcessors/inlineQueryActionProcessor.ts +176 -0
- package/services/actionProcessors/scheduledActionProcessor.ts +145 -0
- package/services/jsonFileStorage.ts +1 -1
- package/services/telegramApi.ts +45 -17
- package/types/{statefulAction.ts → action.ts} +6 -2
- package/types/capture.ts +21 -0
- package/types/response.ts +10 -6
- package/types/storage.ts +1 -1
- package/dist/types/actionWithState.d.ts.map +0 -1
- package/dist/types/replyInfo.d.ts.map +0 -1
- package/dist/types/statefulAction.d.ts +0 -9
- package/dist/types/statefulAction.d.ts.map +0 -1
- package/dist/types/statelessAction.d.ts +0 -5
- package/dist/types/statelessAction.d.ts.map +0 -1
- package/dist/types/statelessAction.js +0 -2
- package/types/statelessAction.ts +0 -5
- /package/dist/{types → dtos}/replyInfo.d.ts +0 -0
- /package/dist/{types → dtos}/replyInfo.js +0 -0
- /package/dist/types/{actionWithState.js → action.js} +0 -0
- /package/dist/types/{statefulAction.js → capture.js} +0 -0
- /package/{types → dtos}/replyInfo.ts +0 -0
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.BotInstance = void 0;
|
|
7
|
-
const telegraf_1 = require("telegraf");
|
|
8
|
-
const timeConvertions_1 = require("../helpers/timeConvertions");
|
|
9
4
|
const jsonFileStorage_1 = require("../services/jsonFileStorage");
|
|
10
|
-
const telegramApi_1 = require("../services/telegramApi");
|
|
11
5
|
const jsonLogger_1 = require("../services/jsonLogger");
|
|
12
|
-
const incomingMessage_1 = require("../dtos/incomingMessage");
|
|
13
|
-
const moment_1 = __importDefault(require("moment"));
|
|
14
|
-
const chatContext_1 = require("./context/chatContext");
|
|
15
|
-
const messageContext_1 = require("./context/messageContext");
|
|
16
|
-
const chatInfo_1 = require("../dtos/chatInfo");
|
|
17
6
|
const nodeTimeoutScheduler_1 = require("../services/nodeTimeoutScheduler");
|
|
18
7
|
const traceFactory_1 = require("../helpers/traceFactory");
|
|
19
|
-
const
|
|
20
|
-
const inlineQueryContext_1 = require("./context/inlineQueryContext");
|
|
21
|
-
const helpAction_1 = require("../builtin/helpAction");
|
|
22
|
-
const messageTypes_1 = require("../types/messageTypes");
|
|
8
|
+
const actionProcessingService_1 = require("../services/actionProcessingService");
|
|
23
9
|
class BotInstance {
|
|
24
10
|
constructor(options) {
|
|
25
11
|
const actions = [
|
|
@@ -27,8 +13,6 @@ class BotInstance {
|
|
|
27
13
|
...options.actions.scheduled
|
|
28
14
|
];
|
|
29
15
|
this.name = options.name;
|
|
30
|
-
this.chats = options.chats;
|
|
31
|
-
this.telegraf = new telegraf_1.Telegraf(options.token);
|
|
32
16
|
this.logger = options.services?.logger ?? new jsonLogger_1.JsonLogger();
|
|
33
17
|
this.scheduler =
|
|
34
18
|
options.services?.scheduler ??
|
|
@@ -36,159 +20,18 @@ class BotInstance {
|
|
|
36
20
|
this.storage =
|
|
37
21
|
options.services?.storageClient ??
|
|
38
22
|
new jsonFileStorage_1.JsonFileStorage(options.name, actions, options.storagePath);
|
|
39
|
-
this.
|
|
23
|
+
this.actionProcessingService = new actionProcessingService_1.ActionProcessingService(this.name, options.chats, this.storage, this.scheduler, this.logger);
|
|
40
24
|
this.storage.saveMetadata(actions, this.name);
|
|
41
25
|
}
|
|
42
|
-
async start(
|
|
43
|
-
this.
|
|
44
|
-
this.commands =
|
|
45
|
-
options.actions.commands.length > 0
|
|
46
|
-
? [
|
|
47
|
-
(0, helpAction_1.buildHelpCommand)(options.actions.commands
|
|
48
|
-
.map((x) => x.readmeFactory(this.botInfo.username))
|
|
49
|
-
.filter((x) => !!x), this.botInfo.username),
|
|
50
|
-
...options.actions.commands
|
|
51
|
-
]
|
|
52
|
-
: [];
|
|
53
|
-
this.scheduled = options.actions.scheduled;
|
|
54
|
-
this.inlineQueries = options.actions.inlineQueries;
|
|
55
|
-
this.initializeMessageProcessing(options.verboseLoggingForIncomingMessage ?? false);
|
|
56
|
-
this.initializeInlineQueryProcessing(1000);
|
|
57
|
-
this.initializeScheduledProcessing(options.scheduledPeriod ?? (0, timeConvertions_1.hoursToSeconds)(1));
|
|
58
|
-
this.telegraf.launch();
|
|
26
|
+
async start(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage) {
|
|
27
|
+
this.actionProcessingService.initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage);
|
|
59
28
|
this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Start'), 'System', 'Starting bot...');
|
|
60
29
|
}
|
|
61
|
-
initializeScheduledProcessing(period) {
|
|
62
|
-
if (this.scheduled.length > 0) {
|
|
63
|
-
const now = (0, moment_1.default)();
|
|
64
|
-
if (now.minute() == 0 && now.second() == 0) {
|
|
65
|
-
this.scheduler.createTask('ScheduledProcessing', async () => {
|
|
66
|
-
await this.runScheduled();
|
|
67
|
-
}, (0, timeConvertions_1.secondsToMilliseconds)(period), true, this.name);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
let nextExecutionTime = now.clone().startOf('hour');
|
|
71
|
-
if (now.minute() > 0 || now.second() > 0) {
|
|
72
|
-
nextExecutionTime = nextExecutionTime.add(1, 'hour');
|
|
73
|
-
}
|
|
74
|
-
const delay = nextExecutionTime.diff(now);
|
|
75
|
-
this.scheduler.createOnetimeTask('ScheduledProcessing_OneTime', async () => {
|
|
76
|
-
this.scheduler.createTask('ScheduledProcessing', async () => {
|
|
77
|
-
await this.runScheduled();
|
|
78
|
-
}, (0, timeConvertions_1.secondsToMilliseconds)(period), true, this.name);
|
|
79
|
-
}, delay, this.name);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
initializeInlineQueryProcessing(period) {
|
|
83
|
-
let pendingInlineQueries = [];
|
|
84
|
-
if (this.inlineQueries.length > 0) {
|
|
85
|
-
this.telegraf.on('inline_query', async (ctx) => {
|
|
86
|
-
const query = new incomingQuery_1.IncomingInlineQuery(ctx.inlineQuery.id, ctx.inlineQuery.query, ctx.inlineQuery.from.id, (0, traceFactory_1.createTrace)('InlineQuery', this.name, ctx.inlineQuery.id));
|
|
87
|
-
this.logger.logWithTraceId(this.name, query.traceId, 'Query', `${ctx.inlineQuery.from.username} (${ctx.inlineQuery.from.id}): Query for ${ctx.inlineQuery.query}`);
|
|
88
|
-
pendingInlineQueries = pendingInlineQueries.filter((q) => q.userId != query.userId);
|
|
89
|
-
pendingInlineQueries.push(query);
|
|
90
|
-
});
|
|
91
|
-
this.scheduler.createTask('InlineQueryProcessing', async () => {
|
|
92
|
-
const ctx = new inlineQueryContext_1.InlineQueryContext(this.storage, this.logger, this.scheduler);
|
|
93
|
-
const queriesToProcess = [...pendingInlineQueries];
|
|
94
|
-
pendingInlineQueries = [];
|
|
95
|
-
for (const inlineQuery of queriesToProcess) {
|
|
96
|
-
for (const inlineQueryAction of this.inlineQueries) {
|
|
97
|
-
ctx.initializeContext(inlineQuery.query, inlineQuery.queryId, this.name, inlineQueryAction, inlineQuery.traceId);
|
|
98
|
-
try {
|
|
99
|
-
const responses = await inlineQueryAction.exec(ctx);
|
|
100
|
-
this.api.enqueueBatchedResponses(responses);
|
|
101
|
-
ctx.isInitialized = false;
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
this.logger.errorWithTraceId(ctx.botName, ctx.traceId, 'Unknown', error, ctx);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
this.api.flushResponses();
|
|
109
|
-
}, period, false, this.name);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
initializeMessageProcessing(verboseLoggingForIncomingMessage) {
|
|
113
|
-
if (this.commands.length > 0) {
|
|
114
|
-
const triggersToBeProcessed = new Set(this.commands
|
|
115
|
-
.flatMap((x) => x.triggers)
|
|
116
|
-
.map((x) => typeof x == 'string'
|
|
117
|
-
? x.startsWith(messageTypes_1.INTERNAL_MESSAGE_TYPE_PREFIX)
|
|
118
|
-
? x
|
|
119
|
-
: messageTypes_1.MessageType.Text
|
|
120
|
-
: messageTypes_1.MessageType.Text));
|
|
121
|
-
this.telegraf.on('message', async (ctx) => {
|
|
122
|
-
const msg = new incomingMessage_1.IncomingMessage(ctx.update.message, this.name);
|
|
123
|
-
if (verboseLoggingForIncomingMessage) {
|
|
124
|
-
this.logger.logObjectWithTraceId(this.name, msg.traceId, msg.chatInfo.name, ctx.update.message);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this.logger.logWithTraceId(this.name, msg.traceId, msg.chatInfo.name, `${msg.from?.first_name ?? 'Unknown'} (${msg.from?.id ?? 'Unknown'}): ${msg.text || `<non-text message: ${msg.type}>`}`);
|
|
128
|
-
}
|
|
129
|
-
if (triggersToBeProcessed.has(msg.type))
|
|
130
|
-
await this.processMessage(msg);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
30
|
async stop(code) {
|
|
135
31
|
this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Stop'), 'System', 'Stopping bot...');
|
|
136
32
|
this.scheduler.stopAll();
|
|
137
33
|
await this.storage.close();
|
|
138
|
-
this.
|
|
139
|
-
}
|
|
140
|
-
initializeMessageContext(ctx, action, message) {
|
|
141
|
-
ctx.messageId = message.message_id;
|
|
142
|
-
ctx.messageText = message.text ?? '';
|
|
143
|
-
ctx.messageType = message.type;
|
|
144
|
-
ctx.fromUserId = message.from?.id;
|
|
145
|
-
ctx.fromUserName =
|
|
146
|
-
(message.from?.first_name ?? 'Unknown user') +
|
|
147
|
-
(message.from?.last_name ? ` ${message.from.last_name}` : '');
|
|
148
|
-
ctx.messageUpdateObject = message.updateObject;
|
|
149
|
-
ctx.matchResults = [];
|
|
150
|
-
ctx.startCooldown = true;
|
|
151
|
-
this.initializeChatContext(ctx, action, message.chatInfo, message.traceId);
|
|
152
|
-
}
|
|
153
|
-
initializeChatContext(ctx, action, chatInfo, traceId) {
|
|
154
|
-
ctx.responses = [];
|
|
155
|
-
ctx.isInitialized = true;
|
|
156
|
-
ctx.botName = this.name;
|
|
157
|
-
ctx.action = action;
|
|
158
|
-
ctx.chatInfo = chatInfo;
|
|
159
|
-
ctx.traceId = traceId;
|
|
160
|
-
}
|
|
161
|
-
async runScheduled() {
|
|
162
|
-
const ctx = new chatContext_1.ChatContext(this.storage, this.logger, this.scheduler);
|
|
163
|
-
for (const [chatName, chatId] of Object.entries(this.chats)) {
|
|
164
|
-
for (const scheduledAction of this.scheduled) {
|
|
165
|
-
this.initializeChatContext(ctx, scheduledAction, new chatInfo_1.ChatInfo(chatId, chatName), (0, traceFactory_1.createTrace)(scheduledAction, this.name, `${scheduledAction.key}-${chatId}`));
|
|
166
|
-
try {
|
|
167
|
-
const responses = await scheduledAction.exec(ctx);
|
|
168
|
-
this.api.enqueueBatchedResponses(responses);
|
|
169
|
-
ctx.isInitialized = false;
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
this.logger.errorWithTraceId(ctx.botName, ctx.traceId, chatName, error, ctx);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
this.api.flushResponses();
|
|
177
|
-
}
|
|
178
|
-
async processMessage(msg) {
|
|
179
|
-
const ctx = new messageContext_1.MessageContext(this.storage, this.logger, this.scheduler);
|
|
180
|
-
for (const commandAction of this.commands) {
|
|
181
|
-
this.initializeMessageContext(ctx, commandAction, msg);
|
|
182
|
-
try {
|
|
183
|
-
const responses = await commandAction.exec(ctx);
|
|
184
|
-
this.api.enqueueBatchedResponses(responses);
|
|
185
|
-
ctx.isInitialized = false;
|
|
186
|
-
}
|
|
187
|
-
catch (error) {
|
|
188
|
-
this.logger.errorWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, error, ctx);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
this.api.flushResponses();
|
|
34
|
+
this.actionProcessingService.stop(code);
|
|
192
35
|
}
|
|
193
36
|
}
|
|
194
37
|
exports.BotInstance = BotInstance;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { IStorageClient } from '../../types/storage';
|
|
2
2
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
|
-
import { IActionWithState } from '../../types/
|
|
3
|
+
import { IActionWithState } from '../../types/action';
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
|
-
import { BotResponse } from '../../types/response';
|
|
5
|
+
import { BotResponse, IReplyResponse } from '../../types/response';
|
|
6
6
|
import { Milliseconds } from '../../types/timeValues';
|
|
7
7
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
8
8
|
import { ILogger } from '../../types/logger';
|
|
9
9
|
import { IScheduler } from '../../types/scheduler';
|
|
10
10
|
import { TraceId } from '../../types/trace';
|
|
11
|
+
import { ICaptureController } from '../../types/capture';
|
|
11
12
|
/**
|
|
12
13
|
* Context of action executed in chat.
|
|
13
14
|
*/
|
|
@@ -29,6 +30,7 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
29
30
|
responses: BotResponse[];
|
|
30
31
|
isInitialized: boolean;
|
|
31
32
|
constructor(storage: IStorageClient, logger: ILogger, scheduler: IScheduler);
|
|
33
|
+
protected createCaptureController_TEMP(response: IReplyResponse): ICaptureController;
|
|
32
34
|
/**
|
|
33
35
|
* Collection of actions that send something to chat as a standalone message.
|
|
34
36
|
*/
|
|
@@ -39,21 +41,21 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
39
41
|
* @param text Message contents.
|
|
40
42
|
* @param options Message sending option.
|
|
41
43
|
*/
|
|
42
|
-
text: (text: string, options?: TextMessageSendingOptions) =>
|
|
44
|
+
text: (text: string, options?: TextMessageSendingOptions) => ICaptureController;
|
|
43
45
|
/**
|
|
44
46
|
* Sends image message to chat after action execution is finished.
|
|
45
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.
|
|
46
48
|
* @param name Message contents.
|
|
47
49
|
* @param options Message sending option.
|
|
48
50
|
*/
|
|
49
|
-
image: (name: string, options?: MessageSendingOptions) =>
|
|
51
|
+
image: (name: string, options?: MessageSendingOptions) => ICaptureController;
|
|
50
52
|
/**
|
|
51
53
|
* Sends video/gif message to chat after action execution is finished.
|
|
52
54
|
* 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
55
|
* @param name Message contents.
|
|
54
56
|
* @param options Message sending option.
|
|
55
57
|
*/
|
|
56
|
-
video: (name: string, options?: MessageSendingOptions) =>
|
|
58
|
+
video: (name: string, options?: MessageSendingOptions) => ICaptureController;
|
|
57
59
|
};
|
|
58
60
|
/**
|
|
59
61
|
* Unpins message after action execution is finished.
|
|
@@ -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,
|
|
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,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,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;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAIzD;;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,SAAS,CAAC,4BAA4B,CAClC,QAAQ,EAAE,cAAc,GACzB,kBAAkB;IAmBrB;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAexD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;QAerD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;MAcvD;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAK3B"}
|
|
@@ -26,7 +26,9 @@ class ChatContext {
|
|
|
26
26
|
* @param options Message sending option.
|
|
27
27
|
*/
|
|
28
28
|
text: (text, options) => {
|
|
29
|
-
|
|
29
|
+
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
30
|
+
this.responses.push(response);
|
|
31
|
+
return this.createCaptureController_TEMP(response);
|
|
30
32
|
},
|
|
31
33
|
/**
|
|
32
34
|
* Sends image message to chat after action execution is finished.
|
|
@@ -35,7 +37,9 @@ class ChatContext {
|
|
|
35
37
|
* @param options Message sending option.
|
|
36
38
|
*/
|
|
37
39
|
image: (name, options) => {
|
|
38
|
-
|
|
40
|
+
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
41
|
+
this.responses.push(response);
|
|
42
|
+
return this.createCaptureController_TEMP(response);
|
|
39
43
|
},
|
|
40
44
|
/**
|
|
41
45
|
* Sends video/gif message to chat after action execution is finished.
|
|
@@ -44,13 +48,27 @@ class ChatContext {
|
|
|
44
48
|
* @param options Message sending option.
|
|
45
49
|
*/
|
|
46
50
|
video: (name, options) => {
|
|
47
|
-
|
|
51
|
+
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
52
|
+
this.responses.push(response);
|
|
53
|
+
return this.createCaptureController_TEMP(response);
|
|
48
54
|
}
|
|
49
55
|
};
|
|
50
56
|
this.storage = storage;
|
|
51
57
|
this.logger = logger;
|
|
52
58
|
this.scheduler = scheduler;
|
|
53
59
|
}
|
|
60
|
+
createCaptureController_TEMP(response) {
|
|
61
|
+
return {
|
|
62
|
+
captureReplies: (trigger, handler, abortController) => {
|
|
63
|
+
response.captures.push({
|
|
64
|
+
trigger,
|
|
65
|
+
handler,
|
|
66
|
+
abortController,
|
|
67
|
+
action: this.action
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
54
72
|
/**
|
|
55
73
|
* Unpins message after action execution is finished.
|
|
56
74
|
* 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.
|
|
@@ -6,8 +6,8 @@ import { IStorageClient } from '../../types/storage';
|
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
|
7
7
|
import { InlineQueryAction } from '../actions/inlineQueryAction';
|
|
8
8
|
export declare class InlineQueryContext {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
action: InlineQueryAction;
|
|
10
|
+
queryResults: InlineQueryResult[];
|
|
11
11
|
/** Storage client instance for the bot executing this action. */
|
|
12
12
|
readonly storage: IStorageClient;
|
|
13
13
|
/** Logger instance for the bot executing this action */
|
|
@@ -18,6 +18,11 @@ export declare class InlineQueryContext {
|
|
|
18
18
|
traceId: TraceId;
|
|
19
19
|
/** Name of a bot that executes this action. */
|
|
20
20
|
botName: string;
|
|
21
|
+
/**
|
|
22
|
+
* Abort signal to be utilized in query handler.
|
|
23
|
+
* Signal will be aborted if new query comes from the same user.
|
|
24
|
+
*/
|
|
25
|
+
abortSignal: AbortSignal;
|
|
21
26
|
/** Ordered collection of responses to be processed */
|
|
22
27
|
get responses(): BotResponse[];
|
|
23
28
|
/** Inline query text */
|
|
@@ -28,7 +33,6 @@ export declare class InlineQueryContext {
|
|
|
28
33
|
matchResults: RegExpMatchArray[];
|
|
29
34
|
isInitialized: boolean;
|
|
30
35
|
constructor(storage: IStorageClient, logger: ILogger, scheduler: IScheduler);
|
|
31
|
-
initializeContext(queryText: string, queryId: string, botName: string, action: InlineQueryAction, traceId: TraceId): this;
|
|
32
36
|
/**
|
|
33
37
|
* This result will be shown to user as a response to inline query.
|
|
34
38
|
* @param queryResult Inline query result to be shown to user.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,qBAAa,kBAAkB;IAC3B,
|
|
1
|
+
{"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAGjE,qBAAa,kBAAkB;IAC3B,MAAM,EAAG,iBAAiB,CAAC;IAC3B,YAAY,EAAE,iBAAiB,EAAE,CAAM;IAEvC,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;;;OAGG;IACH,WAAW,EAAG,WAAW,CAAC;IAE1B,uDAAuD;IACvD,IAAI,SAAS,IAAI,WAAW,EAAE,CAS7B;IACD,wBAAwB;IACxB,SAAS,EAAG,MAAM,CAAC;IACnB,wBAAwB;IACxB,OAAO,EAAG,MAAM,CAAC;IACjB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IAEtC,aAAa,UAAS;gBAGlB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAOzB;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,iBAAiB;CAGvD"}
|
|
@@ -18,17 +18,6 @@ class InlineQueryContext {
|
|
|
18
18
|
this.logger = logger;
|
|
19
19
|
this.scheduler = scheduler;
|
|
20
20
|
}
|
|
21
|
-
initializeContext(queryText, queryId, botName, action, traceId) {
|
|
22
|
-
this.queryText = queryText;
|
|
23
|
-
this.queryId = queryId;
|
|
24
|
-
this.botName = botName;
|
|
25
|
-
this.action = action;
|
|
26
|
-
this.traceId = traceId;
|
|
27
|
-
this.isInitialized = true;
|
|
28
|
-
this.queryResults = [];
|
|
29
|
-
this.matchResults = [];
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
21
|
/**
|
|
33
22
|
* This result will be shown to user as a response to inline query.
|
|
34
23
|
* @param queryResult Inline query result to be shown to user.
|
|
@@ -51,21 +51,21 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
51
51
|
* @param text Message contents.
|
|
52
52
|
* @param options Message sending option.
|
|
53
53
|
*/
|
|
54
|
-
withText: (text: string, options?: TextMessageSendingOptions) =>
|
|
54
|
+
withText: (text: string, options?: TextMessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
55
55
|
/**
|
|
56
56
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
57
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
58
|
* @param text Message contents.
|
|
59
59
|
* @param options Message sending option.
|
|
60
60
|
*/
|
|
61
|
-
withImage: (name: string, options?: MessageSendingOptions) =>
|
|
61
|
+
withImage: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
62
62
|
/**
|
|
63
63
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
64
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
65
|
* @param text Message contents.
|
|
66
66
|
* @param options Message sending option.
|
|
67
67
|
*/
|
|
68
|
-
withVideo: (name: string, options?: MessageSendingOptions) =>
|
|
68
|
+
withVideo: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
69
69
|
};
|
|
70
70
|
/**
|
|
71
71
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -73,21 +73,21 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
73
73
|
* @param text Message contents.
|
|
74
74
|
* @param options Message sending option.
|
|
75
75
|
*/
|
|
76
|
-
withText: (text: string, options?: TextMessageSendingOptions) =>
|
|
76
|
+
withText: (text: string, options?: TextMessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
77
77
|
/**
|
|
78
78
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
79
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
80
|
* @param text Message contents.
|
|
81
81
|
* @param options Message sending option.
|
|
82
82
|
*/
|
|
83
|
-
withImage: (name: string, options?: MessageSendingOptions) =>
|
|
83
|
+
withImage: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
84
84
|
/**
|
|
85
85
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
86
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
87
|
* @param text Message contents.
|
|
88
88
|
* @param options Message sending option.
|
|
89
89
|
*/
|
|
90
|
-
withVideo: (name: string, options?: MessageSendingOptions) =>
|
|
90
|
+
withVideo: (name: string, options?: MessageSendingOptions) => import("../../types/capture").ICaptureController;
|
|
91
91
|
/**
|
|
92
92
|
* React to the message that triggered this action after action execution is finished.
|
|
93
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.
|
|
@@ -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,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;
|
|
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;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;gBAGzC,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAKzB,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,cAAc;IAwBtB;;;;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,7 +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("../../
|
|
11
|
+
const replyInfo_1 = require("../../dtos/replyInfo");
|
|
12
12
|
/**
|
|
13
13
|
* Context of action executed in chat, in response to a message
|
|
14
14
|
*/
|
|
@@ -85,19 +85,25 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
85
85
|
const quotedPart = this.matchResults.length != 0
|
|
86
86
|
? this.matchResults[0][1]
|
|
87
87
|
: this.messageText;
|
|
88
|
-
|
|
88
|
+
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
89
|
+
this.responses.push(response);
|
|
90
|
+
return this.createCaptureController_TEMP(response);
|
|
89
91
|
}
|
|
90
92
|
replyWithImage(name, quote, options) {
|
|
91
93
|
const quotedPart = this.matchResults.length != 0
|
|
92
94
|
? this.matchResults[0][1]
|
|
93
95
|
: this.messageText;
|
|
94
|
-
|
|
96
|
+
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);
|
|
97
|
+
this.responses.push(response);
|
|
98
|
+
return this.createCaptureController_TEMP(response);
|
|
95
99
|
}
|
|
96
100
|
replyWithVideo(name, quote, options) {
|
|
97
101
|
const quotedPart = this.matchResults.length != 0
|
|
98
102
|
? this.matchResults[0][1]
|
|
99
103
|
: this.messageText;
|
|
100
|
-
|
|
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);
|
|
105
|
+
this.responses.push(response);
|
|
106
|
+
return this.createCaptureController_TEMP(response);
|
|
101
107
|
}
|
|
102
108
|
/**
|
|
103
109
|
* Loads state of another action. Changes to the loaded state will no affect actual state of other action.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { TelegramEmoji } from 'telegraf/types';
|
|
2
|
+
import { ChatInfo } from '../../dtos/chatInfo';
|
|
3
|
+
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ILogger } from '../../types/logger';
|
|
5
|
+
import { TextMessageSendingOptions, MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
|
+
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
7
|
+
import { BotResponse } from '../../types/response';
|
|
8
|
+
import { IScheduler } from '../../types/scheduler';
|
|
9
|
+
import { IStorageClient } from '../../types/storage';
|
|
10
|
+
import { TraceId } from '../../types/trace';
|
|
11
|
+
import { ReplyCaptureAction } from '../actions/replyCaptureAction';
|
|
12
|
+
export declare class ReplyContext<TParentActionState extends IActionState> {
|
|
13
|
+
action: ReplyCaptureAction<TParentActionState>;
|
|
14
|
+
/** Storage client instance for the bot executing this action. */
|
|
15
|
+
readonly storage: IStorageClient;
|
|
16
|
+
/** Logger instance for the bot executing this action */
|
|
17
|
+
readonly logger: ILogger;
|
|
18
|
+
/** Scheduler instance for the bot executing this action */
|
|
19
|
+
readonly scheduler: IScheduler;
|
|
20
|
+
/** Trace id of a action execution. */
|
|
21
|
+
traceId: TraceId;
|
|
22
|
+
/** Name of a bot that executes this action. */
|
|
23
|
+
botName: string;
|
|
24
|
+
/** Ordered collection of responses to be processed */
|
|
25
|
+
responses: BotResponse[];
|
|
26
|
+
/** Chat information. */
|
|
27
|
+
chatInfo: ChatInfo;
|
|
28
|
+
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
29
|
+
matchResults: RegExpExecArray[];
|
|
30
|
+
/** Id of a message that triggered this action. */
|
|
31
|
+
replyMessageId: number | undefined;
|
|
32
|
+
/** Id of a message that triggered this action. */
|
|
33
|
+
messageId: number;
|
|
34
|
+
/** Type of message being received */
|
|
35
|
+
messageType: MessageTypeValue;
|
|
36
|
+
/** Text of a message that triggered this action. */
|
|
37
|
+
messageText: string;
|
|
38
|
+
/** Id of a user that sent a message that triggered this action. */
|
|
39
|
+
fromUserId: number | undefined;
|
|
40
|
+
/** Name of a user that sent a message that triggered this action. */
|
|
41
|
+
fromUserName: string;
|
|
42
|
+
/** Message object recieved from Telegram */
|
|
43
|
+
messageUpdateObject: TelegrafContextMessage;
|
|
44
|
+
isInitialized: boolean;
|
|
45
|
+
constructor(storage: IStorageClient, logger: ILogger, scheduler: IScheduler);
|
|
46
|
+
private replyWithText;
|
|
47
|
+
private replyWithImage;
|
|
48
|
+
private replyWithVideo;
|
|
49
|
+
/**
|
|
50
|
+
* Stops capturing replies and removes this action
|
|
51
|
+
*/
|
|
52
|
+
stopCapture(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
55
|
+
*/
|
|
56
|
+
reply: {
|
|
57
|
+
/**
|
|
58
|
+
* Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
|
|
59
|
+
* If regex is matched, first match will be quoted
|
|
60
|
+
*/
|
|
61
|
+
andQuote: {
|
|
62
|
+
/**
|
|
63
|
+
* Reply with text 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
|
+
withText: (text: string, options?: TextMessageSendingOptions) => void;
|
|
69
|
+
/**
|
|
70
|
+
* Reply with image message to message that triggered this action after action execution is finished.
|
|
71
|
+
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
72
|
+
* @param text Message contents.
|
|
73
|
+
* @param options Message sending option.
|
|
74
|
+
*/
|
|
75
|
+
withImage: (name: string, options?: MessageSendingOptions) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
78
|
+
* 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
|
+
* @param text Message contents.
|
|
80
|
+
* @param options Message sending option.
|
|
81
|
+
*/
|
|
82
|
+
withVideo: (name: string, options?: MessageSendingOptions) => void;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Reply with text 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
|
+
withText: (text: string, options?: TextMessageSendingOptions) => void;
|
|
91
|
+
/**
|
|
92
|
+
* Reply with image message to 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 text Message contents.
|
|
95
|
+
* @param options Message sending option.
|
|
96
|
+
*/
|
|
97
|
+
withImage: (name: string, options?: MessageSendingOptions) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
100
|
+
* 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.
|
|
101
|
+
* @param text Message contents.
|
|
102
|
+
* @param options Message sending option.
|
|
103
|
+
*/
|
|
104
|
+
withVideo: (name: string, options?: MessageSendingOptions) => void;
|
|
105
|
+
/**
|
|
106
|
+
* React to the message that triggered this action after action execution is finished.
|
|
107
|
+
* 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.
|
|
108
|
+
* @param emoji Telegram emoji to react with.
|
|
109
|
+
*/
|
|
110
|
+
withReaction: (emoji: TelegramEmoji) => void;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=replyContext.d.ts.map
|
|
@@ -0,0 +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,qBAAqB,CAAC;AAM/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAGnE,qBAAa,YAAY,CAAC,kBAAkB,SAAS,YAAY;IAC7D,MAAM,EAAG,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IAEhD,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;IAEjB,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;gBAGlB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAOzB,OAAO,CAAC,aAAa;IAsBrB,OAAO,CAAC,cAAc;IAsBtB,OAAO,CAAC,cAAc;IAsBtB;;OAEG;IACH,WAAW;IAIX;;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"}
|