chz-telegram-bot 0.7.20 → 0.7.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dtos/responses/imageMessage.d.ts +2 -3
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.js +4 -3
- package/dist/dtos/responses/pin.d.ts +15 -0
- package/dist/dtos/responses/pin.d.ts.map +1 -0
- package/dist/dtos/responses/pin.js +15 -0
- package/dist/dtos/responses/textMessage.d.ts +1 -0
- package/dist/dtos/responses/textMessage.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.js +3 -0
- package/dist/dtos/responses/videoMessage.d.ts +2 -3
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.js +4 -3
- package/dist/entities/actions/commandAction.d.ts +1 -0
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +10 -8
- package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
- package/dist/entities/actions/inlineQueryAction.js +2 -1
- package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
- package/dist/entities/actions/replyCaptureAction.js +2 -1
- package/dist/entities/actions/scheduledAction.d.ts +1 -0
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +3 -2
- package/dist/entities/context/chatContext.d.ts +9 -3
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +13 -4
- package/dist/entities/context/messageContext.d.ts +5 -5
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +8 -8
- package/dist/entities/context/replyContext.d.ts +5 -5
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.js +12 -12
- package/dist/helpers/constants.d.ts +8 -0
- package/dist/helpers/constants.d.ts.map +1 -0
- package/dist/helpers/constants.js +7 -0
- package/dist/helpers/mapUtils.d.ts +1 -0
- package/dist/helpers/mapUtils.d.ts.map +1 -1
- package/dist/helpers/mapUtils.js +8 -0
- package/dist/services/actionProcessingService.d.ts.map +1 -1
- package/dist/services/actionProcessingService.js +2 -2
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +21 -23
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +19 -24
- package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/scheduledActionProcessor.js +16 -24
- package/dist/services/jsonFileStorage.d.ts +2 -1
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/jsonFileStorage.js +7 -5
- package/dist/services/responseProcessingQueue.d.ts.map +1 -1
- package/dist/services/responseProcessingQueue.js +1 -1
- package/dist/services/telegramApi.d.ts +0 -2
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +85 -99
- package/dist/types/response.d.ts +4 -2
- package/dist/types/response.d.ts.map +1 -1
- package/dist/types/response.js +1 -0
- package/package.json +5 -4
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IReplyResponseWithContent } from '../../types/response';
|
|
2
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
2
|
import { IAction } from '../../types/action';
|
|
4
3
|
import { ChatInfo } from '../chatInfo';
|
|
5
4
|
import { TraceId } from '../../types/trace';
|
|
@@ -15,8 +14,8 @@ export declare class ImageMessage implements IReplyResponseWithContent<InputFile
|
|
|
15
14
|
readonly replyInfo: ReplyInfo | undefined;
|
|
16
15
|
readonly traceId: TraceId;
|
|
17
16
|
readonly disableWebPreview = false;
|
|
18
|
-
readonly shouldPin: boolean;
|
|
19
17
|
readonly action: IAction;
|
|
20
|
-
constructor(image: InputFile, chatInfo: ChatInfo, traceId: TraceId, action: IAction, replyInfo
|
|
18
|
+
constructor(image: InputFile, chatInfo: ChatInfo, traceId: TraceId, action: IAction, replyInfo?: ReplyInfo);
|
|
19
|
+
get quotelessReply(): ImageMessage;
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=imageMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,YAAa,YAAW,yBAAyB,CAAC,SAAS,CAAC;IACrE,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAChC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAM;IAExC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAGrB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,SAAS;IASzB,IAAI,cAAc,iBAQjB;CACJ"}
|
|
@@ -8,14 +8,15 @@ export class ImageMessage {
|
|
|
8
8
|
replyInfo;
|
|
9
9
|
traceId;
|
|
10
10
|
disableWebPreview = false;
|
|
11
|
-
shouldPin;
|
|
12
11
|
action;
|
|
13
|
-
constructor(image, chatInfo, traceId, action, replyInfo
|
|
12
|
+
constructor(image, chatInfo, traceId, action, replyInfo) {
|
|
14
13
|
this.content = image;
|
|
15
14
|
this.chatInfo = chatInfo;
|
|
16
15
|
this.replyInfo = replyInfo;
|
|
17
16
|
this.traceId = traceId;
|
|
18
|
-
this.shouldPin = options?.pin ?? false;
|
|
19
17
|
this.action = action;
|
|
20
18
|
}
|
|
19
|
+
get quotelessReply() {
|
|
20
|
+
return new ImageMessage(this.content, this.chatInfo, this.traceId, this.action, undefined);
|
|
21
|
+
}
|
|
21
22
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IChatResponse } from '../../types/response';
|
|
2
|
+
import { IActionWithState } from '../../types/action';
|
|
3
|
+
import { IActionState } from '../../types/actionState';
|
|
4
|
+
import { ChatInfo } from '../chatInfo';
|
|
5
|
+
import { TraceId } from '../../types/trace';
|
|
6
|
+
export declare class PinResponse implements IChatResponse {
|
|
7
|
+
readonly kind: "pin";
|
|
8
|
+
readonly createdAt: number;
|
|
9
|
+
readonly messageId: number;
|
|
10
|
+
readonly chatInfo: ChatInfo;
|
|
11
|
+
readonly traceId: TraceId;
|
|
12
|
+
readonly action: IActionWithState<IActionState>;
|
|
13
|
+
constructor(messageId: number, chatInfo: ChatInfo, traceId: TraceId, action: IActionWithState<IActionState>);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=pin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pin.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/pin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,WAAY,YAAW,aAAa;IAC7C,QAAQ,CAAC,IAAI,QAAwB;IACrC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BotResponseTypes } from '../../types/response';
|
|
2
|
+
export class PinResponse {
|
|
3
|
+
kind = BotResponseTypes.pin;
|
|
4
|
+
createdAt = Date.now();
|
|
5
|
+
messageId;
|
|
6
|
+
chatInfo;
|
|
7
|
+
traceId;
|
|
8
|
+
action;
|
|
9
|
+
constructor(messageId, chatInfo, traceId, action) {
|
|
10
|
+
this.messageId = messageId;
|
|
11
|
+
this.chatInfo = chatInfo;
|
|
12
|
+
this.traceId = traceId;
|
|
13
|
+
this.action = action;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -19,5 +19,6 @@ export declare class TextMessage implements IReplyResponseWithContent<string> {
|
|
|
19
19
|
readonly action: IAction;
|
|
20
20
|
readonly keyboard?: TelegramInlineKeyboardButton[][];
|
|
21
21
|
constructor(text: string, chatInfo: ChatInfo, traceId: TraceId, action: IAction, replyInfo?: ReplyInfo, options?: TextMessageSendingOptions);
|
|
22
|
+
get quotelessReply(): TextMessage;
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=textMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAEH,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E,qBAAa,WAAY,YAAW,yBAAyB,CAAC,MAAM,CAAC;IACjE,QAAQ,CAAC,IAAI,SAAyB;IACtC,QAAQ,CAAC,SAAS,SAAc;IAChC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAM;IAExC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CA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Q,CAAC,EAAE,4BAA4B,EAAE,EAAE,CAAC;gBAGjD,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,SAAS,EACrB,OAAO,CAAC,EAAE,yBAAyB;IAYvC,IAAI,cAAc,gBASjB;CACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { IReplyResponseWithContent } from '../../types/response';
|
|
2
|
-
import { MessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
2
|
import { IAction } from '../../types/action';
|
|
4
3
|
import { ChatInfo } from '../chatInfo';
|
|
5
4
|
import { TraceId } from '../../types/trace';
|
|
@@ -15,8 +14,8 @@ export declare class VideoMessage implements IReplyResponseWithContent<InputFile
|
|
|
15
14
|
readonly replyInfo: ReplyInfo | undefined;
|
|
16
15
|
readonly traceId: TraceId;
|
|
17
16
|
readonly disableWebPreview = false;
|
|
18
|
-
readonly shouldPin: boolean;
|
|
19
17
|
readonly action: IAction;
|
|
20
|
-
constructor(video: InputFile, chatInfo: ChatInfo, traceId: TraceId, action: IAction, replyInfo
|
|
18
|
+
constructor(video: InputFile, chatInfo: ChatInfo, traceId: TraceId, action: IAction, replyInfo?: ReplyInfo);
|
|
19
|
+
get quotelessReply(): VideoMessage;
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=videoMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../src/dtos/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,yBAAyB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,qBAAa,YAAa,YAAW,yBAAyB,CAAC,SAAS,CAAC;IACrE,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAChC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAM;IAExC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;gBAGrB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,OAAO,EACf,SAAS,CAAC,EAAE,SAAS;IASzB,IAAI,cAAc,iBAQjB;CACJ"}
|
|
@@ -8,14 +8,15 @@ export class VideoMessage {
|
|
|
8
8
|
replyInfo;
|
|
9
9
|
traceId;
|
|
10
10
|
disableWebPreview = false;
|
|
11
|
-
shouldPin;
|
|
12
11
|
action;
|
|
13
|
-
constructor(video, chatInfo, traceId, action, replyInfo
|
|
12
|
+
constructor(video, chatInfo, traceId, action, replyInfo) {
|
|
14
13
|
this.content = video;
|
|
15
14
|
this.chatInfo = chatInfo;
|
|
16
15
|
this.replyInfo = replyInfo;
|
|
17
16
|
this.traceId = traceId;
|
|
18
|
-
this.shouldPin = options?.pin ?? false;
|
|
19
17
|
this.action = action;
|
|
20
18
|
}
|
|
19
|
+
get quotelessReply() {
|
|
20
|
+
return new VideoMessage(this.content, this.chatInfo, this.traceId, this.action, undefined);
|
|
21
|
+
}
|
|
21
22
|
}
|
|
@@ -22,6 +22,7 @@ export declare class CommandAction<TActionState extends IActionState> implements
|
|
|
22
22
|
readonly condition: CommandCondition<TActionState>;
|
|
23
23
|
readonly stateConstructor: () => TActionState;
|
|
24
24
|
readonly readmeFactory: (botName: string) => string;
|
|
25
|
+
readonly semaphoreFactory: () => Semaphore;
|
|
25
26
|
private lastCustomCooldown;
|
|
26
27
|
constructor(trigger: CommandTrigger | CommandTrigger[], handler: CommandHandler<TActionState>, name: string, providers: CommandActionProviders, maxAllowedSimultaniousExecutions: number, condition: CommandCondition<TActionState>, stateConstructor: () => TActionState, readmeFactory: (botName: string) => string);
|
|
27
28
|
exec(ctx: MessageContextInternal<TActionState>): Promise<BotResponse[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../src/entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5D,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAO/C,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3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,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC;IACpD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,SAAS,CAAC;IAE3C,OAAO,CAAC,kBAAkB,CAAsB;gBAG5C,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,sBAAsB,EACjC,gCAAgC,EAAE,MAAM,EACxC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY,EACpC,aAAa,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM;IAyBxC,IAAI,CACN,GAAG,EAAE,sBAAsB,CAAC,YAAY,CAAC,GAC1C,OAAO,CAAC,WAAW,EAAE,CAAC;IA2FzB,OAAO,CAAC,uBAAuB;IA6D/B,OAAO,CAAC,YAAY;CAwCvB"}
|
|
@@ -5,11 +5,11 @@ import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult'
|
|
|
5
5
|
import { Noop } from '../../helpers/noop';
|
|
6
6
|
import { MessageType } from '../../types/messageTypes';
|
|
7
7
|
import { Sema as Semaphore } from 'async-sema';
|
|
8
|
-
import {
|
|
8
|
+
import { getOrCreateIfNotExists } from '../../helpers/mapUtils';
|
|
9
9
|
import { TextMessage } from '../../dtos/responses/textMessage';
|
|
10
10
|
import { ReplyInfo } from '../../dtos/replyInfo';
|
|
11
11
|
import { BotEventType } from '../../types/events';
|
|
12
|
-
|
|
12
|
+
import { REGEX_MATCH_LIMIT } from '../../helpers/constants';
|
|
13
13
|
export class CommandAction {
|
|
14
14
|
cooldownInfoProvider;
|
|
15
15
|
isActiveProvider;
|
|
@@ -25,6 +25,7 @@ export class CommandAction {
|
|
|
25
25
|
condition;
|
|
26
26
|
stateConstructor;
|
|
27
27
|
readmeFactory;
|
|
28
|
+
semaphoreFactory;
|
|
28
29
|
lastCustomCooldown;
|
|
29
30
|
constructor(trigger, handler, name, providers, maxAllowedSimultaniousExecutions, condition, stateConstructor, readmeFactory) {
|
|
30
31
|
this.triggers = toArray(trigger);
|
|
@@ -40,12 +41,13 @@ export class CommandAction {
|
|
|
40
41
|
this.readmeFactory = readmeFactory;
|
|
41
42
|
this.maxAllowedSimultaniousExecutions =
|
|
42
43
|
maxAllowedSimultaniousExecutions;
|
|
44
|
+
this.semaphoreFactory = () => new Semaphore(this.maxAllowedSimultaniousExecutions);
|
|
43
45
|
this.key = `command:${this.name.replace('.', '-')}`;
|
|
44
46
|
}
|
|
45
47
|
async exec(ctx) {
|
|
46
48
|
let lock;
|
|
47
49
|
if (this.maxAllowedSimultaniousExecutions != 0) {
|
|
48
|
-
lock =
|
|
50
|
+
lock = getOrCreateIfNotExists(this.ratelimitSemaphores, ctx.chatInfo.id, this.semaphoreFactory);
|
|
49
51
|
await lock.acquire();
|
|
50
52
|
}
|
|
51
53
|
try {
|
|
@@ -93,8 +95,13 @@ export class CommandAction {
|
|
|
93
95
|
}
|
|
94
96
|
}
|
|
95
97
|
checkIfShouldBeExecuted(ctx, trigger, state) {
|
|
98
|
+
if (!ctx.userInfo.id)
|
|
99
|
+
return CommandTriggerCheckResult.DontTriggerAndSkipCooldown('UserIdMissing');
|
|
96
100
|
if (!this.isActiveProvider(ctx))
|
|
97
101
|
return CommandTriggerCheckResult.DontTriggerAndSkipCooldown('ActionDisabled');
|
|
102
|
+
const triggerCheckResult = this.checkTrigger(ctx, trigger);
|
|
103
|
+
if (!triggerCheckResult.shouldExecute)
|
|
104
|
+
return triggerCheckResult;
|
|
98
105
|
const chatsBlacklist = this.chatsBlacklistProvider(ctx);
|
|
99
106
|
const chatsWhitelist = this.chatsWhitelistProvider(ctx);
|
|
100
107
|
const isChatInBlacklist = chatsBlacklist.includes(ctx.chatInfo.id);
|
|
@@ -102,11 +109,6 @@ export class CommandAction {
|
|
|
102
109
|
chatsWhitelist.includes(ctx.chatInfo.id);
|
|
103
110
|
if (isChatInBlacklist || !isChatInWhitelist)
|
|
104
111
|
return CommandTriggerCheckResult.DontTriggerAndSkipCooldown('ChatForbidden');
|
|
105
|
-
const triggerCheckResult = this.checkTrigger(ctx, trigger);
|
|
106
|
-
if (!triggerCheckResult.shouldExecute)
|
|
107
|
-
return triggerCheckResult;
|
|
108
|
-
if (!ctx.userInfo.id)
|
|
109
|
-
return CommandTriggerCheckResult.DontTriggerAndSkipCooldown('UserIdMissing');
|
|
110
112
|
const usersWhitelist = this.usersWhitelistProvider(ctx);
|
|
111
113
|
const isUserAllowed = usersWhitelist.length == 0 ||
|
|
112
114
|
usersWhitelist.includes(ctx.userInfo.id);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../src/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;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"inlineQueryAction.d.ts","sourceRoot":"","sources":["../../../src/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;AAC1D,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAK5E,qBAAa,iBAAkB,YAAW,OAAO;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,OAAO,CAAC,CAAC;IACjE,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,cAAc,EAAE,4BAA4B,CAAC,OAAO,CAAC,EACrD,OAAO,EAAE,MAAM;IAUb,IAAI,CAAC,GAAG,EAAE,0BAA0B;CAsD7C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Noop } from '../../helpers/noop';
|
|
2
2
|
import { BotEventType } from '../../types/events';
|
|
3
3
|
import { InlineQueryResponse } from '../../dtos/responses/inlineQueryResponse';
|
|
4
|
+
import { REGEX_MATCH_LIMIT } from '../../helpers/constants';
|
|
4
5
|
export class InlineQueryAction {
|
|
5
6
|
key;
|
|
6
7
|
isActiveProvider;
|
|
@@ -21,7 +22,7 @@ export class InlineQueryAction {
|
|
|
21
22
|
this.pattern.lastIndex = 0;
|
|
22
23
|
const execResult = this.pattern.exec(ctx.queryText);
|
|
23
24
|
if (execResult != null) {
|
|
24
|
-
let regexMatchLimit =
|
|
25
|
+
let regexMatchLimit = REGEX_MATCH_LIMIT;
|
|
25
26
|
matchResults.push(execResult);
|
|
26
27
|
if (this.pattern.global) {
|
|
27
28
|
while (regexMatchLimit > 0) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../src/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;
|
|
1
|
+
{"version":3,"file":"replyCaptureAction.d.ts","sourceRoot":"","sources":["../../../src/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;AAI/D,qBAAa,kBAAkB,CAC3B,kBAAkB,SAAS,YAAY,CACzC,YAAW,OAAO;IAChB,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;IA4BxD,OAAO,CAAC,uBAAuB;CA4ClC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult';
|
|
2
2
|
import { Noop } from '../../helpers/noop';
|
|
3
3
|
import { BotEventType } from '../../types/events';
|
|
4
|
+
import { REGEX_MATCH_LIMIT } from '../../helpers/constants';
|
|
4
5
|
export class ReplyCaptureAction {
|
|
5
6
|
parentMessageId;
|
|
6
7
|
key;
|
|
@@ -49,7 +50,7 @@ export class ReplyCaptureAction {
|
|
|
49
50
|
trigger.lastIndex = 0;
|
|
50
51
|
const execResult = trigger.exec(ctx.messageInfo.text);
|
|
51
52
|
if (execResult != null) {
|
|
52
|
-
let regexMatchLimit =
|
|
53
|
+
let regexMatchLimit = REGEX_MATCH_LIMIT;
|
|
53
54
|
matchResults.push(execResult);
|
|
54
55
|
if (trigger.global) {
|
|
55
56
|
while (regexMatchLimit > 0) {
|
|
@@ -7,6 +7,7 @@ import { ChatContextInternal } from '../context/chatContext';
|
|
|
7
7
|
import { ScheduledActionProviders } from '../../dtos/propertyProviderSets';
|
|
8
8
|
export declare class ScheduledAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
|
|
9
9
|
static readonly locks: Map<string, Semaphore>;
|
|
10
|
+
static readonly semaphoreFactory: () => Semaphore;
|
|
10
11
|
readonly name: string;
|
|
11
12
|
readonly key: ActionKey;
|
|
12
13
|
private readonly timeinHoursProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../src/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;AAGxD,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;AAI7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,qBAAa,eAAe,CACxB,YAAY,SAAS,YAAY,CACnC,YAAW,gBAAgB,CAAC,YAAY,CAAC;IACvC,MAAM,CAAC,Q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,EACvC,SAAS,EAAE,wBAAwB,EACnC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAclC,IAAI,CAAC,GAAG,EAAE,mBAAmB,CAAC,YAAY,CAAC;YAoDnC,cAAc;IA6D5B,OAAO,CAAC,uBAAuB;CAgBlC"}
|
|
@@ -2,10 +2,11 @@ import moment from 'moment';
|
|
|
2
2
|
import { Sema as Semaphore } from 'async-sema';
|
|
3
3
|
import { hoursToMilliseconds } from '../../helpers/timeConvertions';
|
|
4
4
|
import { Noop } from '../../helpers/noop';
|
|
5
|
-
import {
|
|
5
|
+
import { getOrCreateIfNotExists, getOrThrow } from '../../helpers/mapUtils';
|
|
6
6
|
import { BotEventType } from '../../types/events';
|
|
7
7
|
export class ScheduledAction {
|
|
8
8
|
static locks = new Map();
|
|
9
|
+
static semaphoreFactory = () => new Semaphore(1);
|
|
9
10
|
name;
|
|
10
11
|
key;
|
|
11
12
|
timeinHoursProvider;
|
|
@@ -53,7 +54,7 @@ export class ScheduledAction {
|
|
|
53
54
|
async getCachedValue(key, ctx) {
|
|
54
55
|
const cachedItemFactory = getOrThrow(this.cachedStateFactories, key, `No shared cache was set up for the key [${key}] in action '${this.name}'`);
|
|
55
56
|
const semaphoreKey = `${this.key}_cached:${key}`;
|
|
56
|
-
const semaphore =
|
|
57
|
+
const semaphore = getOrCreateIfNotExists(ScheduledAction.locks, semaphoreKey, ScheduledAction.semaphoreFactory);
|
|
57
58
|
await semaphore.acquire();
|
|
58
59
|
try {
|
|
59
60
|
if (this.cachedState.has(key)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
2
2
|
import { IActionWithState } from '../../types/action';
|
|
3
3
|
import { IActionState } from '../../types/actionState';
|
|
4
4
|
import { Milliseconds } from '../../types/timeValues';
|
|
@@ -26,14 +26,14 @@ export declare class ChatContextInternal<TActionState extends IActionState, TAct
|
|
|
26
26
|
* @param name Message contents.
|
|
27
27
|
* @param options Message sending option.
|
|
28
28
|
*/
|
|
29
|
-
image: (name: string
|
|
29
|
+
image: (name: string) => import("../..").ICaptureController;
|
|
30
30
|
/**
|
|
31
31
|
* Sends video/gif message to chat after action execution is finished.
|
|
32
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.
|
|
33
33
|
* @param name Message contents.
|
|
34
34
|
* @param options Message sending option.
|
|
35
35
|
*/
|
|
36
|
-
video: (name: string
|
|
36
|
+
video: (name: string) => import("../..").ICaptureController;
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
39
|
* Unpins message after action execution is finished.
|
|
@@ -41,6 +41,12 @@ export declare class ChatContextInternal<TActionState extends IActionState, TAct
|
|
|
41
41
|
* @param messageId Message id.
|
|
42
42
|
*/
|
|
43
43
|
unpinMessage(messageId: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Pins message after action execution is finished.
|
|
46
|
+
* 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.
|
|
47
|
+
* @param messageId Message id.
|
|
48
|
+
*/
|
|
49
|
+
pinMessage(messageId: number): void;
|
|
44
50
|
/**
|
|
45
51
|
* Delays next responses by specified amount of time.
|
|
46
52
|
* @param delay Delay in milliseconds.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,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;AAG7D,MAAM,MAAM,WAAW,CACnB,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAC1C,eAAe,CAAC,YAAY,CAAC,IACjC,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,GAC1C,eAAe,CAAC,YAAY,CAAC,CACnC,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IAClC;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAexD;;;;;WAKG;sBACW,MAAM;QAapB;;;;;WAKG;sBACW,MAAM;MAYtB;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;;OAIG;IACH,UAAU,CAAC,SAAS,EAAE,MAAM;IAW5B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAU3B"}
|
|
@@ -5,6 +5,7 @@ import { VideoMessage } from '../../dtos/responses/videoMessage';
|
|
|
5
5
|
import { UnpinResponse } from '../../dtos/responses/unpin';
|
|
6
6
|
import { DelayResponse } from '../../dtos/responses/delay';
|
|
7
7
|
import { BaseContextInternal } from './baseContext';
|
|
8
|
+
import { PinResponse } from '../../dtos/responses/pin';
|
|
8
9
|
/**
|
|
9
10
|
* Context of action executed in chat.
|
|
10
11
|
*/
|
|
@@ -30,8 +31,8 @@ export class ChatContextInternal extends BaseContextInternal {
|
|
|
30
31
|
* @param name Message contents.
|
|
31
32
|
* @param options Message sending option.
|
|
32
33
|
*/
|
|
33
|
-
image: (name
|
|
34
|
-
const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action
|
|
34
|
+
image: (name) => {
|
|
35
|
+
const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action);
|
|
35
36
|
this.responses.push(response);
|
|
36
37
|
return this.createCaptureController(response);
|
|
37
38
|
},
|
|
@@ -41,8 +42,8 @@ export class ChatContextInternal extends BaseContextInternal {
|
|
|
41
42
|
* @param name Message contents.
|
|
42
43
|
* @param options Message sending option.
|
|
43
44
|
*/
|
|
44
|
-
video: (name
|
|
45
|
-
const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action
|
|
45
|
+
video: (name) => {
|
|
46
|
+
const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action);
|
|
46
47
|
this.responses.push(response);
|
|
47
48
|
return this.createCaptureController(response);
|
|
48
49
|
}
|
|
@@ -55,6 +56,14 @@ export class ChatContextInternal extends BaseContextInternal {
|
|
|
55
56
|
unpinMessage(messageId) {
|
|
56
57
|
this.responses.push(new UnpinResponse(messageId, this.chatInfo, this.observability.traceId, this.action));
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Pins message after action execution is finished.
|
|
61
|
+
* 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.
|
|
62
|
+
* @param messageId Message id.
|
|
63
|
+
*/
|
|
64
|
+
pinMessage(messageId) {
|
|
65
|
+
this.responses.push(new PinResponse(messageId, this.chatInfo, this.observability.traceId, this.action));
|
|
66
|
+
}
|
|
58
67
|
/**
|
|
59
68
|
* Delays next responses by specified amount of time.
|
|
60
69
|
* @param delay Delay in milliseconds.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IActionState } from '../../types/actionState';
|
|
2
2
|
import { ChatContextInternal } from './chatContext';
|
|
3
|
-
import {
|
|
3
|
+
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
4
4
|
import { CommandAction } from '../actions/commandAction';
|
|
5
5
|
import { Seconds } from '../../types/timeValues';
|
|
6
6
|
import { BaseContextPropertiesToOmit } from './baseContext';
|
|
@@ -56,14 +56,14 @@ export declare class MessageContextInternal<TActionState extends IActionState> e
|
|
|
56
56
|
* @param text Message contents.
|
|
57
57
|
* @param options Message sending option.
|
|
58
58
|
*/
|
|
59
|
-
withImage: (name: string, quote?: string
|
|
59
|
+
withImage: (name: string, quote?: string) => import("../..").ICaptureController;
|
|
60
60
|
/**
|
|
61
61
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
62
62
|
* 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.
|
|
63
63
|
* @param text Message contents.
|
|
64
64
|
* @param options Message sending option.
|
|
65
65
|
*/
|
|
66
|
-
withVideo: (name: string, quote?: string
|
|
66
|
+
withVideo: (name: string, quote?: string) => import("../..").ICaptureController;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
69
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -78,14 +78,14 @@ export declare class MessageContextInternal<TActionState extends IActionState> e
|
|
|
78
78
|
* @param text Message contents.
|
|
79
79
|
* @param options Message sending option.
|
|
80
80
|
*/
|
|
81
|
-
withImage: (name: string
|
|
81
|
+
withImage: (name: string) => import("../..").ICaptureController;
|
|
82
82
|
/**
|
|
83
83
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
84
84
|
* 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.
|
|
85
85
|
* @param text Message contents.
|
|
86
86
|
* @param options Message sending option.
|
|
87
87
|
*/
|
|
88
|
-
withVideo: (name: string
|
|
88
|
+
withVideo: (name: string) => import("../..").ICaptureController;
|
|
89
89
|
/**
|
|
90
90
|
* React to the message that triggered this action after action execution is finished.
|
|
91
91
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,
|
|
1
|
+
{"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAE9E,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;AAC/C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAG7D,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,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,6BAA6B;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,yDAAyD;IACzD,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;gBAGlC,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,UAAU,EACrB,YAAY,EAAE,iBAAiB,EAC/B,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,EACnC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,OAAO;IA2BpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAgBtB,OAAO,CAAC,cAAc;IAgBtB,YAAY;IAIZ,mBAAmB,CAAC,cAAc,EAAE,OAAO;IAK3C;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;YAGxC;;;;;eAKG;8BACe,MAAM,UAAU,MAAM;;QAI5C;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM;QAExB;;;;;WAKG;0BACe,MAAM;QAExB;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
|
|
@@ -37,15 +37,15 @@ export class MessageContextInternal extends ChatContextInternal {
|
|
|
37
37
|
this.responses.push(response);
|
|
38
38
|
return this.createCaptureController(response);
|
|
39
39
|
}
|
|
40
|
-
replyWithImage(name, quote
|
|
40
|
+
replyWithImage(name, quote) {
|
|
41
41
|
const quotedPart = getQuotedText(this, quote);
|
|
42
|
-
const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined)
|
|
42
|
+
const response = new ImageMessage({ source: resolve(`./content/${name}.png`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined));
|
|
43
43
|
this.responses.push(response);
|
|
44
44
|
return this.createCaptureController(response);
|
|
45
45
|
}
|
|
46
|
-
replyWithVideo(name, quote
|
|
46
|
+
replyWithVideo(name, quote) {
|
|
47
47
|
const quotedPart = getQuotedText(this, quote);
|
|
48
|
-
const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined)
|
|
48
|
+
const response = new VideoMessage({ source: resolve(`./content/${name}.mp4`) }, this.chatInfo, this.observability.traceId, this.action, new ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined));
|
|
49
49
|
this.responses.push(response);
|
|
50
50
|
return this.createCaptureController(response);
|
|
51
51
|
}
|
|
@@ -78,14 +78,14 @@ export class MessageContextInternal extends ChatContextInternal {
|
|
|
78
78
|
* @param text Message contents.
|
|
79
79
|
* @param options Message sending option.
|
|
80
80
|
*/
|
|
81
|
-
withImage: (name, quote
|
|
81
|
+
withImage: (name, quote) => this.replyWithImage(name, quote ?? true),
|
|
82
82
|
/**
|
|
83
83
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
84
84
|
* 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.
|
|
85
85
|
* @param text Message contents.
|
|
86
86
|
* @param options Message sending option.
|
|
87
87
|
*/
|
|
88
|
-
withVideo: (name, quote
|
|
88
|
+
withVideo: (name, quote) => this.replyWithVideo(name, quote ?? true)
|
|
89
89
|
},
|
|
90
90
|
/**
|
|
91
91
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -100,14 +100,14 @@ export class MessageContextInternal extends ChatContextInternal {
|
|
|
100
100
|
* @param text Message contents.
|
|
101
101
|
* @param options Message sending option.
|
|
102
102
|
*/
|
|
103
|
-
withImage: (name
|
|
103
|
+
withImage: (name) => this.replyWithImage(name, false),
|
|
104
104
|
/**
|
|
105
105
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
106
106
|
* 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.
|
|
107
107
|
* @param text Message contents.
|
|
108
108
|
* @param options Message sending option.
|
|
109
109
|
*/
|
|
110
|
-
withVideo: (name
|
|
110
|
+
withVideo: (name) => this.replyWithVideo(name, false),
|
|
111
111
|
/**
|
|
112
112
|
* React to the message that triggered this action after action execution is finished.
|
|
113
113
|
* 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 { IActionState } from '../../types/actionState';
|
|
2
|
-
import { TextMessageSendingOptions
|
|
2
|
+
import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
|
|
3
3
|
import { ReplyCaptureAction } from '../actions/replyCaptureAction';
|
|
4
4
|
import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
|
|
5
5
|
import { UserInfo } from '../../dtos/userInfo';
|
|
@@ -51,14 +51,14 @@ export declare class ReplyContextInternal<TParentActionState extends IActionStat
|
|
|
51
51
|
* @param text Message contents.
|
|
52
52
|
* @param options Message sending option.
|
|
53
53
|
*/
|
|
54
|
-
withImage: (name: string, quote?: string
|
|
54
|
+
withImage: (name: string, quote?: string) => import("../..").ICaptureController;
|
|
55
55
|
/**
|
|
56
56
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
57
57
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
58
58
|
* @param text Message contents.
|
|
59
59
|
* @param options Message sending option.
|
|
60
60
|
*/
|
|
61
|
-
withVideo: (name: string, quote?: string
|
|
61
|
+
withVideo: (name: string, quote?: string) => import("../..").ICaptureController;
|
|
62
62
|
};
|
|
63
63
|
/**
|
|
64
64
|
* Reply with text message to message that triggered this action after action execution is finished.
|
|
@@ -73,14 +73,14 @@ export declare class ReplyContextInternal<TParentActionState extends IActionStat
|
|
|
73
73
|
* @param text Message contents.
|
|
74
74
|
* @param options Message sending option.
|
|
75
75
|
*/
|
|
76
|
-
withImage: (name: string
|
|
76
|
+
withImage: (name: string) => import("../..").ICaptureController;
|
|
77
77
|
/**
|
|
78
78
|
* Reply with video/gif message to message that triggered this action after action execution is finished.
|
|
79
79
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
80
80
|
* @param text Message contents.
|
|
81
81
|
* @param options Message sending option.
|
|
82
82
|
*/
|
|
83
|
-
withVideo: (name: string
|
|
83
|
+
withVideo: (name: string) => import("../..").ICaptureController;
|
|
84
84
|
/**
|
|
85
85
|
* React to the message that triggered this action after action execution is finished.
|
|
86
86
|
* If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"replyContext.d.ts","sourceRoot":"","sources":["../../../src/entities/context/replyContext.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,QAAQ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