chz-telegram-bot 0.3.1 → 0.3.3
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/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +3 -2
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
- package/dist/entities/actions/inlineQueryAction.js +1 -1
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.js +1 -1
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +1 -1
- package/dist/entities/context/chatContext.d.ts +10 -4
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +18 -6
- package/dist/entities/context/inlineQueryContext.d.ts +4 -4
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.js +1 -2
- package/dist/entities/context/messageContext.d.ts +1 -8
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +5 -20
- package/dist/entities/context/replyContext.d.ts +4 -4
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +1 -2
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +12 -8
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +7 -5
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/scheduledActionProcessor.js +3 -2
- package/dist/services/jsonLogger.d.ts +3 -2
- package/dist/services/jsonLogger.d.ts.map +1 -1
- package/dist/services/jsonLogger.js +8 -4
- package/dist/services/telegramApi.d.ts +1 -0
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +23 -6
- package/dist/types/capture.d.ts +11 -1
- package/dist/types/capture.d.ts.map +1 -1
- package/dist/types/commandCondition.d.ts +5 -1
- package/dist/types/commandCondition.d.ts.map +1 -1
- package/dist/types/logger.d.ts +6 -0
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/messageTypes.d.ts +1 -0
- package/dist/types/messageTypes.d.ts.map +1 -1
- package/dist/types/messageTypes.js +1 -0
- package/entities/actions/commandAction.ts +2 -4
- package/entities/actions/inlineQueryAction.ts +1 -6
- package/entities/actions/replyCaptureAction.ts +0 -3
- package/entities/actions/scheduledAction.ts +0 -3
- package/entities/context/chatContext.ts +25 -12
- package/entities/context/inlineQueryContext.ts +4 -9
- package/entities/context/messageContext.ts +5 -34
- package/entities/context/replyContext.ts +4 -9
- package/package.json +1 -1
- package/services/actionProcessors/commandActionProcessor.ts +28 -32
- package/services/actionProcessors/inlineQueryActionProcessor.ts +10 -18
- package/services/actionProcessors/scheduledActionProcessor.ts +8 -12
- package/services/jsonLogger.ts +20 -4
- package/services/telegramApi.ts +40 -11
- package/types/capture.ts +7 -0
- package/types/commandCondition.ts +2 -0
- package/types/logger.ts +20 -0
- package/types/messageTypes.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"commandAction.d.ts","sourceRoot":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AAO,EACjB,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY,EACpC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAgBxC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;IA+C5C,OAAO,CAAC,uBAAuB;IA+B/B,OAAO,CAAC,YAAY;CAmCvB"}
|
|
@@ -9,6 +9,7 @@ const timeConvertions_1 = require("../../helpers/timeConvertions");
|
|
|
9
9
|
const toArray_1 = require("../../helpers/toArray");
|
|
10
10
|
const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResult");
|
|
11
11
|
const noop_1 = require("../../helpers/noop");
|
|
12
|
+
const messageTypes_1 = require("../../types/messageTypes");
|
|
12
13
|
class CommandAction {
|
|
13
14
|
constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor, readmeFactory) {
|
|
14
15
|
this.triggers = (0, toArray_1.toArray)(trigger);
|
|
@@ -34,7 +35,7 @@ class CommandAction {
|
|
|
34
35
|
.reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger);
|
|
35
36
|
if (!shouldExecute)
|
|
36
37
|
return noop_1.Noop.NoResponse;
|
|
37
|
-
ctx.logger.logWithTraceId(
|
|
38
|
+
ctx.logger.logWithTraceId(` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
|
|
38
39
|
ctx.matchResults = matchResults;
|
|
39
40
|
await this.handler(ctx, state);
|
|
40
41
|
if (skipCooldown) {
|
|
@@ -64,7 +65,7 @@ class CommandAction {
|
|
|
64
65
|
return this.checkTrigger(ctx, trigger);
|
|
65
66
|
}
|
|
66
67
|
checkTrigger(ctx, trigger) {
|
|
67
|
-
if (trigger == ctx.messageType)
|
|
68
|
+
if (trigger == messageTypes_1.MessageType.Any || trigger == ctx.messageType)
|
|
68
69
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger;
|
|
69
70
|
if (typeof trigger == 'string')
|
|
70
71
|
return ctx.messageText.toLowerCase() == trigger.toLowerCase()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,kBAAkB;
|
|
1
|
+
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/inlineQueryAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAGrB,OAAO,EAAE,kBAAkB,EAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,kBAAkB;CAmCrC"}
|
|
@@ -32,7 +32,7 @@ class InlineQueryAction {
|
|
|
32
32
|
if (matchResults.length == 0)
|
|
33
33
|
return noop_1.Noop.NoResponse;
|
|
34
34
|
ctx.matchResults = matchResults;
|
|
35
|
-
ctx.logger.logWithTraceId(
|
|
35
|
+
ctx.logger.logWithTraceId(` - Executing [${this.name}]`);
|
|
36
36
|
await this.handler(ctx);
|
|
37
37
|
return ctx.responses;
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/replyCaptureAction.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,kBAAkB,CAAC,kBAAkB,SAAS,YAAY,CACnE,YAAW,OAAO;IAElB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,CACd,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE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AE,YAAY,CAAC,kBAAkB,CAAC;IAyBhD,OAAO,CAAC,uBAAuB;CAsClC"}
|
|
@@ -21,7 +21,7 @@ class ReplyCaptureAction {
|
|
|
21
21
|
.reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger);
|
|
22
22
|
if (!shouldExecute)
|
|
23
23
|
return noop_1.Noop.NoResponse;
|
|
24
|
-
ctx.logger.logWithTraceId(
|
|
24
|
+
ctx.logger.logWithTraceId(` - Executing [${this.key}] in ${ctx.chatInfo.id}`);
|
|
25
25
|
ctx.matchResults = matchResults;
|
|
26
26
|
await this.handler(ctx);
|
|
27
27
|
return ctx.responses;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAIrD,qBAAa,eAAe,CAAC,YAAY,SAAS,YAAY,CAC1D,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,MAAM,CAAC,QAAQ,CAAC,KAAK,yBAAgC;IAErD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,C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AQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG7C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACvC,WAAW,EAAE,UAAU,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAYlC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;YAuC3B,cAAc;IA+C5B,OAAO,CAAC,uBAAuB;CAalC"}
|
|
@@ -29,7 +29,7 @@ class ScheduledAction {
|
|
|
29
29
|
const isAllowedToTrigger = this.checkIfShouldBeExecuted(state);
|
|
30
30
|
if (!isAllowedToTrigger)
|
|
31
31
|
return noop_1.Noop.NoResponse;
|
|
32
|
-
ctx.logger.logWithTraceId(
|
|
32
|
+
ctx.logger.logWithTraceId(` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
|
|
33
33
|
await this.handler(ctx, (key) => this.getCachedValue(key, ctx.botName, ctx.scheduler), state);
|
|
34
34
|
state.lastExecutedDate = (0, moment_1.default)().valueOf();
|
|
35
35
|
await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
|
|
@@ -5,7 +5,7 @@ import { IActionState } from '../../types/actionState';
|
|
|
5
5
|
import { BotResponse, IReplyResponse } from '../../types/response';
|
|
6
6
|
import { Milliseconds } from '../../types/timeValues';
|
|
7
7
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
8
|
-
import {
|
|
8
|
+
import { IScopedLogger } from '../../types/logger';
|
|
9
9
|
import { IScheduler } from '../../types/scheduler';
|
|
10
10
|
import { TraceId } from '../../types/trace';
|
|
11
11
|
import { ICaptureController } from '../../types/capture';
|
|
@@ -17,9 +17,9 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
17
17
|
/** Storage client instance for the bot executing this action. */
|
|
18
18
|
readonly storage: IStorageClient;
|
|
19
19
|
/** Logger instance for the bot executing this action */
|
|
20
|
-
readonly logger: ILogger;
|
|
21
20
|
/** Scheduler instance for the bot executing this action */
|
|
22
21
|
readonly scheduler: IScheduler;
|
|
22
|
+
logger: IScopedLogger;
|
|
23
23
|
/** Trace id of a action execution. */
|
|
24
24
|
traceId: TraceId;
|
|
25
25
|
/** Name of a bot that executes this action. */
|
|
@@ -29,8 +29,14 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
29
29
|
/** Ordered collection of responses to be processed */
|
|
30
30
|
responses: BotResponse[];
|
|
31
31
|
isInitialized: boolean;
|
|
32
|
-
constructor(storage: IStorageClient,
|
|
33
|
-
protected
|
|
32
|
+
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
33
|
+
protected createCaptureController(response: IReplyResponse): ICaptureController;
|
|
34
|
+
/**
|
|
35
|
+
* Loads state of another action for current chat.
|
|
36
|
+
* @param action Action to load state of.
|
|
37
|
+
* @template TAnotherActionState - Type of a state that is used by another action.
|
|
38
|
+
*/
|
|
39
|
+
loadStateOf<TAnotherActionState extends IActionState>(action: IActionWithState<TAnotherActionState>): Promise<Readonly<TAnotherActionState>>;
|
|
34
40
|
/**
|
|
35
41
|
* Collection of actions that send something to chat as a standalone message.
|
|
36
42
|
*/
|
|
@@ -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,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,
|
|
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,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,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,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAE/B,MAAM,EAAG,aAAa,CAAC;IACvB,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;gBAEV,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAK1D,SAAS,CAAC,uBAAuB,CAC7B,QAAQ,EAAE,cAAc,GACzB,kBAAkB;IAmBrB;;;;OAIG;IACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,MAAM,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;IAYjD;;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"}
|
|
@@ -11,7 +11,7 @@ const delay_1 = require("../../dtos/responses/delay");
|
|
|
11
11
|
* Context of action executed in chat.
|
|
12
12
|
*/
|
|
13
13
|
class ChatContext {
|
|
14
|
-
constructor(storage,
|
|
14
|
+
constructor(storage, scheduler) {
|
|
15
15
|
/** Ordered collection of responses to be processed */
|
|
16
16
|
this.responses = [];
|
|
17
17
|
this.isInitialized = false;
|
|
@@ -28,7 +28,7 @@ class ChatContext {
|
|
|
28
28
|
text: (text, options) => {
|
|
29
29
|
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
30
30
|
this.responses.push(response);
|
|
31
|
-
return this.
|
|
31
|
+
return this.createCaptureController(response);
|
|
32
32
|
},
|
|
33
33
|
/**
|
|
34
34
|
* Sends image message to chat after action execution is finished.
|
|
@@ -39,7 +39,7 @@ class ChatContext {
|
|
|
39
39
|
image: (name, options) => {
|
|
40
40
|
const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
41
41
|
this.responses.push(response);
|
|
42
|
-
return this.
|
|
42
|
+
return this.createCaptureController(response);
|
|
43
43
|
},
|
|
44
44
|
/**
|
|
45
45
|
* Sends video/gif message to chat after action execution is finished.
|
|
@@ -50,14 +50,13 @@ class ChatContext {
|
|
|
50
50
|
video: (name, options) => {
|
|
51
51
|
const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
|
|
52
52
|
this.responses.push(response);
|
|
53
|
-
return this.
|
|
53
|
+
return this.createCaptureController(response);
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
56
|
this.storage = storage;
|
|
57
|
-
this.logger = logger;
|
|
58
57
|
this.scheduler = scheduler;
|
|
59
58
|
}
|
|
60
|
-
|
|
59
|
+
createCaptureController(response) {
|
|
61
60
|
return {
|
|
62
61
|
captureReplies: (trigger, handler, abortController) => {
|
|
63
62
|
response.captures.push({
|
|
@@ -69,6 +68,19 @@ class ChatContext {
|
|
|
69
68
|
}
|
|
70
69
|
};
|
|
71
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Loads state of another action for current chat.
|
|
73
|
+
* @param action Action to load state of.
|
|
74
|
+
* @template TAnotherActionState - Type of a state that is used by another action.
|
|
75
|
+
*/
|
|
76
|
+
async loadStateOf(action) {
|
|
77
|
+
const allStates = await this.storage.load(action.key);
|
|
78
|
+
const stateForChat = allStates[this.chatInfo.id];
|
|
79
|
+
if (!stateForChat) {
|
|
80
|
+
return Object.freeze(action.stateConstructor());
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze(stateForChat);
|
|
83
|
+
}
|
|
72
84
|
/**
|
|
73
85
|
* Unpins message after action execution is finished.
|
|
74
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.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InlineQueryResult } from 'telegraf/types';
|
|
2
|
-
import {
|
|
2
|
+
import { IScopedLogger } from '../../types/logger';
|
|
3
3
|
import { BotResponse } from '../../types/response';
|
|
4
4
|
import { IScheduler } from '../../types/scheduler';
|
|
5
5
|
import { IStorageClient } from '../../types/storage';
|
|
@@ -10,10 +10,10 @@ export declare class InlineQueryContext {
|
|
|
10
10
|
queryResults: InlineQueryResult[];
|
|
11
11
|
/** Storage client instance for the bot executing this action. */
|
|
12
12
|
readonly storage: IStorageClient;
|
|
13
|
-
/** Logger instance for the bot executing this action */
|
|
14
|
-
readonly logger: ILogger;
|
|
15
13
|
/** Scheduler instance for the bot executing this action */
|
|
16
14
|
readonly scheduler: IScheduler;
|
|
15
|
+
/** Logger instance for the bot executing this action */
|
|
16
|
+
logger: IScopedLogger;
|
|
17
17
|
/** Trace id of a action execution. */
|
|
18
18
|
traceId: TraceId;
|
|
19
19
|
/** Name of a bot that executes this action. */
|
|
@@ -32,7 +32,7 @@ export declare class InlineQueryContext {
|
|
|
32
32
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
33
33
|
matchResults: RegExpMatchArray[];
|
|
34
34
|
isInitialized: boolean;
|
|
35
|
-
constructor(storage: IStorageClient,
|
|
35
|
+
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
36
36
|
/**
|
|
37
37
|
* This result will be shown to user as a response to inline query.
|
|
38
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,
|
|
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,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,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,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAE/B,wDAAwD;IACxD,MAAM,EAAG,aAAa,CAAC;IACvB,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;gBAEV,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAK1D;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,iBAAiB;CAGvD"}
|
|
@@ -9,13 +9,12 @@ class InlineQueryContext {
|
|
|
9
9
|
new inlineQueryResponse_1.InlineQueryResponse(this.queryResults, this.queryId, this.traceId, this.action)
|
|
10
10
|
];
|
|
11
11
|
}
|
|
12
|
-
constructor(storage,
|
|
12
|
+
constructor(storage, scheduler) {
|
|
13
13
|
this.queryResults = [];
|
|
14
14
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
15
15
|
this.matchResults = [];
|
|
16
16
|
this.isInitialized = false;
|
|
17
17
|
this.storage = storage;
|
|
18
|
-
this.logger = logger;
|
|
19
18
|
this.scheduler = scheduler;
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
@@ -4,7 +4,6 @@ import { IActionState } from '../../types/actionState';
|
|
|
4
4
|
import { ChatContext } from './chatContext';
|
|
5
5
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
6
|
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
7
|
-
import { ILogger } from '../../types/logger';
|
|
8
7
|
import { IScheduler } from '../../types/scheduler';
|
|
9
8
|
/**
|
|
10
9
|
* Context of action executed in chat, in response to a message
|
|
@@ -26,16 +25,10 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
26
25
|
messageType: MessageTypeValue;
|
|
27
26
|
/** Message object recieved from Telegram */
|
|
28
27
|
messageUpdateObject: TelegrafContextMessage;
|
|
29
|
-
constructor(storage: IStorageClient,
|
|
28
|
+
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
30
29
|
private replyWithText;
|
|
31
30
|
private replyWithImage;
|
|
32
31
|
private replyWithVideo;
|
|
33
|
-
/**
|
|
34
|
-
* Loads state of another action. Changes to the loaded state will no affect actual state of other action.
|
|
35
|
-
* @param commandName Name of an action to load state of.
|
|
36
|
-
* @template TAnotherActionState - Type of a state that is used by another action.
|
|
37
|
-
*/
|
|
38
|
-
loadStateOf<TAnotherActionState extends IActionState>(commandName: string): Promise<TAnotherActionState>;
|
|
39
32
|
/**
|
|
40
33
|
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
41
34
|
*/
|
|
@@ -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;
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAGnD;;GAEG;AACH,qBAAa,cAAc,CACvB,YAAY,SAAS,YAAY,CACnC,SAAQ,WAAW,CAAC,YAAY,CAAC;IAC/B,kDAAkD;IAClD,SAAS,EAAG,MAAM,CAAC;IACnB,oDAAoD;IACpD,WAAW,EAAG,MAAM,CAAC;IACrB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,mEAAmE;IACnE,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,qEAAqE;IACrE,YAAY,EAAG,MAAM,CAAC;IACtB,qCAAqC;IACrC,WAAW,EAAG,gBAAgB,CAAC;IAC/B,4CAA4C;IAC5C,mBAAmB,EAAG,sBAAsB,CAAC;gBAEjC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAI1D,OAAO,CAAC,aAAa;IAwBrB,OAAO,CAAC,cAAc;IAwBtB,OAAO,CAAC,cAAc;IAwBtB;;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"}
|
|
@@ -6,15 +6,14 @@ const imageMessage_1 = require("../../dtos/responses/imageMessage");
|
|
|
6
6
|
const reaction_1 = require("../../dtos/responses/reaction");
|
|
7
7
|
const textMessage_1 = require("../../dtos/responses/textMessage");
|
|
8
8
|
const videoMessage_1 = require("../../dtos/responses/videoMessage");
|
|
9
|
-
const actionStateBase_1 = require("../states/actionStateBase");
|
|
10
9
|
const chatContext_1 = require("./chatContext");
|
|
11
10
|
const replyInfo_1 = require("../../dtos/replyInfo");
|
|
12
11
|
/**
|
|
13
12
|
* Context of action executed in chat, in response to a message
|
|
14
13
|
*/
|
|
15
14
|
class MessageContext extends chatContext_1.ChatContext {
|
|
16
|
-
constructor(storage,
|
|
17
|
-
super(storage,
|
|
15
|
+
constructor(storage, scheduler) {
|
|
16
|
+
super(storage, scheduler);
|
|
18
17
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
19
18
|
this.matchResults = [];
|
|
20
19
|
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
@@ -87,7 +86,7 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
87
86
|
: this.messageText;
|
|
88
87
|
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageId, quote ? quotedPart : undefined), options);
|
|
89
88
|
this.responses.push(response);
|
|
90
|
-
return this.
|
|
89
|
+
return this.createCaptureController(response);
|
|
91
90
|
}
|
|
92
91
|
replyWithImage(name, quote, options) {
|
|
93
92
|
const quotedPart = this.matchResults.length != 0
|
|
@@ -95,7 +94,7 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
95
94
|
: this.messageText;
|
|
96
95
|
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
96
|
this.responses.push(response);
|
|
98
|
-
return this.
|
|
97
|
+
return this.createCaptureController(response);
|
|
99
98
|
}
|
|
100
99
|
replyWithVideo(name, quote, options) {
|
|
101
100
|
const quotedPart = this.matchResults.length != 0
|
|
@@ -103,21 +102,7 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
103
102
|
: this.messageText;
|
|
104
103
|
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
104
|
this.responses.push(response);
|
|
106
|
-
return this.
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Loads state of another action. Changes to the loaded state will no affect actual state of other action.
|
|
110
|
-
* @param commandName Name of an action to load state of.
|
|
111
|
-
* @template TAnotherActionState - Type of a state that is used by another action.
|
|
112
|
-
*/
|
|
113
|
-
async loadStateOf(commandName) {
|
|
114
|
-
const storageKey = `command:${commandName.replace('.', '-')}`;
|
|
115
|
-
const allStates = await this.storage.load(storageKey);
|
|
116
|
-
const stateForChat = allStates[this.chatInfo.id];
|
|
117
|
-
if (!stateForChat) {
|
|
118
|
-
return new actionStateBase_1.ActionStateBase();
|
|
119
|
-
}
|
|
120
|
-
return stateForChat;
|
|
105
|
+
return this.createCaptureController(response);
|
|
121
106
|
}
|
|
122
107
|
}
|
|
123
108
|
exports.MessageContext = MessageContext;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { TelegramEmoji } from 'telegraf/types';
|
|
2
2
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
|
-
import {
|
|
4
|
+
import { IScopedLogger } from '../../types/logger';
|
|
5
5
|
import { TextMessageSendingOptions, MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
6
6
|
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
7
7
|
import { BotResponse } from '../../types/response';
|
|
@@ -13,14 +13,14 @@ export declare class ReplyContext<TParentActionState extends IActionState> {
|
|
|
13
13
|
action: ReplyCaptureAction<TParentActionState>;
|
|
14
14
|
/** Storage client instance for the bot executing this action. */
|
|
15
15
|
readonly storage: IStorageClient;
|
|
16
|
-
/** Logger instance for the bot executing this action */
|
|
17
|
-
readonly logger: ILogger;
|
|
18
16
|
/** Scheduler instance for the bot executing this action */
|
|
19
17
|
readonly scheduler: IScheduler;
|
|
20
18
|
/** Trace id of a action execution. */
|
|
21
19
|
traceId: TraceId;
|
|
22
20
|
/** Name of a bot that executes this action. */
|
|
23
21
|
botName: string;
|
|
22
|
+
/** Logger instance for the bot executing this action */
|
|
23
|
+
logger: IScopedLogger;
|
|
24
24
|
/** Ordered collection of responses to be processed */
|
|
25
25
|
responses: BotResponse[];
|
|
26
26
|
/** Chat information. */
|
|
@@ -42,7 +42,7 @@ export declare class ReplyContext<TParentActionState extends IActionState> {
|
|
|
42
42
|
/** Message object recieved from Telegram */
|
|
43
43
|
messageUpdateObject: TelegrafContextMessage;
|
|
44
44
|
isInitialized: boolean;
|
|
45
|
-
constructor(storage: IStorageClient,
|
|
45
|
+
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
46
46
|
private replyWithText;
|
|
47
47
|
private replyWithImage;
|
|
48
48
|
private replyWithVideo;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,
|
|
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,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,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,iEAAi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G;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 path_1 = require("path");
|
|
10
10
|
class ReplyContext {
|
|
11
|
-
constructor(storage,
|
|
11
|
+
constructor(storage, scheduler) {
|
|
12
12
|
/** Ordered collection of responses to be processed */
|
|
13
13
|
this.responses = [];
|
|
14
14
|
this.isInitialized = false;
|
|
@@ -74,7 +74,6 @@ class ReplyContext {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
this.storage = storage;
|
|
77
|
-
this.logger = logger;
|
|
78
77
|
this.scheduler = scheduler;
|
|
79
78
|
}
|
|
80
79
|
replyWithText(text, quote, options) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/commandActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAKrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAK7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,qBAAa,sBAAsB;IAC/B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,SA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AAa;IACvC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAqC;IAEnE,OAAO,CAAC,GAAG,CAAsB;IACjC,OAAO,CAAC,QAAQ,CAAY;IAC5B,OAAO,CAAC,QAAQ,CAAiC;IAEjD,OAAO,CAAC,8BAA8B,CAAe;gBAGjD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IAUnB,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,EACvC,gCAAgC,EAAE,OAAO;IAoD7C,2BAA2B,CACvB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;YAgCN,cAAc;IAsC5B,OAAO,CAAC,6BAA6B;IA6BrC,OAAO,CAAC,wBAAwB;CA8BnC"}
|
|
@@ -28,11 +28,12 @@ class CommandActionProcessor {
|
|
|
28
28
|
: messageTypes_1.MessageType.Text));
|
|
29
29
|
this.telegraf.on('message', async (ctx) => {
|
|
30
30
|
const msg = new incomingMessage_1.IncomingMessage(ctx.update.message, this.botName);
|
|
31
|
+
const logger = this.logger.createScope(this.botName, msg.traceId, msg.chatInfo.name);
|
|
31
32
|
if (verboseLoggingForIncomingMessage) {
|
|
32
|
-
|
|
33
|
+
logger.logObjectWithTraceId(ctx.update.message);
|
|
33
34
|
}
|
|
34
35
|
else {
|
|
35
|
-
|
|
36
|
+
logger.logWithTraceId(`${msg.from?.first_name ?? 'Unknown'} (${msg.from?.id ?? 'Unknown'}): ${msg.text || `<non-text message: ${msg.type}>`}`);
|
|
36
37
|
}
|
|
37
38
|
if (this.permanentTriggersToBeProcessed.has(msg.type) ||
|
|
38
39
|
this.replyCaptures.find((x) => x.parentMessageId == msg.replyToMessageId))
|
|
@@ -42,16 +43,17 @@ class CommandActionProcessor {
|
|
|
42
43
|
}
|
|
43
44
|
captureRegistrationCallback(capture, parentMessageId, chatInfo, traceId) {
|
|
44
45
|
const replyAction = new replyCaptureAction_1.ReplyCaptureAction(parentMessageId, capture.action, capture.handler, capture.trigger, capture.abortController);
|
|
45
|
-
this.logger.
|
|
46
|
+
const logger = this.logger.createScope(this.botName, traceId, chatInfo.name);
|
|
47
|
+
logger.logWithTraceId(`Starting capturing replies to message ${parentMessageId} with action ${replyAction.key}`);
|
|
46
48
|
this.replyCaptures.push(replyAction);
|
|
47
49
|
capture.abortController.signal.addEventListener('abort', () => {
|
|
48
50
|
const index = this.replyCaptures.indexOf(replyAction);
|
|
49
51
|
this.replyCaptures.splice(index, 1);
|
|
50
|
-
|
|
52
|
+
logger.logWithTraceId(`Stopping capturing replies to message ${parentMessageId} with action ${replyAction.key}`);
|
|
51
53
|
});
|
|
52
54
|
}
|
|
53
55
|
async processMessage(msg) {
|
|
54
|
-
const ctx = new messageContext_1.MessageContext(this.storage, this.
|
|
56
|
+
const ctx = new messageContext_1.MessageContext(this.storage, this.scheduler);
|
|
55
57
|
for (const commandAction of this.commands) {
|
|
56
58
|
this.initializeMessageContext(ctx, commandAction, msg);
|
|
57
59
|
try {
|
|
@@ -60,10 +62,10 @@ class CommandActionProcessor {
|
|
|
60
62
|
ctx.isInitialized = false;
|
|
61
63
|
}
|
|
62
64
|
catch (error) {
|
|
63
|
-
|
|
65
|
+
ctx.logger.errorWithTraceId(error, ctx);
|
|
64
66
|
}
|
|
65
67
|
}
|
|
66
|
-
const replyCtx = new replyContext_1.ReplyContext(this.storage, this.
|
|
68
|
+
const replyCtx = new replyContext_1.ReplyContext(this.storage, this.scheduler);
|
|
67
69
|
for (const replyAction of this.replyCaptures) {
|
|
68
70
|
this.initializeReplyCaptureContext(replyCtx, replyAction, msg);
|
|
69
71
|
try {
|
|
@@ -72,7 +74,7 @@ class CommandActionProcessor {
|
|
|
72
74
|
replyCtx.isInitialized = false;
|
|
73
75
|
}
|
|
74
76
|
catch (error) {
|
|
75
|
-
|
|
77
|
+
replyCtx.logger.errorWithTraceId(error, replyCtx);
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
this.api.flushResponses();
|
|
@@ -93,6 +95,7 @@ class CommandActionProcessor {
|
|
|
93
95
|
ctx.traceId = message.traceId;
|
|
94
96
|
ctx.isInitialized = true;
|
|
95
97
|
ctx.matchResults = [];
|
|
98
|
+
ctx.logger = this.logger.createScope(this.botName, message.traceId, message.chatInfo.name);
|
|
96
99
|
}
|
|
97
100
|
initializeMessageContext(ctx, action, message) {
|
|
98
101
|
ctx.messageId = message.messageId;
|
|
@@ -111,6 +114,7 @@ class CommandActionProcessor {
|
|
|
111
114
|
ctx.action = action;
|
|
112
115
|
ctx.chatInfo = message.chatInfo;
|
|
113
116
|
ctx.traceId = message.traceId;
|
|
117
|
+
ctx.logger = this.logger.createScope(this.botName, message.traceId, message.chatInfo.name);
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
exports.CommandActionProcessor = CommandActionProcessor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/inlineQueryActionProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAG7E,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,qBAA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AY;IAC5B,OAAO,CAAC,aAAa,CAAuB;gBAGxC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IASnB,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,iBAAiB,EAAE,EAClC,MAAM,EAAE,YAAY;IA0GxB,OAAO,CAAC,4BAA4B;CAqBvC"}
|
|
@@ -20,10 +20,11 @@ class InlineQueryActionProcessor {
|
|
|
20
20
|
if (this.inlineQueries.length > 0) {
|
|
21
21
|
this.telegraf.on('inline_query', async (ctx) => {
|
|
22
22
|
const query = new incomingQuery_1.IncomingInlineQuery(ctx.inlineQuery.id, ctx.inlineQuery.query, ctx.inlineQuery.from.id, (0, traceFactory_1.createTrace)('InlineQuery', this.botName, ctx.inlineQuery.id));
|
|
23
|
-
this.logger.
|
|
23
|
+
const logger = this.logger.createScope(this.botName, query.traceId, 'Query');
|
|
24
|
+
logger.logWithTraceId(`${ctx.inlineQuery.from.username} (${ctx.inlineQuery.from.id}): Query for ${ctx.inlineQuery.query}`);
|
|
24
25
|
const queryBeingProcessed = queriesInProcessing.get(query.userId);
|
|
25
26
|
if (queryBeingProcessed) {
|
|
26
|
-
|
|
27
|
+
logger.logWithTraceId(`Aborting query ${queryBeingProcessed.queryId} (${queryBeingProcessed.query}): new query recieved from ${query.userId}`);
|
|
27
28
|
queryBeingProcessed.abortController.abort();
|
|
28
29
|
queriesInProcessing.delete(query.userId);
|
|
29
30
|
}
|
|
@@ -31,7 +32,7 @@ class InlineQueryActionProcessor {
|
|
|
31
32
|
pendingInlineQueries.push(query);
|
|
32
33
|
});
|
|
33
34
|
this.scheduler.createTask('InlineQueryProcessing', async () => {
|
|
34
|
-
const ctx = new inlineQueryContext_1.InlineQueryContext(this.storage, this.
|
|
35
|
+
const ctx = new inlineQueryContext_1.InlineQueryContext(this.storage, this.scheduler);
|
|
35
36
|
const queriesToProcess = [...pendingInlineQueries];
|
|
36
37
|
pendingInlineQueries = [];
|
|
37
38
|
for (const inlineQuery of queriesToProcess) {
|
|
@@ -46,10 +47,10 @@ class InlineQueryActionProcessor {
|
|
|
46
47
|
catch (err) {
|
|
47
48
|
const error = err;
|
|
48
49
|
if (error.name == 'AbortError') {
|
|
49
|
-
|
|
50
|
+
ctx.logger.logWithTraceId(`Aborting query ${inlineQuery.queryId} (${inlineQuery.query}) successful.`);
|
|
50
51
|
}
|
|
51
52
|
else {
|
|
52
|
-
|
|
53
|
+
ctx.logger.errorWithTraceId(error, ctx);
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
}
|
|
@@ -69,6 +70,7 @@ class InlineQueryActionProcessor {
|
|
|
69
70
|
ctx.isInitialized = true;
|
|
70
71
|
ctx.queryResults = [];
|
|
71
72
|
ctx.matchResults = [];
|
|
73
|
+
ctx.logger = this.logger.createScope(this.botName, traceId, 'Unknown');
|
|
72
74
|
}
|
|
73
75
|
}
|
|
74
76
|
exports.InlineQueryActionProcessor = InlineQueryActionProcessor;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledActionProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/scheduledActionProcessor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAKzE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAgB,MAAM,wBAAwB,CAAC;AAE/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,qBAAa,wBAAwB;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO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AC,GAAG,CAAsB;IACjC,OAAO,CAAC,SAAS,CAAmC;gBAGhD,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IAUnB,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,eAAe,CAAC,YAAY,CAAC,EAAE,EAC1C,MAAM,EAAE,OAAO;YAgDL,YAAY;IA6B1B,OAAO,CAAC,qBAAqB;CAmBhC"}
|
|
@@ -41,7 +41,7 @@ class ScheduledActionProcessor {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
async runScheduled() {
|
|
44
|
-
const ctx = new chatContext_1.ChatContext(this.storage, this.
|
|
44
|
+
const ctx = new chatContext_1.ChatContext(this.storage, this.scheduler);
|
|
45
45
|
for (const [chatName, chatId] of Object.entries(this.chats)) {
|
|
46
46
|
for (const scheduledAction of this.scheduled) {
|
|
47
47
|
this.initializeChatContext(ctx, scheduledAction, new chatInfo_1.ChatInfo(chatId, chatName), (0, traceFactory_1.createTrace)(scheduledAction, this.botName, `${scheduledAction.key}-${chatId}`));
|
|
@@ -51,7 +51,7 @@ class ScheduledActionProcessor {
|
|
|
51
51
|
ctx.isInitialized = false;
|
|
52
52
|
}
|
|
53
53
|
catch (error) {
|
|
54
|
-
|
|
54
|
+
ctx.logger.errorWithTraceId(error, ctx);
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -64,6 +64,7 @@ class ScheduledActionProcessor {
|
|
|
64
64
|
ctx.action = action;
|
|
65
65
|
ctx.chatInfo = chatInfo;
|
|
66
66
|
ctx.traceId = traceId;
|
|
67
|
+
ctx.logger = this.logger.createScope(this.botName, traceId, chatInfo.name);
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
exports.ScheduledActionProcessor = ScheduledActionProcessor;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ILogger } from '../types/logger';
|
|
1
|
+
import { ILogger, IScopedLogger } from '../types/logger';
|
|
2
2
|
import { TraceId } from '../types/trace';
|
|
3
3
|
export declare class JsonLogger implements ILogger {
|
|
4
4
|
private serializeError;
|
|
5
|
+
createScope(botName: string, traceId: TraceId, chatName: string): IScopedLogger;
|
|
5
6
|
logObjectWithTraceId(botName: string, traceId: TraceId, chatName: string, data: any): void;
|
|
6
7
|
logWithTraceId(botName: string, traceId: TraceId, chatName: string, text: string): void;
|
|
7
|
-
errorWithTraceId<TData>(botName: string, traceId: TraceId, chatName: string, errorObj: unknown, extraData?: TData
|
|
8
|
+
errorWithTraceId<TData>(botName: string, traceId: TraceId, chatName: string, errorObj: unknown, extraData?: TData): void;
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=jsonLogger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonLogger.d.ts","sourceRoot":"","sources":["../../services/jsonLogger.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonLogger.d.ts","sourceRoot":"","sources":["../../services/jsonLogger.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,UAAW,YAAW,OAAO;IACtC,OAAO,CAAC,cAAc;IAQtB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GActD,aAAa;IAGtB,oBAAoB,CAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,GAAG;IAQb,cAAc,CACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM;IAOhB,gBAAgB,CAAC,KAAK,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,OAAO,EACjB,SAAS,CAAC,EAAE,KAAK;CAQxB"}
|