chz-telegram-bot 0.3.13 → 0.3.15
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/README.md +92 -73
- package/dist/dtos/chatInfo.d.ts +10 -1
- package/dist/dtos/chatInfo.d.ts.map +1 -1
- package/dist/dtos/chatInfo.js +11 -5
- package/dist/dtos/commandTriggerCheckResult.d.ts +5 -5
- package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -1
- package/dist/dtos/commandTriggerCheckResult.js +4 -4
- package/dist/dtos/cooldownInfo.d.ts +9 -3
- package/dist/dtos/cooldownInfo.d.ts.map +1 -1
- package/dist/dtos/cooldownInfo.js +5 -1
- package/dist/dtos/incomingMessage.d.ts +1 -1
- package/dist/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.js +2 -2
- package/dist/dtos/incomingQuery.d.ts.map +1 -1
- package/dist/dtos/messageInfo.d.ts +21 -0
- package/dist/dtos/messageInfo.d.ts.map +1 -0
- package/dist/dtos/messageInfo.js +24 -0
- package/dist/dtos/userInfo.d.ts +12 -0
- package/dist/dtos/userInfo.d.ts.map +1 -0
- package/dist/dtos/userInfo.js +16 -0
- package/dist/entities/actions/commandAction.d.ts +2 -2
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +11 -8
- package/dist/entities/actions/inlineQueryAction.d.ts +2 -2
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.d.ts +4 -4
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.js +4 -4
- package/dist/entities/actions/scheduledAction.d.ts +2 -2
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/context/baseContext.d.ts +2 -1
- package/dist/entities/context/baseContext.d.ts.map +1 -1
- package/dist/entities/context/baseContext.js +3 -3
- package/dist/entities/context/chatContext.d.ts +3 -2
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +3 -3
- package/dist/entities/context/inlineQueryContext.d.ts +3 -2
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/inlineQueryContext.js +3 -3
- package/dist/entities/context/messageContext.d.ts +11 -15
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +15 -20
- package/dist/entities/context/replyContext.d.ts +9 -15
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +12 -20
- package/dist/helpers/mapUtils.d.ts +9 -2
- package/dist/helpers/mapUtils.d.ts.map +1 -1
- package/dist/helpers/mapUtils.js +1 -1
- package/dist/services/actionProcessors/baseProcessor.d.ts +2 -2
- package/dist/services/actionProcessors/baseProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +1 -0
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +18 -19
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +1 -1
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/scheduledActionProcessor.js +2 -2
- package/dist/types/action.d.ts +2 -2
- package/dist/types/action.d.ts.map +1 -1
- package/dist/types/capture.d.ts +3 -3
- package/dist/types/capture.d.ts.map +1 -1
- package/dtos/chatInfo.ts +10 -9
- package/dtos/commandTriggerCheckResult.ts +5 -15
- package/dtos/cooldownInfo.ts +6 -1
- package/dtos/incomingMessage.ts +7 -2
- package/dtos/incomingQuery.ts +4 -12
- package/dtos/messageInfo.ts +17 -0
- package/dtos/userInfo.ts +8 -0
- package/entities/actions/commandAction.ts +16 -12
- package/entities/actions/inlineQueryAction.ts +2 -2
- package/entities/actions/replyCaptureAction.ts +9 -9
- package/entities/actions/scheduledAction.ts +2 -2
- package/entities/context/baseContext.ts +11 -1
- package/entities/context/chatContext.ts +16 -5
- package/entities/context/inlineQueryContext.ts +10 -2
- package/entities/context/messageContext.ts +24 -25
- package/entities/context/replyContext.ts +26 -25
- package/helpers/mapUtils.ts +15 -2
- package/package.json +1 -1
- package/services/actionProcessors/baseProcessor.ts +3 -3
- package/services/actionProcessors/commandActionProcessor.ts +43 -21
- package/services/actionProcessors/inlineQueryActionProcessor.ts +3 -3
- package/services/actionProcessors/scheduledActionProcessor.ts +7 -4
- package/types/action.ts +2 -2
- package/types/capture.ts +5 -3
|
@@ -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,
|
|
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,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,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,0BAA0B;CAuC7C"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { IActionState } from '../../types/actionState';
|
|
2
2
|
import { CommandTrigger } from '../../types/commandTrigger';
|
|
3
3
|
import { ActionKey, IAction, IActionWithState } from '../../types/action';
|
|
4
|
-
import {
|
|
4
|
+
import { ReplyContextInternal } from '../context/replyContext';
|
|
5
5
|
export declare class ReplyCaptureAction<TParentActionState extends IActionState> implements IAction {
|
|
6
6
|
readonly parentMessageId: number;
|
|
7
7
|
readonly key: ActionKey;
|
|
8
|
-
readonly handler: (replyContext:
|
|
8
|
+
readonly handler: (replyContext: ReplyContextInternal<TParentActionState>) => Promise<void>;
|
|
9
9
|
readonly triggers: CommandTrigger[];
|
|
10
10
|
readonly abortController: AbortController;
|
|
11
|
-
constructor(parentMessageId: number, parentAction: IActionWithState<TParentActionState>, handler: (replyContext:
|
|
12
|
-
exec(ctx:
|
|
11
|
+
constructor(parentMessageId: number, parentAction: IActionWithState<TParentActionState>, handler: (replyContext: ReplyContextInternal<TParentActionState>) => Promise<void>, triggers: CommandTrigger[], abortController: AbortController);
|
|
12
|
+
exec(ctx: ReplyContextInternal<TParentActionState>): Promise<import("../../types/response").BotResponse[]>;
|
|
13
13
|
private checkIfShouldBeExecuted;
|
|
14
14
|
}
|
|
15
15
|
//# sourceMappingURL=replyCaptureAction.d.ts.map
|
|
@@ -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,
|
|
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,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,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,oBAAoB,CAAC,kBAAkB,CAAC,KACrD,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAGtC,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,gBAAgB,CAAC,kBAAkB,CAAC,EAClD,OAAO,EAAE,CACL,YAAY,EAAE,oBAAoB,CAAC,kBAAkB,CAAC,KACrD,OAAO,CAAC,IAAI,CAAC,EAClB,QAAQ,EAAE,cAAc,EAAE,EAC1B,eAAe,EAAE,eAAe;IAY9B,IAAI,CAAC,GAAG,EAAE,oBAAoB,CAAC,kBAAkB,CAAC;IAyBxD,OAAO,CAAC,uBAAuB;CA+ClC"}
|
|
@@ -34,22 +34,22 @@ class ReplyCaptureAction {
|
|
|
34
34
|
checkIfShouldBeExecuted(ctx, trigger) {
|
|
35
35
|
if (ctx.replyMessageId != this.parentMessageId)
|
|
36
36
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger('TriggerNotSatisfied');
|
|
37
|
-
if (trigger == ctx.
|
|
37
|
+
if (trigger == ctx.messageInfo.type)
|
|
38
38
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger();
|
|
39
39
|
if (typeof trigger == 'string')
|
|
40
|
-
if (ctx.
|
|
40
|
+
if (ctx.messageInfo.text.toLowerCase() == trigger.toLowerCase())
|
|
41
41
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger();
|
|
42
42
|
else
|
|
43
43
|
return commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger('TriggerNotSatisfied');
|
|
44
44
|
const matchResults = [];
|
|
45
45
|
trigger.lastIndex = 0;
|
|
46
|
-
const execResult = trigger.exec(ctx.
|
|
46
|
+
const execResult = trigger.exec(ctx.messageInfo.text);
|
|
47
47
|
if (execResult != null) {
|
|
48
48
|
let regexMatchLimit = 100;
|
|
49
49
|
matchResults.push(execResult);
|
|
50
50
|
if (trigger.global) {
|
|
51
51
|
while (regexMatchLimit > 0) {
|
|
52
|
-
const nextResult = trigger.exec(ctx.
|
|
52
|
+
const nextResult = trigger.exec(ctx.messageInfo.text);
|
|
53
53
|
if (nextResult == null)
|
|
54
54
|
break;
|
|
55
55
|
matchResults.push(nextResult);
|
|
@@ -4,7 +4,7 @@ import { HoursOfDay } from '../../types/timeValues';
|
|
|
4
4
|
import { IActionState } from '../../types/actionState';
|
|
5
5
|
import { IActionWithState, ActionKey } from '../../types/action';
|
|
6
6
|
import { CachedStateFactory } from '../cachedStateFactory';
|
|
7
|
-
import {
|
|
7
|
+
import { ChatContextInternal } from '../context/chatContext';
|
|
8
8
|
export declare class ScheduledAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
|
|
9
9
|
static readonly locks: Map<string, Semaphore>;
|
|
10
10
|
readonly name: string;
|
|
@@ -17,7 +17,7 @@ export declare class ScheduledAction<TActionState extends IActionState> implemen
|
|
|
17
17
|
readonly cachedStateFactories: Map<string, CachedStateFactory>;
|
|
18
18
|
readonly handler: ScheduledHandler<TActionState>;
|
|
19
19
|
constructor(name: string, handler: ScheduledHandler<TActionState>, timeinHours: HoursOfDay, active: boolean, whitelist: number[], cachedStateFactories: Map<string, CachedStateFactory>, stateConstructor: () => TActionState);
|
|
20
|
-
exec(ctx:
|
|
20
|
+
exec(ctx: ChatContextInternal<TActionState>): Promise<import("../../types/response").BotResponse[]>;
|
|
21
21
|
private getCachedValue;
|
|
22
22
|
private checkIfShouldBeExecuted;
|
|
23
23
|
}
|
|
@@ -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,
|
|
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,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAK7D,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,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,mBAAmB,CAAC,YAAY,CAAC;YAuCnC,cAAc;IA4C5B,OAAO,CAAC,uBAAuB;CAalC"}
|
|
@@ -6,7 +6,8 @@ import { BotResponse } from '../../types/response';
|
|
|
6
6
|
import { IScheduler } from '../../types/scheduler';
|
|
7
7
|
import { IStorageClient } from '../../types/storage';
|
|
8
8
|
import { TraceId } from '../../types/trace';
|
|
9
|
-
export
|
|
9
|
+
export type BaseContextPropertiesToOmit = 'action' | 'isInitialized' | 'storage' | 'scheduler' | 'logger' | 'responses' | 'traceId' | 'botName';
|
|
10
|
+
export declare abstract class BaseContextInternal<TAction extends IAction> {
|
|
10
11
|
isInitialized: boolean;
|
|
11
12
|
private _responses;
|
|
12
13
|
action: TAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseContext.d.ts","sourceRoot":"","sources":["../../../entities/context/baseContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,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;AAE5C,
|
|
1
|
+
{"version":3,"file":"baseContext.d.ts","sourceRoot":"","sources":["../../../entities/context/baseContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,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;AAE5C,MAAM,MAAM,2BAA2B,GACjC,QAAQ,GACR,eAAe,GACf,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,GACT,SAAS,CAAC;AAEhB,8BAAsB,mBAAmB,CAAC,OAAO,SAAS,OAAO;IAC7D,aAAa,UAAS;IACtB,OAAO,CAAC,UAAU,CAAqB;IAEvC,MAAM,EAAG,OAAO,CAAC;IAEjB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/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;IAEpB,uDAAuD;IACvD,IAAW,SAAS,IAAI,WAAW,EAAE,CAEpC;IACD,IAAW,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,EAExC;gBAEW,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAK1D;;;;OAIG;IACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,MAAM,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;CAWpD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
class
|
|
3
|
+
exports.BaseContextInternal = void 0;
|
|
4
|
+
class BaseContextInternal {
|
|
5
5
|
isInitialized = false;
|
|
6
6
|
_responses = [];
|
|
7
7
|
action;
|
|
@@ -41,4 +41,4 @@ class BaseContext {
|
|
|
41
41
|
return Object.freeze(stateForChat);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
exports.
|
|
44
|
+
exports.BaseContextInternal = BaseContextInternal;
|
|
@@ -4,12 +4,13 @@ import { IActionState } from '../../types/actionState';
|
|
|
4
4
|
import { IReplyResponse } from '../../types/response';
|
|
5
5
|
import { Milliseconds } from '../../types/timeValues';
|
|
6
6
|
import { ICaptureController } from '../../types/capture';
|
|
7
|
-
import {
|
|
7
|
+
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
8
8
|
import { ScheduledAction } from '../actions/scheduledAction';
|
|
9
|
+
export type ChatContext<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> = Omit<ChatContextInternal<TActionState, TAction>, BaseContextPropertiesToOmit>;
|
|
9
10
|
/**
|
|
10
11
|
* Context of action executed in chat.
|
|
11
12
|
*/
|
|
12
|
-
export declare class
|
|
13
|
+
export declare class ChatContextInternal<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> extends BaseContextInternal<TAction> {
|
|
13
14
|
protected createCaptureController(response: IReplyResponse): ICaptureController;
|
|
14
15
|
/**
|
|
15
16
|
* Collection of actions that send something to chat as a standalone message.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,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,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,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,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAGzD,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,WAAW,CACnB,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,IAC9E,IAAI,CACJ,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,EAC1C,2BAA2B,CAC9B,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAmB,CAC5B,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,CAChF,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IAClC,SAAS,CAAC,uBAAuB,CAC7B,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"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ChatContextInternal = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const imageMessage_1 = require("../../dtos/responses/imageMessage");
|
|
6
6
|
const textMessage_1 = require("../../dtos/responses/textMessage");
|
|
@@ -11,7 +11,7 @@ const baseContext_1 = require("./baseContext");
|
|
|
11
11
|
/**
|
|
12
12
|
* Context of action executed in chat.
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
14
|
+
class ChatContextInternal extends baseContext_1.BaseContextInternal {
|
|
15
15
|
createCaptureController(response) {
|
|
16
16
|
return {
|
|
17
17
|
captureReplies: (trigger, handler, abortController) => {
|
|
@@ -78,4 +78,4 @@ class ChatContext extends baseContext_1.BaseContext {
|
|
|
78
78
|
this.responses.push(new delay_1.DelayResponse(delay, this.chatInfo, this.traceId, this.action));
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
exports.
|
|
81
|
+
exports.ChatContextInternal = ChatContextInternal;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { InlineQueryResult } from 'telegraf/types';
|
|
2
2
|
import { BotResponse } from '../../types/response';
|
|
3
3
|
import { InlineQueryAction } from '../actions/inlineQueryAction';
|
|
4
|
-
import {
|
|
5
|
-
export
|
|
4
|
+
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
5
|
+
export type InlineQueryContext = Omit<InlineQueryContextInternal, BaseContextPropertiesToOmit | 'queryResults' | 'queryId'>;
|
|
6
|
+
export declare class InlineQueryContextInternal extends BaseContextInternal<InlineQueryAction> {
|
|
6
7
|
queryResults: InlineQueryResult[];
|
|
7
8
|
/**
|
|
8
9
|
* Abort signal to be utilized in query handler.
|
|
@@ -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,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,
|
|
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,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AAEvB,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACjC,0BAA0B,EAC1B,2BAA2B,GAAG,cAAc,GAAG,SAAS,CAC3D,CAAC;AAEF,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,iBAAiB,CAAC;IAClF,YAAY,EAAE,iBAAiB,EAAE,CAAM;IACvC;;;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;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,iBAAiB;CAGvD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InlineQueryContextInternal = void 0;
|
|
4
4
|
const inlineQueryResponse_1 = require("../../dtos/responses/inlineQueryResponse");
|
|
5
5
|
const baseContext_1 = require("./baseContext");
|
|
6
|
-
class
|
|
6
|
+
class InlineQueryContextInternal extends baseContext_1.BaseContextInternal {
|
|
7
7
|
queryResults = [];
|
|
8
8
|
/**
|
|
9
9
|
* Abort signal to be utilized in query handler.
|
|
@@ -30,4 +30,4 @@ class InlineQueryContext extends baseContext_1.BaseContext {
|
|
|
30
30
|
this.queryResults.push(queryResult);
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
-
exports.
|
|
33
|
+
exports.InlineQueryContextInternal = InlineQueryContextInternal;
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import { TelegramEmoji, UserFromGetMe } from 'telegraf/types';
|
|
2
2
|
import { IActionState } from '../../types/actionState';
|
|
3
|
-
import {
|
|
3
|
+
import { ChatContextInternal } from './chatContext';
|
|
4
4
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
5
|
-
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
6
5
|
import { CommandAction } from '../actions/commandAction';
|
|
7
6
|
import { Seconds } from '../../types/timeValues';
|
|
7
|
+
import { BaseContextPropertiesToOmit } from './baseContext';
|
|
8
|
+
import { MessageInfo } from '../../dtos/messageInfo';
|
|
9
|
+
import { UserInfo } from '../../dtos/userInfo';
|
|
10
|
+
export type MessageContext<TActionState extends IActionState> = Omit<MessageContextInternal<TActionState>, BaseContextPropertiesToOmit | 'startCooldown' | 'customCooldown'>;
|
|
8
11
|
/**
|
|
9
12
|
* Context of action executed in chat, in response to a message
|
|
10
13
|
*/
|
|
11
|
-
export declare class
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
export declare class MessageContextInternal<TActionState extends IActionState> extends ChatContextInternal<TActionState, CommandAction<TActionState>> {
|
|
15
|
+
/** Information about the user that triggered this action */
|
|
16
|
+
userInfo: UserInfo;
|
|
17
|
+
/** Information about the message that triggered this action */
|
|
18
|
+
messageInfo: MessageInfo;
|
|
16
19
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
17
20
|
matchResults: RegExpMatchArray[];
|
|
18
|
-
/** Id of a user that sent a message that triggered this action. */
|
|
19
|
-
fromUserId: number | undefined;
|
|
20
21
|
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
21
22
|
startCooldown: boolean;
|
|
22
|
-
/** Name of a user that sent a message that triggered this action. */
|
|
23
|
-
fromUserName: string;
|
|
24
|
-
/** Type of message being received */
|
|
25
|
-
messageType: MessageTypeValue;
|
|
26
|
-
/** Message object recieved from Telegram */
|
|
27
|
-
messageUpdateObject: TelegrafContextMessage;
|
|
28
23
|
/** Bot info from Telegram */
|
|
29
24
|
botInfo: UserFromGetMe;
|
|
30
25
|
customCooldown: Seconds | undefined;
|
|
@@ -32,6 +27,7 @@ export declare class MessageContext<TActionState extends IActionState> extends C
|
|
|
32
27
|
private replyWithText;
|
|
33
28
|
private replyWithImage;
|
|
34
29
|
private replyWithVideo;
|
|
30
|
+
skipCooldown(): void;
|
|
35
31
|
startCustomCooldown(customCooldown: Seconds): void;
|
|
36
32
|
/**
|
|
37
33
|
* Collection of actions that can be done as a reply to a message that triggered this action
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAChE,sBAAsB,CAAC,YAAY,CAAC,EACpC,2BAA2B,GAAG,eAAe,GAAG,gBAAgB,CACnE,CAAC;AAEF;;GAEG;AACH,qBAAa,sBAAsB,CAC/B,YAAY,SAAS,YAAY,CACnC,SAAQ,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACpE,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,6BAA6B;IAC7B,OAAO,EAAG,aAAa,CAAC;IACxB,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB,YAAY;IAIZ,mBAAmB,CAAC,cAAc,EAAE,OAAO;IAK3C;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAGnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAIvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MessageContextInternal = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const imageMessage_1 = require("../../dtos/responses/imageMessage");
|
|
6
6
|
const reaction_1 = require("../../dtos/responses/reaction");
|
|
@@ -11,23 +11,15 @@ const replyInfo_1 = require("../../dtos/replyInfo");
|
|
|
11
11
|
/**
|
|
12
12
|
* Context of action executed in chat, in response to a message
|
|
13
13
|
*/
|
|
14
|
-
class
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
|
|
14
|
+
class MessageContextInternal extends chatContext_1.ChatContextInternal {
|
|
15
|
+
/** Information about the user that triggered this action */
|
|
16
|
+
userInfo;
|
|
17
|
+
/** Information about the message that triggered this action */
|
|
18
|
+
messageInfo;
|
|
19
19
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
20
20
|
matchResults = [];
|
|
21
|
-
/** Id of a user that sent a message that triggered this action. */
|
|
22
|
-
fromUserId;
|
|
23
21
|
/** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
|
|
24
22
|
startCooldown = true;
|
|
25
|
-
/** Name of a user that sent a message that triggered this action. */
|
|
26
|
-
fromUserName;
|
|
27
|
-
/** Type of message being received */
|
|
28
|
-
messageType;
|
|
29
|
-
/** Message object recieved from Telegram */
|
|
30
|
-
messageUpdateObject;
|
|
31
23
|
/** Bot info from Telegram */
|
|
32
24
|
botInfo;
|
|
33
25
|
customCooldown;
|
|
@@ -35,27 +27,30 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
35
27
|
return typeof quote == 'boolean'
|
|
36
28
|
? this.matchResults.length != 0
|
|
37
29
|
? this.matchResults[0][1]
|
|
38
|
-
: this.
|
|
30
|
+
: this.messageInfo.text
|
|
39
31
|
: quote;
|
|
40
32
|
}
|
|
41
33
|
replyWithText(text, quote, options) {
|
|
42
34
|
const quotedPart = this.getQuotePart(quote);
|
|
43
|
-
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.
|
|
35
|
+
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
44
36
|
this.responses.push(response);
|
|
45
37
|
return this.createCaptureController(response);
|
|
46
38
|
}
|
|
47
39
|
replyWithImage(name, quote, options) {
|
|
48
40
|
const quotedPart = this.getQuotePart(quote);
|
|
49
|
-
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.
|
|
41
|
+
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.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
50
42
|
this.responses.push(response);
|
|
51
43
|
return this.createCaptureController(response);
|
|
52
44
|
}
|
|
53
45
|
replyWithVideo(name, quote, options) {
|
|
54
46
|
const quotedPart = this.getQuotePart(quote);
|
|
55
|
-
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.
|
|
47
|
+
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.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
56
48
|
this.responses.push(response);
|
|
57
49
|
return this.createCaptureController(response);
|
|
58
50
|
}
|
|
51
|
+
skipCooldown() {
|
|
52
|
+
this.startCooldown = false;
|
|
53
|
+
}
|
|
59
54
|
startCustomCooldown(customCooldown) {
|
|
60
55
|
this.startCooldown = true;
|
|
61
56
|
this.customCooldown = customCooldown;
|
|
@@ -118,8 +113,8 @@ class MessageContext extends chatContext_1.ChatContext {
|
|
|
118
113
|
* @param emoji Telegram emoji to react with.
|
|
119
114
|
*/
|
|
120
115
|
withReaction: (emoji) => {
|
|
121
|
-
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.
|
|
116
|
+
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
|
|
122
117
|
}
|
|
123
118
|
};
|
|
124
119
|
}
|
|
125
|
-
exports.
|
|
120
|
+
exports.MessageContextInternal = MessageContextInternal;
|
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
import { TelegramEmoji, UserFromGetMe } from 'telegraf/types';
|
|
2
2
|
import { IActionState } from '../../types/actionState';
|
|
3
3
|
import { TextMessageSendingOptions, MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
|
-
import { MessageTypeValue, TelegrafContextMessage } from '../../types/messageTypes';
|
|
5
4
|
import { ReplyCaptureAction } from '../actions/replyCaptureAction';
|
|
6
|
-
import {
|
|
7
|
-
|
|
5
|
+
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
6
|
+
import { UserInfo } from '../../dtos/userInfo';
|
|
7
|
+
import { MessageInfo } from '../../dtos/messageInfo';
|
|
8
|
+
export type ReplyContext<TActionState extends IActionState> = Omit<ReplyContextInternal<TActionState>, BaseContextPropertiesToOmit | 'messageId' | 'startCooldown' | 'customCooldown'>;
|
|
9
|
+
export declare class ReplyContextInternal<TParentActionState extends IActionState> extends BaseContextInternal<ReplyCaptureAction<TParentActionState>> {
|
|
8
10
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
9
11
|
matchResults: RegExpExecArray[];
|
|
10
12
|
/** Id of a message that triggered this action. */
|
|
11
13
|
replyMessageId: number | undefined;
|
|
12
|
-
/**
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
/** Text of a message that triggered this action. */
|
|
17
|
-
messageText: string;
|
|
18
|
-
/** Id of a user that sent a message that triggered this action. */
|
|
19
|
-
fromUserId: number | undefined;
|
|
20
|
-
/** Name of a user that sent a message that triggered this action. */
|
|
21
|
-
fromUserName: string;
|
|
22
|
-
/** Message object recieved from Telegram */
|
|
23
|
-
messageUpdateObject: TelegrafContextMessage;
|
|
14
|
+
/** Information about the user that triggered this action */
|
|
15
|
+
userInfo: UserInfo;
|
|
16
|
+
/** Information about the message that triggered this action */
|
|
17
|
+
messageInfo: MessageInfo;
|
|
24
18
|
/** Bot info from Telegram */
|
|
25
19
|
botInfo: UserFromGetMe;
|
|
26
20
|
isInitialized: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../entities/context/replyContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAM9D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EACH,yBAAyB,EACzB,qBAAqB,EACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,MAAM,YAAY,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAC9D,oBAAoB,CAAC,YAAY,CAAC,EAChC,2BAA2B,GAC3B,WAAW,GACX,eAAe,GACf,gBAAgB,CACrB,CAAC;AAEF,qBAAa,oBAAoB,CAC7B,kBAAkB,SAAS,YAAY,CACzC,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,kBAAkB,CAAC,CAAC;IACjE,4HAA4H;IAC5H,YAAY,EAAG,eAAe,EAAE,CAAC;IACjC,kDAAkD;IAClD,cAAc,EAAG,MAAM,GAAG,SAAS,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,6BAA6B;IAC7B,OAAO,EAAG,aAAa,CAAC;IAExB,aAAa,UAAS;IAEtB,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAmBrB,OAAO,CAAC,cAAc;IAmBtB,OAAO,CAAC,cAAc;IAmBtB;;OAEG;IACH,WAAW;IAIX;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAIvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAKnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAMvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAG5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAIzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ReplyContextInternal = void 0;
|
|
4
4
|
const replyInfo_1 = require("../../dtos/replyInfo");
|
|
5
5
|
const imageMessage_1 = require("../../dtos/responses/imageMessage");
|
|
6
6
|
const reaction_1 = require("../../dtos/responses/reaction");
|
|
@@ -8,23 +8,15 @@ 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
|
const baseContext_1 = require("./baseContext");
|
|
11
|
-
class
|
|
11
|
+
class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
12
12
|
/** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
|
|
13
13
|
matchResults;
|
|
14
14
|
/** Id of a message that triggered this action. */
|
|
15
15
|
replyMessageId;
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/** Text of a message that triggered this action. */
|
|
21
|
-
messageText;
|
|
22
|
-
/** Id of a user that sent a message that triggered this action. */
|
|
23
|
-
fromUserId;
|
|
24
|
-
/** Name of a user that sent a message that triggered this action. */
|
|
25
|
-
fromUserName;
|
|
26
|
-
/** Message object recieved from Telegram */
|
|
27
|
-
messageUpdateObject;
|
|
16
|
+
/** Information about the user that triggered this action */
|
|
17
|
+
userInfo;
|
|
18
|
+
/** Information about the message that triggered this action */
|
|
19
|
+
messageInfo;
|
|
28
20
|
/** Bot info from Telegram */
|
|
29
21
|
botInfo;
|
|
30
22
|
isInitialized = false;
|
|
@@ -32,22 +24,22 @@ class ReplyContext extends baseContext_1.BaseContext {
|
|
|
32
24
|
return typeof quote == 'boolean'
|
|
33
25
|
? this.matchResults.length != 0
|
|
34
26
|
? this.matchResults[0][1]
|
|
35
|
-
: this.
|
|
27
|
+
: this.messageInfo.text
|
|
36
28
|
: quote;
|
|
37
29
|
}
|
|
38
30
|
replyWithText(text, quote, options) {
|
|
39
31
|
const quotedPart = this.getQuotePart(quote);
|
|
40
|
-
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.
|
|
32
|
+
const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
41
33
|
this.responses.push(response);
|
|
42
34
|
}
|
|
43
35
|
replyWithImage(name, quote, options) {
|
|
44
36
|
const quotedPart = this.getQuotePart(quote);
|
|
45
|
-
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.
|
|
37
|
+
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.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
46
38
|
this.responses.push(response);
|
|
47
39
|
}
|
|
48
40
|
replyWithVideo(name, quote, options) {
|
|
49
41
|
const quotedPart = this.getQuotePart(quote);
|
|
50
|
-
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.
|
|
42
|
+
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.messageInfo.id, quote ? quotedPart : undefined), options);
|
|
51
43
|
this.responses.push(response);
|
|
52
44
|
}
|
|
53
45
|
/**
|
|
@@ -126,8 +118,8 @@ class ReplyContext extends baseContext_1.BaseContext {
|
|
|
126
118
|
* @param emoji Telegram emoji to react with.
|
|
127
119
|
*/
|
|
128
120
|
withReaction: (emoji) => {
|
|
129
|
-
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.
|
|
121
|
+
this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
|
|
130
122
|
}
|
|
131
123
|
};
|
|
132
124
|
}
|
|
133
|
-
exports.
|
|
125
|
+
exports.ReplyContextInternal = ReplyContextInternal;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type KeyedReadonlyCollection<K, V> = {
|
|
2
|
+
get: (key: K) => V | undefined;
|
|
3
|
+
};
|
|
4
|
+
type KeyedWriteableCollection<K, V> = KeyedReadonlyCollection<K, V> & {
|
|
5
|
+
set: (key: K, value: V) => KeyedWriteableCollection<K, V>;
|
|
6
|
+
};
|
|
7
|
+
export declare function getOrSetIfNotExists<K, V>(map: KeyedWriteableCollection<K, V>, key: K, fallback: V): V;
|
|
8
|
+
export declare function getOrThrow<K, V>(map: KeyedReadonlyCollection<K, V>, key: K, error?: string): NonNullable<V>;
|
|
9
|
+
export {};
|
|
3
10
|
//# sourceMappingURL=mapUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapUtils.d.ts","sourceRoot":"","sources":["../../helpers/mapUtils.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"mapUtils.d.ts","sourceRoot":"","sources":["../../helpers/mapUtils.ts"],"names":[],"mappings":"AAAA,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI;IAAE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAA;CAAE,CAAC;AACxE,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;IAClE,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;CAC7D,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,CAAC,EACpC,GAAG,EAAE,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,EACnC,GAAG,EAAE,CAAC,EACN,QAAQ,EAAE,CAAC,KAQd;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,CAAC,EAC3B,GAAG,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,EAClC,GAAG,EAAE,CAAC,EACN,KAAK,GAAE,MAAsC,kBAMhD"}
|
package/dist/helpers/mapUtils.js
CHANGED
|
@@ -9,7 +9,7 @@ function getOrSetIfNotExists(map, key, fallback) {
|
|
|
9
9
|
map.set(key, fallback);
|
|
10
10
|
return fallback;
|
|
11
11
|
}
|
|
12
|
-
function getOrThrow(map, key, error) {
|
|
12
|
+
function getOrThrow(map, key, error = 'Key not found in collection') {
|
|
13
13
|
const existingValue = map.get(key);
|
|
14
14
|
if (existingValue)
|
|
15
15
|
return existingValue;
|
|
@@ -3,7 +3,7 @@ import { IScheduler } from '../../types/scheduler';
|
|
|
3
3
|
import { IStorageClient } from '../../types/storage';
|
|
4
4
|
import { TelegramApiService } from '../telegramApi';
|
|
5
5
|
import { IAction } from '../../types/action';
|
|
6
|
-
import {
|
|
6
|
+
import { BaseContextInternal } from '../../entities/context/baseContext';
|
|
7
7
|
export declare abstract class BaseActionProcessor {
|
|
8
8
|
protected readonly storage: IStorageClient;
|
|
9
9
|
protected readonly scheduler: IScheduler;
|
|
@@ -13,6 +13,6 @@ export declare abstract class BaseActionProcessor {
|
|
|
13
13
|
constructor(botName: string, storage: IStorageClient, scheduler: IScheduler, logger: ILogger);
|
|
14
14
|
private defaultErrorHandler;
|
|
15
15
|
initializeDependencies(api: TelegramApiService): void;
|
|
16
|
-
executeAction<TAction extends IAction, TActionContext extends
|
|
16
|
+
executeAction<TAction extends IAction, TActionContext extends BaseContextInternal<TAction>>(action: TAction, ctx: TActionContext, errorHandler?: (error: Error, ctx: TActionContext) => void): Promise<void>;
|
|
17
17
|
}
|
|
18
18
|
//# sourceMappingURL=baseProcessor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"baseProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/baseProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"baseProcessor.d.ts","sourceRoot":"","sources":["../../../services/actionProcessors/baseProcessor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEzE,8BAAsB,mBAAmB;IACrC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IAC3C,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IACzC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEnC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEnC,SAAS,CAAC,GAAG,EAAG,kBAAkB,CAAC;gBAG/B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,MAAM,EAAE,OAAO;IASnB,OAAO,CAAC,mBAAmB;IAO3B,sBAAsB,CAAC,GAAG,EAAE,kBAAkB;IAIxC,aAAa,CACf,OAAO,SAAS,OAAO,EACvB,cAAc,SAAS,mBAAmB,CAAC,OAAO,CAAC,EAEnD,MAAM,EAAE,OAAO,EACf,GAAG,EAAE,cAAc,EACnB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,KAAK,IAAI;CAUjE"}
|
|
@@ -10,6 +10,7 @@ import { UserFromGetMe } from 'telegraf/types';
|
|
|
10
10
|
export declare class CommandActionProcessor extends BaseActionProcessor {
|
|
11
11
|
private readonly replyCaptures;
|
|
12
12
|
private botInfo;
|
|
13
|
+
private lastMessages;
|
|
13
14
|
private commands;
|
|
14
15
|
initialize(api: TelegramApiService, telegraf: Telegraf, commands: CommandAction<IActionState>[], verboseLoggingForIncomingMessage: boolean, botInfo: UserFromGetMe): void;
|
|
15
16
|
captureRegistrationCallback(capture: IReplyCapture, parentMessageId: number, chatInfo: ChatInfo, traceId: TraceId): void;
|
|
@@ -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;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,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;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
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;AAIrE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,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;AAM/C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAO/C,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC3D,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IACxE,OAAO,CAAC,OAAO,CAAiB;IAChC,OAAO,CAAC,YAAY,CAAwC;IAE5D,OAAO,CAAC,QAAQ,CAKd;IAEF,UAAU,CACN,GAAG,EAAE,kBAAkB,EACvB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,EACvC,gCAAgC,EAAE,OAAO,EACzC,OAAO,EAAE,aAAa;IA2D1B,2BAA2B,CACvB,OAAO,EAAE,aAAa,EACtB,eAAe,EAAE,MAAM,EACvB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;YA+BN,cAAc;IA0C5B,OAAO,CAAC,6BAA6B;IAiCrC,OAAO,CAAC,wBAAwB;CAmCnC"}
|