chz-telegram-bot 0.0.15 → 0.0.17
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/actionExecutionResult.d.ts +7 -0
- package/dist/entities/actionExecutionResult.d.ts.map +1 -0
- package/dist/entities/{transactionResult.js → actionExecutionResult.js} +3 -2
- package/dist/entities/actions/commandAction.d.ts +4 -4
- package/dist/entities/actions/commandAction.d.ts.map +1 -1
- package/dist/entities/actions/commandAction.js +12 -11
- package/dist/entities/actions/scheduledAction.d.ts +5 -5
- package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
- package/dist/entities/actions/scheduledAction.js +10 -9
- package/dist/entities/{bot.d.ts → botInstance.d.ts} +5 -5
- package/dist/entities/botInstance.d.ts.map +1 -0
- package/dist/entities/{bot.js → botInstance.js} +20 -22
- package/dist/entities/cachedStateFactory.d.ts +1 -1
- package/dist/entities/cachedStateFactory.d.ts.map +1 -1
- package/dist/entities/cachedStateFactory.js +2 -1
- package/dist/entities/commandTriggerCheckResult.d.ts +1 -1
- package/dist/entities/commandTriggerCheckResult.d.ts.map +1 -1
- package/dist/entities/commandTriggerCheckResult.js +2 -1
- package/dist/entities/context/chatContext.d.ts +7 -5
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +17 -14
- package/dist/entities/context/messageContext.d.ts +7 -7
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.js +19 -21
- package/dist/entities/incomingMessage.d.ts +1 -1
- package/dist/entities/incomingMessage.d.ts.map +1 -1
- package/dist/entities/incomingMessage.js +2 -1
- package/dist/entities/responses/imageMessage.d.ts +6 -3
- package/dist/entities/responses/imageMessage.d.ts.map +1 -1
- package/dist/entities/responses/imageMessage.js +7 -2
- package/dist/entities/responses/reaction.d.ts +5 -2
- package/dist/entities/responses/reaction.d.ts.map +1 -1
- package/dist/entities/responses/reaction.js +6 -2
- package/dist/entities/responses/textMessage.d.ts +6 -3
- package/dist/entities/responses/textMessage.d.ts.map +1 -1
- package/dist/entities/responses/textMessage.js +7 -2
- package/dist/entities/responses/unpin.d.ts +10 -0
- package/dist/entities/responses/unpin.d.ts.map +1 -0
- package/dist/entities/responses/unpin.js +14 -0
- package/dist/entities/responses/videoMessage.d.ts +6 -3
- package/dist/entities/responses/videoMessage.d.ts.map +1 -1
- package/dist/entities/responses/videoMessage.js +7 -2
- package/dist/entities/states/actionStateBase.d.ts +3 -2
- package/dist/entities/states/actionStateBase.d.ts.map +1 -1
- package/dist/entities/states/actionStateBase.js +3 -1
- package/dist/entities/taskRecord.d.ts +1 -1
- package/dist/entities/taskRecord.d.ts.map +1 -1
- package/dist/entities/taskRecord.js +2 -1
- package/dist/helpers/builders/commandActionBuilder.d.ts +3 -3
- package/dist/helpers/builders/commandActionBuilder.d.ts.map +1 -1
- package/dist/helpers/builders/commandActionBuilder.js +9 -12
- package/dist/helpers/builders/scheduledActionBuilder.d.ts +3 -3
- package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +1 -1
- package/dist/helpers/builders/scheduledActionBuilder.js +8 -10
- package/dist/helpers/noop.d.ts +1 -2
- package/dist/helpers/noop.d.ts.map +1 -1
- package/dist/helpers/noop.js +2 -1
- package/dist/helpers/toArray.d.ts +1 -1
- package/dist/helpers/toArray.d.ts.map +1 -1
- package/dist/helpers/toArray.js +1 -1
- package/dist/main.d.ts +5 -5
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +6 -9
- package/dist/services/jsonFileStorage.d.ts +6 -5
- package/dist/services/jsonFileStorage.d.ts.map +1 -1
- package/dist/services/jsonFileStorage.js +10 -1
- package/dist/services/logger.d.ts +3 -3
- package/dist/services/logger.d.ts.map +1 -1
- package/dist/services/logger.js +3 -2
- package/dist/services/taskScheduler.d.ts +3 -3
- package/dist/services/taskScheduler.d.ts.map +1 -1
- package/dist/services/taskScheduler.js +8 -10
- package/dist/services/telegramApi.d.ts +20 -15
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +50 -43
- package/dist/types/actionState.d.ts +2 -1
- package/dist/types/actionState.d.ts.map +1 -1
- package/dist/types/actionWithState.d.ts +2 -2
- package/dist/types/actionWithState.d.ts.map +1 -1
- package/dist/types/commandCondition.d.ts +2 -2
- package/dist/types/commandCondition.d.ts.map +1 -1
- package/dist/types/handlers.d.ts +3 -3
- package/dist/types/handlers.d.ts.map +1 -1
- package/dist/types/replyMessage.d.ts +1 -1
- package/dist/types/replyMessage.d.ts.map +1 -1
- package/dist/types/response.d.ts +26 -0
- package/dist/types/response.d.ts.map +1 -0
- package/dist/types/response.js +10 -0
- package/dist/types/storage.d.ts +5 -4
- package/dist/types/storage.d.ts.map +1 -1
- package/entities/{transactionResult.ts → actionExecutionResult.ts} +2 -2
- package/entities/actions/commandAction.ts +10 -10
- package/entities/actions/scheduledAction.ts +13 -13
- package/entities/{bot.ts → botInstance.ts} +20 -20
- package/entities/cachedStateFactory.ts +1 -1
- package/entities/commandTriggerCheckResult.ts +1 -1
- package/entities/context/chatContext.ts +35 -10
- package/entities/context/messageContext.ts +37 -16
- package/entities/incomingMessage.ts +1 -1
- package/entities/responses/imageMessage.ts +11 -3
- package/entities/responses/reaction.ts +8 -2
- package/entities/responses/textMessage.ts +11 -3
- package/entities/responses/unpin.ts +22 -0
- package/entities/responses/videoMessage.ts +11 -3
- package/entities/states/actionStateBase.ts +3 -2
- package/entities/taskRecord.ts +1 -1
- package/helpers/builders/commandActionBuilder.ts +5 -5
- package/helpers/builders/scheduledActionBuilder.ts +4 -4
- package/helpers/noop.ts +1 -3
- package/helpers/toArray.ts +1 -1
- package/main.ts +9 -9
- package/package.json +1 -1
- package/services/jsonFileStorage.ts +21 -6
- package/services/logger.ts +2 -2
- package/services/taskScheduler.ts +6 -6
- package/services/telegramApi.ts +95 -59
- package/types/actionState.ts +2 -1
- package/types/actionWithState.ts +2 -2
- package/types/commandCondition.ts +2 -2
- package/types/handlers.ts +3 -3
- package/types/response.ts +34 -0
- package/types/storage.ts +9 -5
- package/dist/entities/bot.d.ts.map +0 -1
- package/dist/entities/transactionResult.d.ts +0 -7
- package/dist/entities/transactionResult.d.ts.map +0 -1
- package/types/replyMessage.ts +0 -7
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ImageMessage = void 0;
|
|
4
|
+
const response_1 = require("../../types/response");
|
|
3
5
|
class ImageMessage {
|
|
4
|
-
constructor(image, chatId, replyId, traceId) {
|
|
6
|
+
constructor(image, chatId, replyId, traceId, pinned, sourceActionKey) {
|
|
7
|
+
this.kind = response_1.BotResponseTypes.image;
|
|
5
8
|
this.disableWebPreview = false;
|
|
6
9
|
this.content = image;
|
|
7
10
|
this.chatId = chatId;
|
|
8
11
|
this.replyId = replyId;
|
|
9
12
|
this.traceId = traceId;
|
|
13
|
+
this.shouldPin = pinned;
|
|
14
|
+
this.sourceActionKey = sourceActionKey;
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
|
-
exports.
|
|
17
|
+
exports.ImageMessage = ImageMessage;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { TelegramEmoji } from 'telegraf/types';
|
|
2
|
-
|
|
2
|
+
import { IChatResponse } from '../../types/response';
|
|
3
|
+
export declare class Reaction implements IChatResponse {
|
|
4
|
+
kind: "react";
|
|
3
5
|
chatId: number;
|
|
4
6
|
messageId: number;
|
|
5
7
|
traceId: number | string;
|
|
6
8
|
emoji: TelegramEmoji;
|
|
7
|
-
|
|
9
|
+
sourceActionKey: string;
|
|
10
|
+
constructor(traceId: number | string, chatId: number, messageId: number, emoji: TelegramEmoji, sourceActionKey: string);
|
|
8
11
|
}
|
|
9
12
|
//# sourceMappingURL=reaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../entities/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../entities/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,QAAS,YAAW,aAAa;IAC1C,IAAI,UAA0B;IAE9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;gBAGpB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,eAAe,EAAE,MAAM;CAQ9B"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reaction = void 0;
|
|
4
|
+
const response_1 = require("../../types/response");
|
|
3
5
|
class Reaction {
|
|
4
|
-
constructor(traceId, chatId, messageId, emoji) {
|
|
6
|
+
constructor(traceId, chatId, messageId, emoji, sourceActionKey) {
|
|
7
|
+
this.kind = response_1.BotResponseTypes.react;
|
|
5
8
|
this.chatId = chatId;
|
|
6
9
|
this.messageId = messageId;
|
|
7
10
|
this.emoji = emoji;
|
|
8
11
|
this.traceId = traceId;
|
|
12
|
+
this.sourceActionKey = sourceActionKey;
|
|
9
13
|
}
|
|
10
14
|
}
|
|
11
|
-
exports.
|
|
15
|
+
exports.Reaction = Reaction;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import IReplyMessage from '../../types/
|
|
2
|
-
export
|
|
1
|
+
import { IReplyMessage } from '../../types/response';
|
|
2
|
+
export declare class TextMessage implements IReplyMessage<string> {
|
|
3
|
+
kind: "text";
|
|
3
4
|
content: string;
|
|
4
5
|
chatId: number;
|
|
5
6
|
replyId: number | undefined;
|
|
6
7
|
traceId: string | number;
|
|
7
8
|
disableWebPreview: boolean;
|
|
8
|
-
|
|
9
|
+
shouldPin: boolean;
|
|
10
|
+
sourceActionKey: string;
|
|
11
|
+
constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number, disableWebPreview: boolean, pinned: boolean, sourceActionKey: string);
|
|
9
12
|
}
|
|
10
13
|
//# sourceMappingURL=textMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,IAAI,SAAyB;IAE7B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,iBAAiB,EAAE,OAAO,EAC1B,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,MAAM;CAU9B"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextMessage = void 0;
|
|
4
|
+
const response_1 = require("../../types/response");
|
|
3
5
|
class TextMessage {
|
|
4
|
-
constructor(text, chatId, replyId, traceId, disableWebPreview) {
|
|
6
|
+
constructor(text, chatId, replyId, traceId, disableWebPreview, pinned, sourceActionKey) {
|
|
7
|
+
this.kind = response_1.BotResponseTypes.text;
|
|
5
8
|
this.content = text;
|
|
6
9
|
this.chatId = chatId;
|
|
7
10
|
this.replyId = replyId;
|
|
8
11
|
this.traceId = traceId;
|
|
9
12
|
this.disableWebPreview = disableWebPreview;
|
|
13
|
+
this.shouldPin = pinned;
|
|
14
|
+
this.sourceActionKey = sourceActionKey;
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
|
-
exports.
|
|
17
|
+
exports.TextMessage = TextMessage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IChatResponse } from '../../types/response';
|
|
2
|
+
export declare class UnpinResponse implements IChatResponse {
|
|
3
|
+
kind: "unpin";
|
|
4
|
+
messageId: number;
|
|
5
|
+
chatId: number;
|
|
6
|
+
traceId: number | string;
|
|
7
|
+
sourceActionKey: string;
|
|
8
|
+
constructor(messageId: number, chatId: number, traceId: number | string, sourceActionKey: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=unpin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../entities/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,aAAc,YAAW,aAAa;IAC/C,IAAI,UAA0B;IAE9B,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;gBAGpB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,eAAe,EAAE,MAAM;CAO9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnpinResponse = void 0;
|
|
4
|
+
const response_1 = require("../../types/response");
|
|
5
|
+
class UnpinResponse {
|
|
6
|
+
constructor(messageId, chatId, traceId, sourceActionKey) {
|
|
7
|
+
this.kind = response_1.BotResponseTypes.unpin;
|
|
8
|
+
this.messageId = messageId;
|
|
9
|
+
this.chatId = chatId;
|
|
10
|
+
this.traceId = traceId;
|
|
11
|
+
this.sourceActionKey = sourceActionKey;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.UnpinResponse = UnpinResponse;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { InputFile } from 'telegraf/types';
|
|
2
|
-
import IReplyMessage from '../../types/
|
|
3
|
-
export
|
|
2
|
+
import { IReplyMessage } from '../../types/response';
|
|
3
|
+
export declare class VideoMessage implements IReplyMessage<InputFile> {
|
|
4
|
+
kind: "video";
|
|
4
5
|
content: InputFile;
|
|
5
6
|
chatId: number;
|
|
6
7
|
replyId: number | undefined;
|
|
7
8
|
traceId: string | number;
|
|
8
9
|
disableWebPreview: boolean;
|
|
9
|
-
|
|
10
|
+
shouldPin: boolean;
|
|
11
|
+
sourceActionKey: string;
|
|
12
|
+
constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, pinned: boolean, sourceActionKey: string);
|
|
10
13
|
}
|
|
11
14
|
//# sourceMappingURL=videoMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../entities/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEvE,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,IAAI,UAA0B;IAE9B,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,iBAAiB,UAAS;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;gBAGpB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,OAAO,EACf,eAAe,EAAE,MAAM;CAS9B"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoMessage = void 0;
|
|
4
|
+
const response_1 = require("../../types/response");
|
|
3
5
|
class VideoMessage {
|
|
4
|
-
constructor(video, chatId, replyId, traceId) {
|
|
6
|
+
constructor(video, chatId, replyId, traceId, pinned, sourceActionKey) {
|
|
7
|
+
this.kind = response_1.BotResponseTypes.video;
|
|
5
8
|
this.disableWebPreview = false;
|
|
6
9
|
this.content = video;
|
|
7
10
|
this.chatId = chatId;
|
|
8
11
|
this.replyId = replyId;
|
|
9
12
|
this.traceId = traceId;
|
|
13
|
+
this.shouldPin = pinned;
|
|
14
|
+
this.sourceActionKey = sourceActionKey;
|
|
10
15
|
}
|
|
11
16
|
}
|
|
12
|
-
exports.
|
|
17
|
+
exports.VideoMessage = VideoMessage;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import IActionState from '../../types/actionState';
|
|
2
|
-
export
|
|
1
|
+
import { IActionState } from '../../types/actionState';
|
|
2
|
+
export declare class ActionStateBase implements IActionState {
|
|
3
|
+
pinnedMessages: number[];
|
|
3
4
|
lastExecutedDate: number;
|
|
4
5
|
}
|
|
5
6
|
//# sourceMappingURL=actionStateBase.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actionStateBase.d.ts","sourceRoot":"","sources":["../../../entities/states/actionStateBase.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"actionStateBase.d.ts","sourceRoot":"","sources":["../../../entities/states/actionStateBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,qBAAa,eAAgB,YAAW,YAAY;IAChD,cAAc,EAAE,MAAM,EAAE,CAAM;IAC9B,gBAAgB,SAAK;CACxB"}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ActionStateBase = void 0;
|
|
3
4
|
class ActionStateBase {
|
|
4
5
|
constructor() {
|
|
6
|
+
this.pinnedMessages = [];
|
|
5
7
|
this.lastExecutedDate = 0;
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
|
-
exports.
|
|
10
|
+
exports.ActionStateBase = ActionStateBase;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskRecord.d.ts","sourceRoot":"","sources":["../../entities/taskRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,
|
|
1
|
+
{"version":3,"file":"taskRecord.d.ts","sourceRoot":"","sources":["../../entities/taskRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,qBAAa,UAAU;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC;IACvB,QAAQ,EAAE,YAAY,CAAC;gBAEX,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,OAAO,EAAE,QAAQ,EAAE,YAAY;CAK3E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TaskRecord = void 0;
|
|
3
4
|
class TaskRecord {
|
|
4
5
|
constructor(name, taskId, interval) {
|
|
5
6
|
this.name = name;
|
|
@@ -7,4 +8,4 @@ class TaskRecord {
|
|
|
7
8
|
this.interval = interval;
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
|
-
exports.
|
|
11
|
+
exports.TaskRecord = TaskRecord;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import CommandAction from '../../entities/actions/commandAction';
|
|
2
|
-
import ActionStateBase from '../../entities/states/actionStateBase';
|
|
3
|
-
import IActionState from '../../types/actionState';
|
|
4
1
|
import { CommandHandler } from '../../types/handlers';
|
|
5
2
|
import { CommandCondition } from '../../types/commandCondition';
|
|
6
3
|
import { Seconds } from '../../types/timeValues';
|
|
4
|
+
import { CommandAction } from '../../entities/actions/commandAction';
|
|
5
|
+
import { ActionStateBase } from '../../entities/states/actionStateBase';
|
|
6
|
+
import { IActionState } from '../../types/actionState';
|
|
7
7
|
export declare class CommandActionBuilderWithState<TActionState extends IActionState> {
|
|
8
8
|
name: string;
|
|
9
9
|
trigger: string | RegExp | Array<string> | Array<RegExp>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"commandActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/commandActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"commandActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/commandActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD,qBAAa,6BAA6B,CAAC,YAAY,SAAS,YAAY;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAM;IAE9D,MAAM,UAAQ;IACd,eAAe,EAAE,OAAO,CAAgB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAM;IACzB,YAAY,EAAE,MAAM,EAAE,CAAM;IAC5B,gBAAgB,EAAE,MAAM,YAAY,CAAC;IACrC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAa;IAClD,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAa;gBAE1C,IAAI,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,YAAY;IAK9D,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC;IAM3D,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAM/B,EAAE,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC;IAMxC,IAAI,CAAC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC;IAM9C,QAAQ;IAMR,QAAQ,CAAC,OAAO,EAAE,OAAO;IAMzB,UAAU,CAAC,MAAM,EAAE,MAAM;IAMzB,KAAK;CAaR;AAED,qBAAa,oBAAqB,SAAQ,6BAA6B,CAAC,eAAe,CAAC;gBACxE,IAAI,EAAE,MAAM;CAG3B"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CommandActionBuilder = exports.CommandActionBuilderWithState = void 0;
|
|
7
|
-
const commandAction_1 =
|
|
8
|
-
const actionStateBase_1 =
|
|
9
|
-
const toArray_1 =
|
|
10
|
-
const noop_1 =
|
|
4
|
+
const commandAction_1 = require("../../entities/actions/commandAction");
|
|
5
|
+
const actionStateBase_1 = require("../../entities/states/actionStateBase");
|
|
6
|
+
const toArray_1 = require("../toArray");
|
|
7
|
+
const noop_1 = require("../noop");
|
|
11
8
|
class CommandActionBuilderWithState {
|
|
12
9
|
constructor(name, stateConstructor) {
|
|
13
10
|
this.trigger = [];
|
|
@@ -15,8 +12,8 @@ class CommandActionBuilderWithState {
|
|
|
15
12
|
this.cooldownSeconds = 0;
|
|
16
13
|
this.blacklist = [];
|
|
17
14
|
this.allowedUsers = [];
|
|
18
|
-
this.handler = noop_1.
|
|
19
|
-
this.condition = noop_1.
|
|
15
|
+
this.handler = noop_1.Noop.call;
|
|
16
|
+
this.condition = noop_1.Noop.true;
|
|
20
17
|
this.name = name;
|
|
21
18
|
this.stateConstructor = stateConstructor;
|
|
22
19
|
}
|
|
@@ -25,7 +22,7 @@ class CommandActionBuilderWithState {
|
|
|
25
22
|
return this;
|
|
26
23
|
}
|
|
27
24
|
from(id) {
|
|
28
|
-
this.allowedUsers = (0, toArray_1.
|
|
25
|
+
this.allowedUsers = (0, toArray_1.toArray)(id);
|
|
29
26
|
return this;
|
|
30
27
|
}
|
|
31
28
|
do(handler) {
|
|
@@ -49,13 +46,13 @@ class CommandActionBuilderWithState {
|
|
|
49
46
|
return this;
|
|
50
47
|
}
|
|
51
48
|
build() {
|
|
52
|
-
return new commandAction_1.
|
|
49
|
+
return new commandAction_1.CommandAction(this.trigger, this.handler, this.name, this.active, this.cooldownSeconds, this.blacklist, this.allowedUsers, this.condition, this.stateConstructor);
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
exports.CommandActionBuilderWithState = CommandActionBuilderWithState;
|
|
56
53
|
class CommandActionBuilder extends CommandActionBuilderWithState {
|
|
57
54
|
constructor(name) {
|
|
58
|
-
super(name, () => new actionStateBase_1.
|
|
55
|
+
super(name, () => new actionStateBase_1.ActionStateBase());
|
|
59
56
|
}
|
|
60
57
|
}
|
|
61
58
|
exports.CommandActionBuilder = CommandActionBuilder;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import ScheduledAction from '../../entities/actions/scheduledAction';
|
|
2
|
-
import CachedStateFactory from '../../entities/cachedStateFactory';
|
|
1
|
+
import { ScheduledAction } from '../../entities/actions/scheduledAction';
|
|
2
|
+
import { CachedStateFactory } from '../../entities/cachedStateFactory';
|
|
3
3
|
import { ScheduledHandler } from '../../types/handlers';
|
|
4
4
|
import { Hours, HoursOfDay } from '../../types/timeValues';
|
|
5
|
-
export
|
|
5
|
+
export declare class ScheduledActionBuilder {
|
|
6
6
|
active: boolean;
|
|
7
7
|
time: HoursOfDay;
|
|
8
8
|
cachedStateFactories: Map<string, CachedStateFactory>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduledActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/scheduledActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"scheduledActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/scheduledActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAG3D,qBAAa,sBAAsB;IAC/B,MAAM,UAAQ;IACd,IAAI,EAAE,UAAU,CAAK;IACrB,oBAAoB,kCAAyC;IAC7D,SAAS,EAAE,MAAM,EAAE,CAAM;IACzB,OAAO,EAAE,gBAAgB,CAAa;IAEtC,IAAI,EAAE,MAAM,CAAC;gBAED,IAAI,EAAE,MAAM;IAIxB,OAAO,CAAC,MAAM,EAAE,MAAM;IAMtB,KAAK,CAAC,IAAI,EAAE,UAAU;IAMtB,EAAE,CAAC,OAAO,EAAE,gBAAgB;IAM5B,eAAe,CACX,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EACnC,0BAA0B,GAAE,KAAmB;IAUnD,QAAQ;IAMR,KAAK;CAUR"}
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
3
|
+
exports.ScheduledActionBuilder = void 0;
|
|
4
|
+
const scheduledAction_1 = require("../../entities/actions/scheduledAction");
|
|
5
|
+
const cachedStateFactory_1 = require("../../entities/cachedStateFactory");
|
|
6
|
+
const noop_1 = require("../noop");
|
|
9
7
|
class ScheduledActionBuilder {
|
|
10
8
|
constructor(name) {
|
|
11
9
|
this.active = true;
|
|
12
10
|
this.time = 0;
|
|
13
11
|
this.cachedStateFactories = new Map();
|
|
14
12
|
this.whitelist = [];
|
|
15
|
-
this.handler = noop_1.
|
|
13
|
+
this.handler = noop_1.Noop.call;
|
|
16
14
|
this.name = name;
|
|
17
15
|
}
|
|
18
16
|
allowIn(chatId) {
|
|
@@ -28,7 +26,7 @@ class ScheduledActionBuilder {
|
|
|
28
26
|
return this;
|
|
29
27
|
}
|
|
30
28
|
withSharedCache(key, itemFactory, invalidationTimeoutInHours = 20) {
|
|
31
|
-
this.cachedStateFactories.set(key, new cachedStateFactory_1.
|
|
29
|
+
this.cachedStateFactories.set(key, new cachedStateFactory_1.CachedStateFactory(itemFactory, invalidationTimeoutInHours));
|
|
32
30
|
return this;
|
|
33
31
|
}
|
|
34
32
|
disabled() {
|
|
@@ -36,7 +34,7 @@ class ScheduledActionBuilder {
|
|
|
36
34
|
return this;
|
|
37
35
|
}
|
|
38
36
|
build() {
|
|
39
|
-
return new scheduledAction_1.
|
|
37
|
+
return new scheduledAction_1.ScheduledAction(this.name, this.handler, this.time, this.active, this.whitelist, this.cachedStateFactories);
|
|
40
38
|
}
|
|
41
39
|
}
|
|
42
|
-
exports.
|
|
40
|
+
exports.ScheduledActionBuilder = ScheduledActionBuilder;
|
package/dist/helpers/noop.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
declare class Noop {
|
|
1
|
+
export declare class Noop {
|
|
2
2
|
static true<T1>(arg1: T1): Promise<boolean>;
|
|
3
3
|
static false<T1>(arg1: T1): Promise<boolean>;
|
|
4
4
|
static call<T1, T2>(arg1: T1, arg2: T2): Promise<void>;
|
|
5
5
|
}
|
|
6
|
-
export default Noop;
|
|
7
6
|
//# sourceMappingURL=noop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AACA,
|
|
1
|
+
{"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AACA,qBAAa,IAAI;WACA,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;WAGjB,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;WAGlB,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAE/D"}
|
package/dist/helpers/noop.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Noop = void 0;
|
|
3
4
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
5
|
class Noop {
|
|
5
6
|
static async true(arg1) {
|
|
@@ -10,4 +11,4 @@ class Noop {
|
|
|
10
11
|
}
|
|
11
12
|
static async call(arg1) { }
|
|
12
13
|
}
|
|
13
|
-
exports.
|
|
14
|
+
exports.Noop = Noop;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function toArray<TType>(value: TType | TType[]): TType[];
|
|
2
2
|
//# sourceMappingURL=toArray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toArray.d.ts","sourceRoot":"","sources":["../../helpers/toArray.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"toArray.d.ts","sourceRoot":"","sources":["../../helpers/toArray.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,EAAE,WAEpD"}
|
package/dist/helpers/toArray.js
CHANGED
package/dist/main.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import CommandAction from './entities/actions/commandAction
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
1
|
+
import { IStorageClient } from './types/storage';
|
|
2
|
+
import { CommandAction } from './entities/actions/commandAction';
|
|
3
|
+
import { ScheduledAction } from './entities/actions/scheduledAction';
|
|
4
|
+
import { IActionState } from './types/actionState';
|
|
5
|
+
import { BotInstance } from './entities/botInstance';
|
|
6
6
|
declare function startBot(options: {
|
|
7
7
|
name: string;
|
|
8
8
|
tokenFilePath: string;
|
package/dist/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../main.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAQrD,iBAAe,QAAQ,CAAC,OAAO,EAAE;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,aAAa,CAAC,YAAY,CAAC,EAAE,CAAC;IACxC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3B,aAAa,CAAC,EAAE,cAAc,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,wBAcA;AAED,iBAAe,QAAQ,CAAC,MAAM,EAAE,MAAM,iBASrC;AAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/main.js
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.startBot = startBot;
|
|
7
4
|
exports.stopBots = stopBots;
|
|
8
5
|
const promises_1 = require("fs/promises");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
6
|
+
const logger_1 = require("./services/logger");
|
|
7
|
+
const taskScheduler_1 = require("./services/taskScheduler");
|
|
8
|
+
const botInstance_1 = require("./entities/botInstance");
|
|
12
9
|
const bots = [];
|
|
13
10
|
function log(text) {
|
|
14
|
-
|
|
11
|
+
logger_1.Logger.logWithTraceId('ALL BOTS', 'System:Bot', 'System', text);
|
|
15
12
|
}
|
|
16
13
|
async function startBot(options) {
|
|
17
14
|
const token = await (0, promises_1.readFile)(options.tokenFilePath, 'utf8');
|
|
18
|
-
const bot = new
|
|
15
|
+
const bot = new botInstance_1.BotInstance({
|
|
19
16
|
name: options.name,
|
|
20
17
|
token,
|
|
21
18
|
commands: options.commands,
|
|
@@ -29,7 +26,7 @@ async function startBot(options) {
|
|
|
29
26
|
}
|
|
30
27
|
async function stopBots(reason) {
|
|
31
28
|
log(`Recieved termination code: ${reason}`);
|
|
32
|
-
|
|
29
|
+
taskScheduler_1.Scheduler.stopAll();
|
|
33
30
|
log('Acquiring storage semaphore...');
|
|
34
31
|
log('Stopping bots...');
|
|
35
32
|
for (const bot of bots) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import TransactionResult from '../entities/transactionResult';
|
|
2
|
-
import IActionState from '../types/actionState';
|
|
3
|
-
import IActionWithState from '../types/actionWithState';
|
|
4
1
|
import { Sema as Semaphore } from 'async-sema';
|
|
5
2
|
import { IStorageClient } from '../types/storage';
|
|
6
|
-
|
|
3
|
+
import { ActionExecutionResult } from '../entities/actionExecutionResult';
|
|
4
|
+
import { IActionState } from '../types/actionState';
|
|
5
|
+
import { IActionWithState } from '../types/actionWithState';
|
|
6
|
+
export declare class JsonFileStorage implements IStorageClient {
|
|
7
7
|
semaphore: Semaphore;
|
|
8
8
|
private cache;
|
|
9
9
|
private storagePath;
|
|
@@ -16,7 +16,8 @@ export default class JsonFileStorage implements IStorageClient {
|
|
|
16
16
|
load<TActionState extends IActionState>(key: string): Promise<Record<number, TActionState>>;
|
|
17
17
|
saveMetadata(actions: IActionWithState[], botName: string): Promise<void>;
|
|
18
18
|
getActionState<TActionState extends IActionState>(entity: IActionWithState, chatId: number): Promise<TActionState>;
|
|
19
|
-
saveActionExecutionResult(action: IActionWithState, chatId: number, transactionResult:
|
|
19
|
+
saveActionExecutionResult(action: IActionWithState, chatId: number, transactionResult: ActionExecutionResult): Promise<void>;
|
|
20
20
|
close(): Promise<void>;
|
|
21
|
+
updateStateFor<TActionState extends IActionState>(sourceActionKey: string, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
|
|
21
22
|
}
|
|
22
23
|
//# sourceMappingURL=jsonFileStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D,qBAAa,eAAgB,YAAW,cAAc;IAClD,SAAS,YAAoB;IAC7B,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;YAY5B,IAAI;YAUJ,YAAY;YAmBZ,IAAI;IAalB,OAAO,CAAC,eAAe;IAOjB,IAAI,CAAC,YAAY,SAAS,YAAY,EAAE,GAAG,EAAE,MAAM;IAMnD,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM;IAUzD,cAAc,CAAC,YAAY,SAAS,YAAY,EAClD,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM;IASZ,yBAAyB,CAC3B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,qBAAqB;IAYtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAItB,cAAc,CAAC,YAAY,SAAS,YAAY,EAClD,eAAe,EAAE,MAAM,EACvB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC;CAWrD"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JsonFileStorage = void 0;
|
|
3
4
|
const fs_1 = require("fs");
|
|
4
5
|
const path_1 = require("path");
|
|
5
6
|
const promises_1 = require("fs/promises");
|
|
@@ -82,5 +83,13 @@ class JsonFileStorage {
|
|
|
82
83
|
async close() {
|
|
83
84
|
await this.semaphore.acquire();
|
|
84
85
|
}
|
|
86
|
+
async updateStateFor(sourceActionKey, chatId, update) {
|
|
87
|
+
await this.lock(async () => {
|
|
88
|
+
const data = await this.loadInternal(sourceActionKey);
|
|
89
|
+
const state = data[chatId];
|
|
90
|
+
await update(state);
|
|
91
|
+
await this.save(data, sourceActionKey);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
85
94
|
}
|
|
86
|
-
exports.
|
|
95
|
+
exports.JsonFileStorage = JsonFileStorage;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
declare class
|
|
1
|
+
declare class JsonLogger {
|
|
2
2
|
logWithTraceId(botName: string, traceId: string | number, chatName: string, text: string): void;
|
|
3
3
|
errorWithTraceId<TData>(botName: string, traceId: string | number, chatName: string, errorObj: string | Error, extraData?: TData | undefined): void;
|
|
4
4
|
}
|
|
5
|
-
declare const
|
|
6
|
-
export
|
|
5
|
+
export declare const Logger: JsonLogger;
|
|
6
|
+
export {};
|
|
7
7
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../services/logger.ts"],"names":[],"mappings":"AAAA,cAAM,
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../services/logger.ts"],"names":[],"mappings":"AAAA,cAAM,UAAU;IACZ,cAAc,CACV,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM;IAKhB,gBAAgB,CAAC,KAAK,EAClB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GAAG,KAAK,EACxB,SAAS,CAAC,EAAE,KAAK,GAAG,SAAS;CAYpC;AAED,eAAO,MAAM,MAAM,YAAmB,CAAC"}
|
package/dist/services/logger.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
3
|
+
exports.Logger = void 0;
|
|
4
|
+
class JsonLogger {
|
|
4
5
|
logWithTraceId(botName, traceId, chatName, text) {
|
|
5
6
|
console.log(JSON.stringify({ botName, traceId, chatName, text }));
|
|
6
7
|
}
|
|
@@ -14,4 +15,4 @@ class Logger {
|
|
|
14
15
|
}));
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
|
-
exports.
|
|
18
|
+
exports.Logger = new JsonLogger();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import TaskRecord from '../entities/taskRecord';
|
|
1
|
+
import { TaskRecord } from '../entities/taskRecord';
|
|
2
2
|
import { Milliseconds } from '../types/timeValues';
|
|
3
3
|
declare class TaskScheduler {
|
|
4
4
|
activeTasks: TaskRecord[];
|
|
@@ -6,6 +6,6 @@ declare class TaskScheduler {
|
|
|
6
6
|
createTask(name: string, action: () => void, interval: Milliseconds, executeRightAway: boolean, ownerName: string): void;
|
|
7
7
|
createOnetimeTask(name: string, action: () => void, delay: Milliseconds, ownerName: string): void;
|
|
8
8
|
}
|
|
9
|
-
declare const
|
|
10
|
-
export
|
|
9
|
+
export declare const Scheduler: TaskScheduler;
|
|
10
|
+
export {};
|
|
11
11
|
//# sourceMappingURL=taskScheduler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taskScheduler.d.ts","sourceRoot":"","sources":["../../services/taskScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"taskScheduler.d.ts","sourceRoot":"","sources":["../../services/taskScheduler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,YAAY,EAAW,MAAM,qBAAqB,CAAC;AAG5D,cAAM,aAAa;IACf,WAAW,EAAE,UAAU,EAAE,CAAM;IAE/B,OAAO;IAMP,UAAU,CACN,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,IAAI,EAClB,QAAQ,EAAE,YAAY,EACtB,gBAAgB,EAAE,OAAO,EACzB,SAAS,EAAE,MAAM;IAoBrB,iBAAiB,CACb,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,IAAI,EAClB,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM;CAoBxB;AAED,eAAO,MAAM,SAAS,eAAsB,CAAC"}
|