chz-telegram-bot 0.3.22 → 0.3.24
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/replyCaptureAction.d.ts +2 -2
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
- package/dist/entities/context/baseContext.d.ts +4 -1
- package/dist/entities/context/baseContext.d.ts.map +1 -1
- package/dist/entities/context/baseContext.js +15 -0
- package/dist/entities/context/chatContext.d.ts +3 -6
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +0 -12
- package/dist/entities/context/replyContext.d.ts +6 -6
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +9 -6
- package/dist/types/capture.d.ts +3 -3
- package/dist/types/capture.d.ts.map +1 -1
- package/entities/actions/replyCaptureAction.ts +2 -2
- package/entities/context/baseContext.ts +28 -1
- package/entities/context/chatContext.ts +0 -25
- package/entities/context/replyContext.ts +12 -6
- package/package.json +1 -1
- package/types/capture.ts +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IActionState } from '../../types/actionState';
|
|
2
2
|
import { CommandTrigger } from '../../types/commandTrigger';
|
|
3
|
-
import { ActionKey, IAction
|
|
3
|
+
import { ActionKey, IAction } from '../../types/action';
|
|
4
4
|
import { ReplyContextInternal } from '../context/replyContext';
|
|
5
5
|
export declare class ReplyCaptureAction<TParentActionState extends IActionState> implements IAction {
|
|
6
6
|
readonly parentMessageId: number;
|
|
@@ -8,7 +8,7 @@ export declare class ReplyCaptureAction<TParentActionState extends IActionState>
|
|
|
8
8
|
readonly handler: (replyContext: ReplyContextInternal<TParentActionState>) => Promise<void>;
|
|
9
9
|
readonly triggers: CommandTrigger[];
|
|
10
10
|
readonly abortController: AbortController;
|
|
11
|
-
constructor(parentMessageId: number, parentAction:
|
|
11
|
+
constructor(parentMessageId: number, parentAction: IAction, handler: (replyContext: ReplyContextInternal<TParentActionState>) => Promise<void>, triggers: CommandTrigger[], abortController: AbortController);
|
|
12
12
|
exec(ctx: ReplyContextInternal<TParentActionState>): Promise<import("../../types/response").BotResponse[]>;
|
|
13
13
|
private checkIfShouldBeExecuted;
|
|
14
14
|
}
|
|
@@ -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,
|
|
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,MAAM,oBAAoB,CAAC;AACxD,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,OAAO,EACrB,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;CA4ClC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
2
2
|
import { IAction, IActionWithState } from '../../types/action';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ICaptureController } from '../../types/capture';
|
|
4
5
|
import { IScopedLogger } from '../../types/logger';
|
|
5
|
-
import { BotResponse } from '../../types/response';
|
|
6
|
+
import { BotResponse, IReplyResponse } from '../../types/response';
|
|
6
7
|
import { IScheduler } from '../../types/scheduler';
|
|
7
8
|
import { IStorageClient } from '../../types/storage';
|
|
8
9
|
import { TraceId } from '../../types/trace';
|
|
@@ -22,10 +23,12 @@ export declare abstract class BaseContextInternal<TAction extends IAction> {
|
|
|
22
23
|
botName: string;
|
|
23
24
|
/** Chat information. */
|
|
24
25
|
chatInfo: ChatInfo;
|
|
26
|
+
get actionKey(): import("../../types/action").ActionKey;
|
|
25
27
|
/** Ordered collection of responses to be processed */
|
|
26
28
|
get responses(): BotResponse[];
|
|
27
29
|
set responses(value: BotResponse[]);
|
|
28
30
|
constructor(storage: IStorageClient, scheduler: IScheduler);
|
|
31
|
+
protected createCaptureController(response: IReplyResponse): ICaptureController;
|
|
29
32
|
/**
|
|
30
33
|
* Loads state of another action for current chat.
|
|
31
34
|
* @param action Action to load state of.
|
|
@@ -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,yBAAy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AAI,SAAS,2CAEZ;IAED,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,SAAS,CAAC,uBAAuB,CAC7B,QAAQ,EAAE,cAAc,GACzB,kBAAkB;IAmBrB;;;;OAIG;IACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,MAAM,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;CAWpD"}
|
|
@@ -16,6 +16,9 @@ class BaseContextInternal {
|
|
|
16
16
|
botName;
|
|
17
17
|
/** Chat information. */
|
|
18
18
|
chatInfo;
|
|
19
|
+
get actionKey() {
|
|
20
|
+
return this.action.key;
|
|
21
|
+
}
|
|
19
22
|
/** Ordered collection of responses to be processed */
|
|
20
23
|
get responses() {
|
|
21
24
|
return this._responses;
|
|
@@ -27,6 +30,18 @@ class BaseContextInternal {
|
|
|
27
30
|
this.storage = storage;
|
|
28
31
|
this.scheduler = scheduler;
|
|
29
32
|
}
|
|
33
|
+
createCaptureController(response) {
|
|
34
|
+
return {
|
|
35
|
+
captureReplies: (trigger, handler, abortController) => {
|
|
36
|
+
response.captures.push({
|
|
37
|
+
trigger,
|
|
38
|
+
handler,
|
|
39
|
+
abortController: abortController ?? new AbortController(),
|
|
40
|
+
action: this.action
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
30
45
|
/**
|
|
31
46
|
* Loads state of another action for current chat.
|
|
32
47
|
* @param action Action to load state of.
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
2
|
import { IActionWithState } from '../../types/action';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
|
-
import { IReplyResponse } from '../../types/response';
|
|
5
4
|
import { Milliseconds } from '../../types/timeValues';
|
|
6
|
-
import { ICaptureController } from '../../types/capture';
|
|
7
5
|
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
8
6
|
import { ScheduledAction } from '../actions/scheduledAction';
|
|
9
7
|
export type ChatContext<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> = Omit<ChatContextInternal<TActionState, TAction>, BaseContextPropertiesToOmit>;
|
|
@@ -11,7 +9,6 @@ export type ChatContext<TActionState extends IActionState, TAction extends IActi
|
|
|
11
9
|
* Context of action executed in chat.
|
|
12
10
|
*/
|
|
13
11
|
export declare class ChatContextInternal<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> extends BaseContextInternal<TAction> {
|
|
14
|
-
protected createCaptureController(response: IReplyResponse): ICaptureController;
|
|
15
12
|
/**
|
|
16
13
|
* Collection of actions that send something to chat as a standalone message.
|
|
17
14
|
*/
|
|
@@ -22,21 +19,21 @@ export declare class ChatContextInternal<TActionState extends IActionState, TAct
|
|
|
22
19
|
* @param text Message contents.
|
|
23
20
|
* @param options Message sending option.
|
|
24
21
|
*/
|
|
25
|
-
text: (text: string, options?: TextMessageSendingOptions) => ICaptureController;
|
|
22
|
+
text: (text: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
|
|
26
23
|
/**
|
|
27
24
|
* Sends image message to chat after action execution is finished.
|
|
28
25
|
* 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.
|
|
29
26
|
* @param name Message contents.
|
|
30
27
|
* @param options Message sending option.
|
|
31
28
|
*/
|
|
32
|
-
image: (name: string, options?: MessageSendingOptions) => ICaptureController;
|
|
29
|
+
image: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
33
30
|
/**
|
|
34
31
|
* Sends video/gif message to chat after action execution is finished.
|
|
35
32
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
36
33
|
* @param name Message contents.
|
|
37
34
|
* @param options Message sending option.
|
|
38
35
|
*/
|
|
39
|
-
video: (name: string, options?: MessageSendingOptions) => ICaptureController;
|
|
36
|
+
video: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
40
37
|
};
|
|
41
38
|
/**
|
|
42
39
|
* Unpins message after action execution is finished.
|
|
@@ -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,
|
|
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,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,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;;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"}
|
|
@@ -12,18 +12,6 @@ const baseContext_1 = require("./baseContext");
|
|
|
12
12
|
* Context of action executed in chat.
|
|
13
13
|
*/
|
|
14
14
|
class ChatContextInternal extends baseContext_1.BaseContextInternal {
|
|
15
|
-
createCaptureController(response) {
|
|
16
|
-
return {
|
|
17
|
-
captureReplies: (trigger, handler, abortController) => {
|
|
18
|
-
response.captures.push({
|
|
19
|
-
trigger,
|
|
20
|
-
handler,
|
|
21
|
-
abortController,
|
|
22
|
-
action: this.action
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
15
|
/**
|
|
28
16
|
* Collection of actions that send something to chat as a standalone message.
|
|
29
17
|
*/
|
|
@@ -41,21 +41,21 @@ export declare class ReplyContextInternal<TParentActionState extends IActionStat
|
|
|
41
41
|
* @param text Message contents.
|
|
42
42
|
* @param options Message sending option.
|
|
43
43
|
*/
|
|
44
|
-
withText: (text: string, quote?: string, options?: TextMessageSendingOptions) =>
|
|
44
|
+
withText: (text: string, quote?: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
|
|
45
45
|
/**
|
|
46
46
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
47
47
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
48
48
|
* @param text Message contents.
|
|
49
49
|
* @param options Message sending option.
|
|
50
50
|
*/
|
|
51
|
-
withImage: (name: string, quote?: string, options?: MessageSendingOptions) =>
|
|
51
|
+
withImage: (name: string, quote?: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
52
52
|
/**
|
|
53
53
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
54
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.
|
|
55
55
|
* @param text Message contents.
|
|
56
56
|
* @param options Message sending option.
|
|
57
57
|
*/
|
|
58
|
-
withVideo: (name: string, quote?: string, options?: MessageSendingOptions) =>
|
|
58
|
+
withVideo: (name: string, quote?: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
59
59
|
};
|
|
60
60
|
/**
|
|
61
61
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -63,21 +63,21 @@ export declare class ReplyContextInternal<TParentActionState extends IActionStat
|
|
|
63
63
|
* @param text Message contents.
|
|
64
64
|
* @param options Message sending option.
|
|
65
65
|
*/
|
|
66
|
-
withText: (text: string, options?: TextMessageSendingOptions) =>
|
|
66
|
+
withText: (text: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
|
|
67
67
|
/**
|
|
68
68
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
69
69
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
70
70
|
* @param text Message contents.
|
|
71
71
|
* @param options Message sending option.
|
|
72
72
|
*/
|
|
73
|
-
withImage: (name: string, options?: MessageSendingOptions) =>
|
|
73
|
+
withImage: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
74
74
|
/**
|
|
75
75
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
76
76
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
77
77
|
* @param text Message contents.
|
|
78
78
|
* @param options Message sending option.
|
|
79
79
|
*/
|
|
80
|
-
withVideo: (name: string, options?: MessageSendingOptions) =>
|
|
80
|
+
withVideo: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
|
|
81
81
|
/**
|
|
82
82
|
* React to the message that triggered this action after action execution is finished.
|
|
83
83
|
* 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":"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,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BAEO,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"}
|
|
@@ -31,16 +31,19 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
31
31
|
const quotedPart = this.getQuotePart(quote);
|
|
32
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);
|
|
33
33
|
this.responses.push(response);
|
|
34
|
+
return this.createCaptureController(response);
|
|
34
35
|
}
|
|
35
36
|
replyWithImage(name, quote, options) {
|
|
36
37
|
const quotedPart = this.getQuotePart(quote);
|
|
37
38
|
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);
|
|
38
39
|
this.responses.push(response);
|
|
40
|
+
return this.createCaptureController(response);
|
|
39
41
|
}
|
|
40
42
|
replyWithVideo(name, quote, options) {
|
|
41
43
|
const quotedPart = this.getQuotePart(quote);
|
|
42
44
|
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);
|
|
43
45
|
this.responses.push(response);
|
|
46
|
+
return this.createCaptureController(response);
|
|
44
47
|
}
|
|
45
48
|
/**
|
|
46
49
|
* Stops capturing replies and removes this action
|
|
@@ -64,7 +67,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
64
67
|
* @param options Message sending option.
|
|
65
68
|
*/
|
|
66
69
|
withText: (text, quote, options) => {
|
|
67
|
-
this.replyWithText(text, quote ?? true, options);
|
|
70
|
+
return this.replyWithText(text, quote ?? true, options);
|
|
68
71
|
},
|
|
69
72
|
/**
|
|
70
73
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
@@ -73,7 +76,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
73
76
|
* @param options Message sending option.
|
|
74
77
|
*/
|
|
75
78
|
withImage: (name, quote, options) => {
|
|
76
|
-
this.replyWithImage(name, quote ?? true, options);
|
|
79
|
+
return this.replyWithImage(name, quote ?? true, options);
|
|
77
80
|
},
|
|
78
81
|
/**
|
|
79
82
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
@@ -82,7 +85,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
82
85
|
* @param options Message sending option.
|
|
83
86
|
*/
|
|
84
87
|
withVideo: (name, quote, options) => {
|
|
85
|
-
this.replyWithVideo(name, quote ?? true, options);
|
|
88
|
+
return this.replyWithVideo(name, quote ?? true, options);
|
|
86
89
|
}
|
|
87
90
|
},
|
|
88
91
|
/**
|
|
@@ -92,7 +95,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
92
95
|
* @param options Message sending option.
|
|
93
96
|
*/
|
|
94
97
|
withText: (text, options) => {
|
|
95
|
-
this.replyWithText(text, false, options);
|
|
98
|
+
return this.replyWithText(text, false, options);
|
|
96
99
|
},
|
|
97
100
|
/**
|
|
98
101
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
@@ -101,7 +104,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
101
104
|
* @param options Message sending option.
|
|
102
105
|
*/
|
|
103
106
|
withImage: (name, options) => {
|
|
104
|
-
this.replyWithImage(name, false, options);
|
|
107
|
+
return this.replyWithImage(name, false, options);
|
|
105
108
|
},
|
|
106
109
|
/**
|
|
107
110
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
@@ -110,7 +113,7 @@ class ReplyContextInternal extends baseContext_1.BaseContextInternal {
|
|
|
110
113
|
* @param options Message sending option.
|
|
111
114
|
*/
|
|
112
115
|
withVideo: (name, options) => {
|
|
113
|
-
this.replyWithVideo(name, false, options);
|
|
116
|
+
return this.replyWithVideo(name, false, options);
|
|
114
117
|
},
|
|
115
118
|
/**
|
|
116
119
|
* React to the message that triggered this action after action execution is finished.
|
package/dist/types/capture.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReplyContext, ReplyContextInternal } from '../entities/context/replyContext';
|
|
2
2
|
import { IActionState } from './actionState';
|
|
3
3
|
import { CommandTrigger } from './commandTrigger';
|
|
4
|
-
import {
|
|
4
|
+
import { IAction } from './action';
|
|
5
5
|
export interface ICaptureController {
|
|
6
6
|
captureReplies: <TParentActionState extends IActionState>(
|
|
7
7
|
/**
|
|
@@ -13,12 +13,12 @@ export interface ICaptureController {
|
|
|
13
13
|
/** Callback that will be called on trigger */
|
|
14
14
|
handler: (replyContext: ReplyContext<TParentActionState>) => Promise<void>,
|
|
15
15
|
/** Abort controller to abort capturing manually */
|
|
16
|
-
abortController
|
|
16
|
+
abortController?: AbortController) => void;
|
|
17
17
|
}
|
|
18
18
|
export interface IReplyCapture {
|
|
19
19
|
trigger: CommandTrigger[];
|
|
20
20
|
handler: (replyContext: ReplyContextInternal<IActionState>) => Promise<void>;
|
|
21
21
|
abortController: AbortController;
|
|
22
|
-
action:
|
|
22
|
+
action: IAction;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=capture.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../types/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,oBAAoB,EACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../types/capture.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,YAAY,EACZ,oBAAoB,EACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAEnC,MAAM,WAAW,kBAAkB;IAC/B,cAAc,EAAE,CAAC,kBAAkB,SAAS,YAAY;IACpD;;;;OAIG;IACH,OAAO,EAAE,cAAc,EAAE;IACzB,8CAA8C;IAC9C,OAAO,EAAE,CACL,YAAY,EAAE,YAAY,CAAC,kBAAkB,CAAC,KAC7C,OAAO,CAAC,IAAI,CAAC;IAClB,mDAAmD;IACnD,eAAe,CAAC,EAAE,eAAe,KAChC,IAAI,CAAC;CACb;AAED,MAAM,WAAW,aAAa;IAC1B,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,OAAO,EAAE,CACL,YAAY,EAAE,oBAAoB,CAAC,YAAY,CAAC,KAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,eAAe,EAAE,eAAe,CAAC;IACjC,MAAM,EAAE,OAAO,CAAC;CACnB"}
|
|
@@ -2,7 +2,7 @@ import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult'
|
|
|
2
2
|
import { Noop } from '../../helpers/noop';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
4
|
import { CommandTrigger } from '../../types/commandTrigger';
|
|
5
|
-
import { ActionKey, IAction
|
|
5
|
+
import { ActionKey, IAction } from '../../types/action';
|
|
6
6
|
import { ReplyContextInternal } from '../context/replyContext';
|
|
7
7
|
|
|
8
8
|
export class ReplyCaptureAction<TParentActionState extends IActionState>
|
|
@@ -18,7 +18,7 @@ export class ReplyCaptureAction<TParentActionState extends IActionState>
|
|
|
18
18
|
|
|
19
19
|
constructor(
|
|
20
20
|
parentMessageId: number,
|
|
21
|
-
parentAction:
|
|
21
|
+
parentAction: IAction,
|
|
22
22
|
handler: (
|
|
23
23
|
replyContext: ReplyContextInternal<TParentActionState>
|
|
24
24
|
) => Promise<void>,
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { ChatInfo } from '../../dtos/chatInfo';
|
|
2
2
|
import { IAction, IActionWithState } from '../../types/action';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ICaptureController } from '../../types/capture';
|
|
5
|
+
import { CommandTrigger } from '../../types/commandTrigger';
|
|
4
6
|
import { IScopedLogger } from '../../types/logger';
|
|
5
|
-
import { BotResponse } from '../../types/response';
|
|
7
|
+
import { BotResponse, IReplyResponse } from '../../types/response';
|
|
6
8
|
import { IScheduler } from '../../types/scheduler';
|
|
7
9
|
import { IStorageClient } from '../../types/storage';
|
|
8
10
|
import { TraceId } from '../../types/trace';
|
|
11
|
+
import { ReplyContext } from './replyContext';
|
|
9
12
|
|
|
10
13
|
export type BaseContextPropertiesToOmit =
|
|
11
14
|
| 'action'
|
|
@@ -34,6 +37,9 @@ export abstract class BaseContextInternal<TAction extends IAction> {
|
|
|
34
37
|
botName!: string;
|
|
35
38
|
/** Chat information. */
|
|
36
39
|
chatInfo!: ChatInfo;
|
|
40
|
+
get actionKey() {
|
|
41
|
+
return this.action.key;
|
|
42
|
+
}
|
|
37
43
|
|
|
38
44
|
/** Ordered collection of responses to be processed */
|
|
39
45
|
public get responses(): BotResponse[] {
|
|
@@ -48,6 +54,27 @@ export abstract class BaseContextInternal<TAction extends IAction> {
|
|
|
48
54
|
this.scheduler = scheduler;
|
|
49
55
|
}
|
|
50
56
|
|
|
57
|
+
protected createCaptureController(
|
|
58
|
+
response: IReplyResponse
|
|
59
|
+
): ICaptureController {
|
|
60
|
+
return {
|
|
61
|
+
captureReplies: (
|
|
62
|
+
trigger: CommandTrigger[],
|
|
63
|
+
handler: (
|
|
64
|
+
replyContext: ReplyContext<IActionState>
|
|
65
|
+
) => Promise<void>,
|
|
66
|
+
abortController?: AbortController
|
|
67
|
+
) => {
|
|
68
|
+
response.captures.push({
|
|
69
|
+
trigger,
|
|
70
|
+
handler,
|
|
71
|
+
abortController: abortController ?? new AbortController(),
|
|
72
|
+
action: this.action
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
51
78
|
/**
|
|
52
79
|
* Loads state of another action for current chat.
|
|
53
80
|
* @param action Action to load state of.
|
|
@@ -9,12 +9,8 @@ import {
|
|
|
9
9
|
} from '../../types/messageSendingOptions';
|
|
10
10
|
import { IActionWithState } from '../../types/action';
|
|
11
11
|
import { IActionState } from '../../types/actionState';
|
|
12
|
-
import { IReplyResponse } from '../../types/response';
|
|
13
12
|
import { Milliseconds } from '../../types/timeValues';
|
|
14
13
|
import { DelayResponse } from '../../dtos/responses/delay';
|
|
15
|
-
import { ICaptureController } from '../../types/capture';
|
|
16
|
-
import { CommandTrigger } from '../../types/commandTrigger';
|
|
17
|
-
import { ReplyContext } from './replyContext';
|
|
18
14
|
import {
|
|
19
15
|
BaseContextInternal,
|
|
20
16
|
BaseContextPropertiesToOmit
|
|
@@ -36,27 +32,6 @@ export class ChatContextInternal<
|
|
|
36
32
|
TActionState extends IActionState,
|
|
37
33
|
TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>
|
|
38
34
|
> extends BaseContextInternal<TAction> {
|
|
39
|
-
protected createCaptureController(
|
|
40
|
-
response: IReplyResponse
|
|
41
|
-
): ICaptureController {
|
|
42
|
-
return {
|
|
43
|
-
captureReplies: (
|
|
44
|
-
trigger: CommandTrigger[],
|
|
45
|
-
handler: (
|
|
46
|
-
replyContext: ReplyContext<TActionState>
|
|
47
|
-
) => Promise<void>,
|
|
48
|
-
abortController: AbortController
|
|
49
|
-
) => {
|
|
50
|
-
response.captures.push({
|
|
51
|
-
trigger,
|
|
52
|
-
handler,
|
|
53
|
-
abortController,
|
|
54
|
-
action: this.action
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
35
|
/**
|
|
61
36
|
* Collection of actions that send something to chat as a standalone message.
|
|
62
37
|
*/
|
|
@@ -67,6 +67,8 @@ export class ReplyContextInternal<
|
|
|
67
67
|
);
|
|
68
68
|
|
|
69
69
|
this.responses.push(response);
|
|
70
|
+
|
|
71
|
+
return this.createCaptureController(response);
|
|
70
72
|
}
|
|
71
73
|
|
|
72
74
|
private replyWithImage(
|
|
@@ -86,6 +88,8 @@ export class ReplyContextInternal<
|
|
|
86
88
|
);
|
|
87
89
|
|
|
88
90
|
this.responses.push(response);
|
|
91
|
+
|
|
92
|
+
return this.createCaptureController(response);
|
|
89
93
|
}
|
|
90
94
|
|
|
91
95
|
private replyWithVideo(
|
|
@@ -105,6 +109,8 @@ export class ReplyContextInternal<
|
|
|
105
109
|
);
|
|
106
110
|
|
|
107
111
|
this.responses.push(response);
|
|
112
|
+
|
|
113
|
+
return this.createCaptureController(response);
|
|
108
114
|
}
|
|
109
115
|
|
|
110
116
|
/**
|
|
@@ -134,7 +140,7 @@ export class ReplyContextInternal<
|
|
|
134
140
|
quote?: string,
|
|
135
141
|
options?: TextMessageSendingOptions
|
|
136
142
|
) => {
|
|
137
|
-
this.replyWithText(text, quote ?? true, options);
|
|
143
|
+
return this.replyWithText(text, quote ?? true, options);
|
|
138
144
|
},
|
|
139
145
|
/**
|
|
140
146
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
@@ -147,7 +153,7 @@ export class ReplyContextInternal<
|
|
|
147
153
|
quote?: string,
|
|
148
154
|
options?: MessageSendingOptions
|
|
149
155
|
) => {
|
|
150
|
-
this.replyWithImage(name, quote ?? true, options);
|
|
156
|
+
return this.replyWithImage(name, quote ?? true, options);
|
|
151
157
|
},
|
|
152
158
|
|
|
153
159
|
/**
|
|
@@ -161,7 +167,7 @@ export class ReplyContextInternal<
|
|
|
161
167
|
quote?: string,
|
|
162
168
|
options?: MessageSendingOptions
|
|
163
169
|
) => {
|
|
164
|
-
this.replyWithVideo(name, quote ?? true, options);
|
|
170
|
+
return this.replyWithVideo(name, quote ?? true, options);
|
|
165
171
|
}
|
|
166
172
|
},
|
|
167
173
|
|
|
@@ -172,7 +178,7 @@ export class ReplyContextInternal<
|
|
|
172
178
|
* @param options Message sending option.
|
|
173
179
|
*/
|
|
174
180
|
withText: (text: string, options?: TextMessageSendingOptions) => {
|
|
175
|
-
this.replyWithText(text, false, options);
|
|
181
|
+
return this.replyWithText(text, false, options);
|
|
176
182
|
},
|
|
177
183
|
/**
|
|
178
184
|
* Reply with image message to message that triggered this action after action execution is finished.
|
|
@@ -181,7 +187,7 @@ export class ReplyContextInternal<
|
|
|
181
187
|
* @param options Message sending option.
|
|
182
188
|
*/
|
|
183
189
|
withImage: (name: string, options?: MessageSendingOptions) => {
|
|
184
|
-
this.replyWithImage(name, false, options);
|
|
190
|
+
return this.replyWithImage(name, false, options);
|
|
185
191
|
},
|
|
186
192
|
|
|
187
193
|
/**
|
|
@@ -191,7 +197,7 @@ export class ReplyContextInternal<
|
|
|
191
197
|
* @param options Message sending option.
|
|
192
198
|
*/
|
|
193
199
|
withVideo: (name: string, options?: MessageSendingOptions) => {
|
|
194
|
-
this.replyWithVideo(name, false, options);
|
|
200
|
+
return this.replyWithVideo(name, false, options);
|
|
195
201
|
},
|
|
196
202
|
|
|
197
203
|
/**
|
package/package.json
CHANGED
package/types/capture.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from '../entities/context/replyContext';
|
|
5
5
|
import { IActionState } from './actionState';
|
|
6
6
|
import { CommandTrigger } from './commandTrigger';
|
|
7
|
-
import {
|
|
7
|
+
import { IAction } from './action';
|
|
8
8
|
|
|
9
9
|
export interface ICaptureController {
|
|
10
10
|
captureReplies: <TParentActionState extends IActionState>(
|
|
@@ -19,7 +19,7 @@ export interface ICaptureController {
|
|
|
19
19
|
replyContext: ReplyContext<TParentActionState>
|
|
20
20
|
) => Promise<void>,
|
|
21
21
|
/** Abort controller to abort capturing manually */
|
|
22
|
-
abortController
|
|
22
|
+
abortController?: AbortController
|
|
23
23
|
) => void;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,5 +29,5 @@ export interface IReplyCapture {
|
|
|
29
29
|
replyContext: ReplyContextInternal<IActionState>
|
|
30
30
|
) => Promise<void>;
|
|
31
31
|
abortController: AbortController;
|
|
32
|
-
action:
|
|
32
|
+
action: IAction;
|
|
33
33
|
}
|