chz-telegram-bot 0.0.49 → 0.0.51

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.
Files changed (87) hide show
  1. package/dist/dtos/actionExecutionResult.d.ts +7 -0
  2. package/dist/dtos/actionExecutionResult.d.ts.map +1 -0
  3. package/dist/dtos/actionExecutionResult.js +10 -0
  4. package/dist/dtos/chatInfo.d.ts +8 -0
  5. package/dist/dtos/chatInfo.d.ts.map +1 -0
  6. package/dist/dtos/chatInfo.js +10 -0
  7. package/dist/dtos/commandTriggerCheckResult.d.ts +10 -0
  8. package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -0
  9. package/dist/dtos/commandTriggerCheckResult.js +23 -0
  10. package/dist/dtos/incomingMessage.d.ts +14 -0
  11. package/dist/dtos/incomingMessage.d.ts.map +1 -0
  12. package/dist/dtos/incomingMessage.js +44 -0
  13. package/dist/dtos/responses/delay.d.ts +14 -0
  14. package/dist/dtos/responses/delay.d.ts.map +1 -0
  15. package/dist/dtos/responses/delay.js +14 -0
  16. package/dist/dtos/responses/imageMessage.d.ts +18 -0
  17. package/dist/dtos/responses/imageMessage.d.ts.map +1 -0
  18. package/dist/dtos/responses/imageMessage.js +17 -0
  19. package/dist/dtos/responses/reaction.d.ts +15 -0
  20. package/dist/dtos/responses/reaction.d.ts.map +1 -0
  21. package/dist/dtos/responses/reaction.js +15 -0
  22. package/dist/dtos/responses/textMessage.d.ts +17 -0
  23. package/dist/dtos/responses/textMessage.d.ts.map +1 -0
  24. package/dist/dtos/responses/textMessage.js +17 -0
  25. package/dist/dtos/responses/unpin.d.ts +13 -0
  26. package/dist/dtos/responses/unpin.d.ts.map +1 -0
  27. package/dist/dtos/responses/unpin.js +14 -0
  28. package/dist/dtos/responses/videoMessage.d.ts +18 -0
  29. package/dist/dtos/responses/videoMessage.d.ts.map +1 -0
  30. package/dist/dtos/responses/videoMessage.js +17 -0
  31. package/dist/entities/actions/commandAction.d.ts +10 -10
  32. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  33. package/dist/entities/actions/commandAction.js +6 -6
  34. package/dist/entities/actions/scheduledAction.d.ts +10 -10
  35. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  36. package/dist/entities/actions/scheduledAction.js +5 -5
  37. package/dist/entities/botInstance.d.ts +7 -7
  38. package/dist/entities/botInstance.d.ts.map +1 -1
  39. package/dist/entities/botInstance.js +8 -7
  40. package/dist/entities/cachedStateFactory.d.ts +2 -2
  41. package/dist/entities/cachedStateFactory.d.ts.map +1 -1
  42. package/dist/entities/context/chatContext.d.ts +4 -5
  43. package/dist/entities/context/chatContext.d.ts.map +1 -1
  44. package/dist/entities/context/chatContext.js +12 -13
  45. package/dist/entities/context/messageContext.d.ts +1 -1
  46. package/dist/entities/context/messageContext.d.ts.map +1 -1
  47. package/dist/entities/context/messageContext.js +10 -10
  48. package/dist/entities/taskRecord.d.ts +3 -3
  49. package/dist/entities/taskRecord.d.ts.map +1 -1
  50. package/dist/services/jsonFileStorage.d.ts +5 -5
  51. package/dist/services/jsonFileStorage.d.ts.map +1 -1
  52. package/dist/services/taskScheduler.d.ts +1 -1
  53. package/dist/services/taskScheduler.d.ts.map +1 -1
  54. package/dist/services/telegramApi.d.ts +5 -14
  55. package/dist/services/telegramApi.d.ts.map +1 -1
  56. package/dist/services/telegramApi.js +11 -21
  57. package/dist/types/actionWithState.d.ts +2 -2
  58. package/dist/types/actionWithState.d.ts.map +1 -1
  59. package/dist/types/response.d.ts +15 -14
  60. package/dist/types/response.d.ts.map +1 -1
  61. package/dist/types/storage.d.ts +1 -1
  62. package/dist/types/storage.d.ts.map +1 -1
  63. package/{entities → dtos}/actionExecutionResult.ts +2 -2
  64. package/dtos/chatInfo.ts +11 -0
  65. package/{entities → dtos}/incomingMessage.ts +8 -7
  66. package/{entities → dtos}/responses/delay.ts +8 -7
  67. package/{entities → dtos}/responses/imageMessage.ts +11 -10
  68. package/{entities → dtos}/responses/reaction.ts +9 -8
  69. package/{entities → dtos}/responses/textMessage.ts +11 -10
  70. package/{entities → dtos}/responses/unpin.ts +8 -7
  71. package/{entities → dtos}/responses/videoMessage.ts +11 -10
  72. package/entities/actions/commandAction.ts +18 -17
  73. package/entities/actions/scheduledAction.ts +16 -16
  74. package/entities/botInstance.ts +26 -15
  75. package/entities/cachedStateFactory.ts +2 -2
  76. package/entities/context/chatContext.ts +20 -18
  77. package/entities/context/messageContext.ts +11 -12
  78. package/entities/taskRecord.ts +3 -3
  79. package/package.json +1 -1
  80. package/services/jsonFileStorage.ts +5 -5
  81. package/services/taskScheduler.ts +1 -1
  82. package/services/telegramApi.ts +17 -65
  83. package/types/actionWithState.ts +2 -2
  84. package/types/response.ts +15 -14
  85. package/types/storage.ts +1 -1
  86. package/helpers/inverseRecord.ts +0 -7
  87. /package/{entities → dtos}/commandTriggerCheckResult.ts +0 -0
@@ -0,0 +1,7 @@
1
+ import { IActionState } from '../types/actionState';
2
+ export declare class ActionExecutionResult<TActionState extends IActionState> {
3
+ readonly data: TActionState;
4
+ readonly shouldUpdate: boolean;
5
+ constructor(data: TActionState, shouldUpdate: boolean);
6
+ }
7
+ //# sourceMappingURL=actionExecutionResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../dtos/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB,CAAC,YAAY,SAAS,YAAY;IAChE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;gBAEnB,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActionExecutionResult = void 0;
4
+ class ActionExecutionResult {
5
+ constructor(data, shouldUpdate) {
6
+ this.data = data;
7
+ this.shouldUpdate = shouldUpdate;
8
+ }
9
+ }
10
+ exports.ActionExecutionResult = ActionExecutionResult;
@@ -0,0 +1,8 @@
1
+ export declare class ChatInfo {
2
+ /** Id of a chat that action is executed in. */
3
+ readonly id: number;
4
+ /** Name of a chat that action is executed in. */
5
+ readonly name: string;
6
+ constructor(chatId: number, chatName: string);
7
+ }
8
+ //# sourceMappingURL=chatInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chatInfo.d.ts","sourceRoot":"","sources":["../../dtos/chatInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI/C"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatInfo = void 0;
4
+ class ChatInfo {
5
+ constructor(chatId, chatName) {
6
+ this.id = chatId;
7
+ this.name = chatName;
8
+ }
9
+ }
10
+ exports.ChatInfo = ChatInfo;
@@ -0,0 +1,10 @@
1
+ export declare class CommandTriggerCheckResult {
2
+ static get DontTriggerAndSkipCooldown(): CommandTriggerCheckResult;
3
+ static get DoNotTrigger(): CommandTriggerCheckResult;
4
+ shouldTrigger: boolean;
5
+ matchResults: RegExpExecArray[];
6
+ skipCooldown: boolean;
7
+ constructor(shouldTrigger: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean);
8
+ mergeWith(other: CommandTriggerCheckResult): this;
9
+ }
10
+ //# sourceMappingURL=commandTriggerCheckResult.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../dtos/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,qBAAa,yBAAyB;IAClC,MAAM,KAAK,0BAA0B,8BAEpC;IACD,MAAM,KAAK,YAAY,8BAEtB;IAED,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,eAAe,EAAE,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC;gBAGlB,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO;IAOzB,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAO7C"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommandTriggerCheckResult = void 0;
4
+ class CommandTriggerCheckResult {
5
+ static get DontTriggerAndSkipCooldown() {
6
+ return new CommandTriggerCheckResult(false, [], true);
7
+ }
8
+ static get DoNotTrigger() {
9
+ return new CommandTriggerCheckResult(false, [], false);
10
+ }
11
+ constructor(shouldTrigger, matchResults, skipCooldown) {
12
+ this.shouldTrigger = shouldTrigger;
13
+ this.matchResults = matchResults;
14
+ this.skipCooldown = skipCooldown;
15
+ }
16
+ mergeWith(other) {
17
+ this.shouldTrigger = this.shouldTrigger || other.shouldTrigger;
18
+ this.matchResults = this.matchResults.concat(other.matchResults);
19
+ this.skipCooldown = this.skipCooldown || other.skipCooldown;
20
+ return this;
21
+ }
22
+ }
23
+ exports.CommandTriggerCheckResult = CommandTriggerCheckResult;
@@ -0,0 +1,14 @@
1
+ import { Message, Update, User } from 'telegraf/types';
2
+ import { MessageTypeValue } from '../types/messageTypes';
3
+ import { ChatInfo } from './chatInfo';
4
+ export declare class IncomingMessage {
5
+ message_id: number;
6
+ chatInfo: ChatInfo;
7
+ from: User | undefined;
8
+ text: string;
9
+ type: MessageTypeValue;
10
+ traceId: number;
11
+ private detectMessageType;
12
+ constructor(ctxMessage: Update.New & (Update.NonChannel & Message));
13
+ }
14
+ //# sourceMappingURL=incomingMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../dtos/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEvD,OAAO,EAAe,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,eAAe;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,gBAAgB,CAAC;IACvB,OAAO,SAA2B;IAElC,OAAO,CAAC,iBAAiB;gBAkBb,UAAU,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC;CAYrE"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IncomingMessage = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const messageTypes_1 = require("../types/messageTypes");
6
+ const chatInfo_1 = require("./chatInfo");
7
+ class IncomingMessage {
8
+ detectMessageType(message) {
9
+ if ('text' in message)
10
+ return messageTypes_1.MessageType.Text;
11
+ if ('photo' in message)
12
+ return messageTypes_1.MessageType.Photo;
13
+ if ('sticker' in message)
14
+ return messageTypes_1.MessageType.Sticker;
15
+ if ('animation' in message)
16
+ return messageTypes_1.MessageType.Animation;
17
+ if ('voice' in message)
18
+ return messageTypes_1.MessageType.Voice;
19
+ if ('audio' in message)
20
+ return messageTypes_1.MessageType.Audio;
21
+ if ('document' in message)
22
+ return messageTypes_1.MessageType.Document;
23
+ if ('left_chat_member' in message)
24
+ return messageTypes_1.MessageType.LeftChatMember;
25
+ if ('new_chat_member' in message)
26
+ return messageTypes_1.MessageType.NewChatMember;
27
+ if ('poll' in message)
28
+ return messageTypes_1.MessageType.Poll;
29
+ if ('location' in message)
30
+ return messageTypes_1.MessageType.Location;
31
+ return messageTypes_1.MessageType.Unknown;
32
+ }
33
+ constructor(ctxMessage) {
34
+ this.traceId = (0, crypto_1.randomInt)(10000, 99999);
35
+ this.message_id = ctxMessage.message_id;
36
+ this.from = ctxMessage.from;
37
+ this.text = 'text' in ctxMessage ? ctxMessage.text : '';
38
+ this.chatInfo = new chatInfo_1.ChatInfo(ctxMessage.chat.id, 'title' in ctxMessage.chat
39
+ ? ctxMessage.chat.title + ' ' + ctxMessage.chat.id
40
+ : 'DM');
41
+ this.type = this.detectMessageType(ctxMessage);
42
+ }
43
+ }
44
+ exports.IncomingMessage = IncomingMessage;
@@ -0,0 +1,14 @@
1
+ import { IActionState } from '../../types/actionState';
2
+ import { IActionWithState } from '../../types/actionWithState';
3
+ import { IChatResponse } from '../../types/response';
4
+ import { Milliseconds } from '../../types/timeValues';
5
+ import { ChatInfo } from '../chatInfo';
6
+ export declare class DelayResponse implements IChatResponse {
7
+ readonly kind: "delay";
8
+ readonly chatInfo: ChatInfo;
9
+ readonly traceId: number | string;
10
+ readonly delay: Milliseconds;
11
+ readonly action: IActionWithState<IActionState>;
12
+ constructor(delay: Milliseconds, chatInfo: ChatInfo, traceId: number | string, action: IActionWithState<IActionState>);
13
+ }
14
+ //# sourceMappingURL=delay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../dtos/responses/delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;IAEvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelayResponse = void 0;
4
+ const response_1 = require("../../types/response");
5
+ class DelayResponse {
6
+ constructor(delay, chatInfo, traceId, action) {
7
+ this.kind = response_1.BotResponseTypes.delay;
8
+ this.chatInfo = chatInfo;
9
+ this.delay = delay;
10
+ this.traceId = traceId;
11
+ this.action = action;
12
+ }
13
+ }
14
+ exports.DelayResponse = DelayResponse;
@@ -0,0 +1,18 @@
1
+ import { InputFile } from 'telegraf/types';
2
+ import { IReplyMessage } from '../../types/response';
3
+ import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
+ import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
6
+ import { ChatInfo } from '../chatInfo';
7
+ export declare class ImageMessage implements IReplyMessage<InputFile> {
8
+ readonly kind: "image";
9
+ readonly content: InputFile;
10
+ readonly chatInfo: ChatInfo;
11
+ readonly replyId: number | undefined;
12
+ readonly traceId: string | number;
13
+ readonly disableWebPreview = false;
14
+ readonly shouldPin: boolean;
15
+ readonly action: IActionWithState<IActionState>;
16
+ constructor(image: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
+ }
18
+ //# sourceMappingURL=imageMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;IAEvC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ImageMessage = void 0;
4
+ const response_1 = require("../../types/response");
5
+ class ImageMessage {
6
+ constructor(image, chatInfo, replyId, traceId, action, options) {
7
+ this.kind = response_1.BotResponseTypes.image;
8
+ this.disableWebPreview = false;
9
+ this.content = image;
10
+ this.chatInfo = chatInfo;
11
+ this.replyId = replyId;
12
+ this.traceId = traceId;
13
+ this.shouldPin = options?.pin ?? false;
14
+ this.action = action;
15
+ }
16
+ }
17
+ exports.ImageMessage = ImageMessage;
@@ -0,0 +1,15 @@
1
+ import { TelegramEmoji } from 'telegraf/types';
2
+ import { IChatResponse } from '../../types/response';
3
+ import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
5
+ import { ChatInfo } from '../chatInfo';
6
+ export declare class Reaction implements IChatResponse {
7
+ readonly kind: "react";
8
+ readonly chatInfo: ChatInfo;
9
+ readonly messageId: number;
10
+ readonly traceId: number | string;
11
+ readonly emoji: TelegramEmoji;
12
+ readonly action: IActionWithState<IActionState>;
13
+ constructor(traceId: number | string, chatInfo: ChatInfo, messageId: number, emoji: TelegramEmoji, action: IActionWithState<IActionState>);
14
+ }
15
+ //# sourceMappingURL=reaction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../dtos/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,QAAS,YAAW,aAAa;IAC1C,QAAQ,CAAC,IAAI,UAA0B;IAEvC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAQ7C"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Reaction = void 0;
4
+ const response_1 = require("../../types/response");
5
+ class Reaction {
6
+ constructor(traceId, chatInfo, messageId, emoji, action) {
7
+ this.kind = response_1.BotResponseTypes.react;
8
+ this.chatInfo = chatInfo;
9
+ this.messageId = messageId;
10
+ this.emoji = emoji;
11
+ this.traceId = traceId;
12
+ this.action = action;
13
+ }
14
+ }
15
+ exports.Reaction = Reaction;
@@ -0,0 +1,17 @@
1
+ import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
2
+ import { IReplyMessage } from '../../types/response';
3
+ import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
5
+ import { ChatInfo } from '../chatInfo';
6
+ export declare class TextMessage implements IReplyMessage<string> {
7
+ readonly kind: "text";
8
+ readonly content: string;
9
+ readonly chatInfo: ChatInfo;
10
+ readonly replyId: number | undefined;
11
+ readonly traceId: string | number;
12
+ readonly disableWebPreview: boolean;
13
+ readonly shouldPin: boolean;
14
+ readonly action: IActionWithState<IActionState>;
15
+ constructor(text: string, chatInfo: ChatInfo, replyId: number | undefined, traceId: string | number, action: IActionWithState<IActionState>, options?: TextMessageSendingOptions);
16
+ }
17
+ //# sourceMappingURL=textMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,QAAQ,CAAC,IAAI,SAAyB;IAEtC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TextMessage = void 0;
4
+ const response_1 = require("../../types/response");
5
+ class TextMessage {
6
+ constructor(text, chatInfo, replyId, traceId, action, options) {
7
+ this.kind = response_1.BotResponseTypes.text;
8
+ this.content = text;
9
+ this.chatInfo = chatInfo;
10
+ this.replyId = replyId;
11
+ this.traceId = traceId;
12
+ this.disableWebPreview = options?.disableWebPreview ?? false;
13
+ this.shouldPin = options?.pin ?? false;
14
+ this.action = action;
15
+ }
16
+ }
17
+ exports.TextMessage = TextMessage;
@@ -0,0 +1,13 @@
1
+ import { IChatResponse } from '../../types/response';
2
+ import { IActionWithState } from '../../types/actionWithState';
3
+ import { IActionState } from '../../types/actionState';
4
+ import { ChatInfo } from '../chatInfo';
5
+ export declare class UnpinResponse implements IChatResponse {
6
+ readonly kind: "unpin";
7
+ readonly messageId: number;
8
+ readonly chatInfo: ChatInfo;
9
+ readonly traceId: number | string;
10
+ readonly action: IActionWithState<IActionState>;
11
+ constructor(messageId: number, chatInfo: ChatInfo, traceId: number | string, action: IActionWithState<IActionState>);
12
+ }
13
+ //# sourceMappingURL=unpin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../dtos/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;IAEvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
@@ -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, chatInfo, traceId, action) {
7
+ this.kind = response_1.BotResponseTypes.unpin;
8
+ this.messageId = messageId;
9
+ this.chatInfo = chatInfo;
10
+ this.traceId = traceId;
11
+ this.action = action;
12
+ }
13
+ }
14
+ exports.UnpinResponse = UnpinResponse;
@@ -0,0 +1,18 @@
1
+ import { InputFile } from 'telegraf/types';
2
+ import { IReplyMessage } from '../../types/response';
3
+ import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
+ import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
6
+ import { ChatInfo } from '../chatInfo';
7
+ export declare class VideoMessage implements IReplyMessage<InputFile> {
8
+ readonly kind: "video";
9
+ readonly content: InputFile;
10
+ readonly chatInfo: ChatInfo;
11
+ readonly replyId: number | undefined;
12
+ readonly traceId: string | number;
13
+ readonly disableWebPreview = false;
14
+ readonly shouldPin: boolean;
15
+ readonly action: IActionWithState<IActionState>;
16
+ constructor(video: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
+ }
18
+ //# sourceMappingURL=videoMessage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;IAEvC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAClC,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VideoMessage = void 0;
4
+ const response_1 = require("../../types/response");
5
+ class VideoMessage {
6
+ constructor(video, chatInfo, replyId, traceId, action, options) {
7
+ this.kind = response_1.BotResponseTypes.video;
8
+ this.disableWebPreview = false;
9
+ this.content = video;
10
+ this.chatInfo = chatInfo;
11
+ this.replyId = replyId;
12
+ this.traceId = traceId;
13
+ this.shouldPin = options?.pin ?? false;
14
+ this.action = action;
15
+ }
16
+ }
17
+ exports.VideoMessage = VideoMessage;
@@ -6,16 +6,16 @@ import { IActionWithState, ActionKey } from '../../types/actionWithState';
6
6
  import { MessageContext } from '../context/messageContext';
7
7
  import { CommandTrigger } from '../../types/commandTrigger';
8
8
  export declare class CommandAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
9
- triggers: CommandTrigger[];
10
- handler: CommandHandler<TActionState>;
11
- name: string;
12
- cooldownInSeconds: Seconds;
13
- active: boolean;
14
- chatsBlacklist: number[];
15
- allowedUsers: number[];
16
- condition: CommandCondition<TActionState>;
17
- stateConstructor: () => TActionState;
18
- key: ActionKey;
9
+ readonly triggers: CommandTrigger[];
10
+ readonly handler: CommandHandler<TActionState>;
11
+ readonly name: string;
12
+ readonly cooldownInSeconds: Seconds;
13
+ readonly active: boolean;
14
+ readonly chatsBlacklist: number[];
15
+ readonly allowedUsers: number[];
16
+ readonly condition: CommandCondition<TActionState>;
17
+ readonly stateConstructor: () => TActionState;
18
+ readonly key: ActionKey;
19
19
  constructor(trigger: CommandTrigger | CommandTrigger[], handler: CommandHandler<TActionState>, name: string, active: boolean, cooldown: Seconds, chatsBlacklist: number[], allowedUsers: number[], condition: CommandCondition<TActionState>, stateConstructor: () => TActionState);
20
20
  exec(ctx: MessageContext<TActionState>): Promise<import("../../types/response").BotResponse[]>;
21
21
  private checkTrigger;
@@ -1 +1 @@
1
- {"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAGjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE1E,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAG3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,qBAAa,aAAa,CAAC,YAAY,SAAS,YAAY,CACxD,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,OAAO,CAAC;IAC3B,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC1C,gBAAgB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AAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;gBAGpB,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,OAAO,EACjB,cAAc,EAAE,MAAM,EAAE,EACxB,YAAY,EAAE,MAAM,EAAE,EACtB,SAAS,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACzC,gBAAgB,EAAE,MAAM,YAAY;IAelC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;IA0D5C,OAAO,CAAC,YAAY;CAwDvB"}
@@ -7,9 +7,9 @@ exports.CommandAction = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const timeConvertions_1 = require("../../helpers/timeConvertions");
9
9
  const toArray_1 = require("../../helpers/toArray");
10
- const commandTriggerCheckResult_1 = require("../commandTriggerCheckResult");
10
+ const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResult");
11
11
  const logger_1 = require("../../services/logger");
12
- const actionExecutionResult_1 = require("../actionExecutionResult");
12
+ const actionExecutionResult_1 = require("../../dtos/actionExecutionResult");
13
13
  class CommandAction {
14
14
  constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor) {
15
15
  this.triggers = (0, toArray_1.toArray)(trigger);
@@ -26,18 +26,18 @@ class CommandAction {
26
26
  async exec(ctx) {
27
27
  if (!ctx.isInitialized)
28
28
  throw new Error(`Context for ${this.key} is not initialized or already consumed`);
29
- if (!this.active || this.chatsBlacklist.includes(ctx.chatId))
29
+ if (!this.active || this.chatsBlacklist.includes(ctx.chatInfo.id))
30
30
  return [];
31
31
  const isConditionMet = await this.condition(ctx);
32
32
  if (!isConditionMet)
33
33
  return [];
34
- const state = await ctx.storage.getActionState(this, ctx.chatId);
34
+ const state = await ctx.storage.getActionState(this, ctx.chatInfo.id);
35
35
  const { shouldTrigger, matchResults, skipCooldown } = this.triggers
36
36
  .map((x) => this.checkTrigger(ctx, x, state))
37
37
  .reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger);
38
38
  if (!shouldTrigger)
39
39
  return [];
40
- logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatName, ` - Executing [${this.name}] in ${ctx.chatId}`);
40
+ logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
41
41
  ctx.matchResults = matchResults;
42
42
  await this.handler(ctx, state);
43
43
  if (skipCooldown) {
@@ -47,7 +47,7 @@ class CommandAction {
47
47
  state.lastExecutedDate = (0, moment_1.default)().valueOf();
48
48
  }
49
49
  ctx.updateActions.forEach((action) => action(state));
50
- await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new actionExecutionResult_1.ActionExecutionResult(state, ctx.startCooldown && shouldTrigger));
50
+ await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, new actionExecutionResult_1.ActionExecutionResult(state, ctx.startCooldown && shouldTrigger));
51
51
  ctx.isInitialized = false;
52
52
  return ctx.responses;
53
53
  }
@@ -6,16 +6,16 @@ import { IActionWithState, ActionKey } from '../../types/actionWithState';
6
6
  import { CachedStateFactory } from '../cachedStateFactory';
7
7
  import { ChatContext } from '../context/chatContext';
8
8
  export declare class ScheduledAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
9
- static locks: Map<string, Semaphore>;
10
- name: string;
11
- timeinHours: HoursOfDay;
12
- active: boolean;
13
- chatsWhitelist: number[];
14
- key: ActionKey;
15
- cachedState: Map<string, unknown>;
16
- stateConstructor: () => TActionState;
17
- cachedStateFactories: Map<string, CachedStateFactory>;
18
- handler: ScheduledHandler<TActionState>;
9
+ static readonly locks: Map<string, Semaphore>;
10
+ readonly name: string;
11
+ readonly timeinHours: HoursOfDay;
12
+ readonly active: boolean;
13
+ readonly chatsWhitelist: number[];
14
+ readonly key: ActionKey;
15
+ readonly cachedState: Map<string, unknown>;
16
+ readonly stateConstructor: () => TActionState;
17
+ readonly cachedStateFactories: Map<string, CachedStateFactory>;
18
+ readonly handler: ScheduledHandler<TActionState>;
19
19
  constructor(name: string, handler: ScheduledHandler<TActionState>, timeinHours: HoursOfDay, active: boolean, whitelist: number[], cachedStateFactories: Map<string, CachedStateFactory>, stateConstructor: () => TActionState);
20
20
  exec(ctx: ChatContext<TActionState>): Promise<import("../../types/response").BotResponse[]>;
21
21
  private getCachedValue;
@@ -1 +1 @@
1
- {"version":3,"file":"scheduledAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/scheduledAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAKrD,qBAAa,eAAe,CAAC,YAAY,SAAS,YAAY,CAC1D,YAAW,gBAAgB,CAAC,YAAY,CAAC;IAEzC,MAAM,CAAC,KAAK,yBAAgC;IAE5C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,MAAM,E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E,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG7C,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACvC,WAAW,EAAE,UAAU,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,MAAM,EAAE,EACnB,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,EACrD,gBAAgB,EAAE,MAAM,YAAY;IAYlC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;YA6C3B,cAAc;IA8C5B,OAAO,CAAC,aAAa;CAaxB"}
@@ -7,7 +7,7 @@ exports.ScheduledAction = void 0;
7
7
  const moment_1 = __importDefault(require("moment"));
8
8
  const async_sema_1 = require("async-sema");
9
9
  const timeConvertions_1 = require("../../helpers/timeConvertions");
10
- const actionExecutionResult_1 = require("../actionExecutionResult");
10
+ const actionExecutionResult_1 = require("../../dtos/actionExecutionResult");
11
11
  const logger_1 = require("../../services/logger");
12
12
  const taskScheduler_1 = require("../../services/taskScheduler");
13
13
  class ScheduledAction {
@@ -25,16 +25,16 @@ class ScheduledAction {
25
25
  async exec(ctx) {
26
26
  if (!ctx.isInitialized)
27
27
  throw new Error(`Context for ${this.key} is not initialized or already consumed`);
28
- if (!this.active || !this.chatsWhitelist.includes(ctx.chatId))
28
+ if (!this.active || !this.chatsWhitelist.includes(ctx.chatInfo.id))
29
29
  return [];
30
- const state = await ctx.storage.getActionState(this, ctx.chatId);
30
+ const state = await ctx.storage.getActionState(this, ctx.chatInfo.id);
31
31
  const isAllowedToTrigger = this.shouldTrigger(state);
32
32
  if (isAllowedToTrigger) {
33
- logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatName, ` - Executing [${this.name}] in ${ctx.chatId}`);
33
+ logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
34
34
  await this.handler(ctx, (key) => this.getCachedValue(key, ctx.botName), state);
35
35
  state.lastExecutedDate = (0, moment_1.default)().valueOf();
36
36
  ctx.updateActions.forEach((action) => action(state));
37
- await ctx.storage.saveActionExecutionResult(this, ctx.chatId, new actionExecutionResult_1.ActionExecutionResult(state, isAllowedToTrigger));
37
+ await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, new actionExecutionResult_1.ActionExecutionResult(state, isAllowedToTrigger));
38
38
  }
39
39
  ctx.isInitialized = false;
40
40
  return ctx.responses;
@@ -4,13 +4,13 @@ import { IActionState } from '../types/actionState';
4
4
  import { CommandAction } from './actions/commandAction';
5
5
  import { ScheduledAction } from './actions/scheduledAction';
6
6
  export declare class BotInstance {
7
- name: string;
8
- private api;
9
- private telegraf;
10
- private commands;
11
- private scheduled;
12
- private chats;
13
- storage: IStorageClient;
7
+ readonly name: string;
8
+ private readonly api;
9
+ private readonly telegraf;
10
+ private readonly commands;
11
+ private readonly scheduled;
12
+ private readonly chats;
13
+ readonly storage: IStorageClient;
14
14
  constructor(options: {
15
15
  name: string;
16
16
  token: string;
@@ -1 +1 @@
1
- {"version":3,"file":"botInstance.d.ts","sourceRoot":"","sources":["../../entities/botInstance.ts"],"names":[],"mappings":"AAKA,OAAO,EAAuB,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAA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