chz-telegram-bot 0.0.51 → 0.0.53

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 (100) hide show
  1. package/dist/dtos/commandTriggerCheckResult.d.ts +5 -5
  2. package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -1
  3. package/dist/dtos/commandTriggerCheckResult.js +3 -6
  4. package/dist/dtos/incomingMessage.d.ts +8 -7
  5. package/dist/dtos/incomingMessage.d.ts.map +1 -1
  6. package/dist/dtos/incomingMessage.js +3 -2
  7. package/dist/dtos/responses/delay.d.ts +3 -2
  8. package/dist/dtos/responses/delay.d.ts.map +1 -1
  9. package/dist/dtos/responses/imageMessage.d.ts +3 -2
  10. package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
  11. package/dist/dtos/responses/reaction.d.ts +3 -2
  12. package/dist/dtos/responses/reaction.d.ts.map +1 -1
  13. package/dist/dtos/responses/textMessage.d.ts +3 -2
  14. package/dist/dtos/responses/textMessage.d.ts.map +1 -1
  15. package/dist/dtos/responses/unpin.d.ts +3 -2
  16. package/dist/dtos/responses/unpin.d.ts.map +1 -1
  17. package/dist/dtos/responses/videoMessage.d.ts +3 -2
  18. package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
  19. package/dist/entities/actions/commandAction.d.ts +1 -0
  20. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  21. package/dist/entities/actions/commandAction.js +38 -37
  22. package/dist/entities/actions/scheduledAction.d.ts +1 -1
  23. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  24. package/dist/entities/actions/scheduledAction.js +12 -16
  25. package/dist/entities/botInstance.d.ts +11 -3
  26. package/dist/entities/botInstance.d.ts.map +1 -1
  27. package/dist/entities/botInstance.js +26 -18
  28. package/dist/entities/context/chatContext.d.ts +12 -11
  29. package/dist/entities/context/chatContext.d.ts.map +1 -1
  30. package/dist/entities/context/chatContext.js +5 -12
  31. package/dist/entities/context/messageContext.d.ts +4 -2
  32. package/dist/entities/context/messageContext.d.ts.map +1 -1
  33. package/dist/entities/context/messageContext.js +4 -4
  34. package/dist/helpers/noop.d.ts +4 -2
  35. package/dist/helpers/noop.d.ts.map +1 -1
  36. package/dist/helpers/noop.js +3 -2
  37. package/dist/helpers/traceFactory.d.ts +3 -0
  38. package/dist/helpers/traceFactory.d.ts.map +1 -0
  39. package/dist/helpers/traceFactory.js +6 -0
  40. package/dist/index.d.ts +4 -1
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/main.d.ts +10 -2
  43. package/dist/main.d.ts.map +1 -1
  44. package/dist/main.js +6 -11
  45. package/dist/services/jsonFileStorage.d.ts +1 -2
  46. package/dist/services/jsonFileStorage.d.ts.map +1 -1
  47. package/dist/services/jsonFileStorage.js +3 -5
  48. package/dist/services/jsonLogger.d.ts +9 -0
  49. package/dist/services/jsonLogger.d.ts.map +1 -0
  50. package/dist/services/jsonLogger.js +28 -0
  51. package/dist/services/nodeTimeoutScheduler.d.ts +13 -0
  52. package/dist/services/nodeTimeoutScheduler.d.ts.map +1 -0
  53. package/dist/services/nodeTimeoutScheduler.js +34 -0
  54. package/dist/services/telegramApi.d.ts +7 -5
  55. package/dist/services/telegramApi.d.ts.map +1 -1
  56. package/dist/services/telegramApi.js +4 -4
  57. package/dist/types/commandCondition.d.ts +1 -1
  58. package/dist/types/commandCondition.d.ts.map +1 -1
  59. package/dist/types/logger.d.ts +7 -0
  60. package/dist/types/logger.d.ts.map +1 -0
  61. package/dist/types/logger.js +2 -0
  62. package/dist/types/response.d.ts +2 -1
  63. package/dist/types/response.d.ts.map +1 -1
  64. package/dist/types/scheduler.d.ts +7 -0
  65. package/dist/types/scheduler.d.ts.map +1 -0
  66. package/dist/types/scheduler.js +2 -0
  67. package/dist/types/storage.d.ts +1 -2
  68. package/dist/types/storage.d.ts.map +1 -1
  69. package/dist/types/trace.d.ts +2 -0
  70. package/dist/types/trace.d.ts.map +1 -0
  71. package/dist/types/trace.js +2 -0
  72. package/dtos/commandTriggerCheckResult.ts +10 -10
  73. package/dtos/incomingMessage.ts +17 -7
  74. package/dtos/responses/delay.ts +3 -2
  75. package/dtos/responses/imageMessage.ts +3 -2
  76. package/dtos/responses/reaction.ts +3 -2
  77. package/dtos/responses/textMessage.ts +3 -2
  78. package/dtos/responses/unpin.ts +3 -2
  79. package/dtos/responses/videoMessage.ts +3 -2
  80. package/entities/actions/commandAction.ts +48 -41
  81. package/entities/actions/scheduledAction.ts +28 -31
  82. package/entities/botInstance.ts +57 -34
  83. package/entities/context/chatContext.ts +22 -17
  84. package/entities/context/messageContext.ts +10 -6
  85. package/helpers/noop.ts +5 -2
  86. package/helpers/traceFactory.ts +9 -0
  87. package/index.ts +4 -1
  88. package/main.ts +16 -15
  89. package/package.json +1 -1
  90. package/services/jsonFileStorage.ts +4 -6
  91. package/services/{logger.ts → jsonLogger.ts} +7 -6
  92. package/services/{taskScheduler.ts → nodeTimeoutScheduler.ts} +15 -10
  93. package/services/telegramApi.ts +15 -8
  94. package/types/commandCondition.ts +1 -1
  95. package/types/logger.ts +26 -0
  96. package/types/response.ts +2 -1
  97. package/types/scheduler.ts +20 -0
  98. package/types/storage.ts +1 -2
  99. package/types/trace.ts +1 -0
  100. package/dtos/actionExecutionResult.ts +0 -11
@@ -1,10 +1,10 @@
1
1
  export declare class CommandTriggerCheckResult {
2
2
  static get DontTriggerAndSkipCooldown(): CommandTriggerCheckResult;
3
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;
4
+ readonly shouldExecute: boolean;
5
+ readonly matchResults: RegExpExecArray[];
6
+ readonly skipCooldown: boolean;
7
+ constructor(shouldExecute: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean);
8
+ mergeWith(other: CommandTriggerCheckResult): CommandTriggerCheckResult;
9
9
  }
10
10
  //# sourceMappingURL=commandTriggerCheckResult.d.ts.map
@@ -1 +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"}
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,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;gBAG3B,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO;IAOzB,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAO7C"}
@@ -8,16 +8,13 @@ class CommandTriggerCheckResult {
8
8
  static get DoNotTrigger() {
9
9
  return new CommandTriggerCheckResult(false, [], false);
10
10
  }
11
- constructor(shouldTrigger, matchResults, skipCooldown) {
12
- this.shouldTrigger = shouldTrigger;
11
+ constructor(shouldExecute, matchResults, skipCooldown) {
12
+ this.shouldExecute = shouldExecute;
13
13
  this.matchResults = matchResults;
14
14
  this.skipCooldown = skipCooldown;
15
15
  }
16
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;
17
+ return new CommandTriggerCheckResult(this.shouldExecute || other.shouldExecute, this.matchResults.concat(other.matchResults), this.skipCooldown || other.skipCooldown);
21
18
  }
22
19
  }
23
20
  exports.CommandTriggerCheckResult = CommandTriggerCheckResult;
@@ -1,14 +1,15 @@
1
1
  import { Message, Update, User } from 'telegraf/types';
2
2
  import { MessageTypeValue } from '../types/messageTypes';
3
3
  import { ChatInfo } from './chatInfo';
4
+ import { TraceId } from '../types/trace';
4
5
  export declare class IncomingMessage {
5
- message_id: number;
6
- chatInfo: ChatInfo;
7
- from: User | undefined;
8
- text: string;
9
- type: MessageTypeValue;
10
- traceId: number;
6
+ readonly message_id: number;
7
+ readonly chatInfo: ChatInfo;
8
+ readonly from: User | undefined;
9
+ readonly text: string;
10
+ readonly type: MessageTypeValue;
11
+ readonly traceId: TraceId;
11
12
  private detectMessageType;
12
- constructor(ctxMessage: Update.New & (Update.NonChannel & Message));
13
+ constructor(ctxMessage: Update.New & (Update.NonChannel & Message), botName: string);
13
14
  }
14
15
  //# sourceMappingURL=incomingMessage.d.ts.map
@@ -1 +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"}
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,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,eAAe;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,SAAS,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAE1B,OAAO,CAAC,iBAAiB;gBAmBrB,UAAU,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,GAAG,OAAO,CAAC,EACtD,OAAO,EAAE,MAAM;CAkBtB"}
@@ -4,6 +4,7 @@ exports.IncomingMessage = void 0;
4
4
  const crypto_1 = require("crypto");
5
5
  const messageTypes_1 = require("../types/messageTypes");
6
6
  const chatInfo_1 = require("./chatInfo");
7
+ const traceFactory_1 = require("../helpers/traceFactory");
7
8
  class IncomingMessage {
8
9
  detectMessageType(message) {
9
10
  if ('text' in message)
@@ -30,8 +31,8 @@ class IncomingMessage {
30
31
  return messageTypes_1.MessageType.Location;
31
32
  return messageTypes_1.MessageType.Unknown;
32
33
  }
33
- constructor(ctxMessage) {
34
- this.traceId = (0, crypto_1.randomInt)(10000, 99999);
34
+ constructor(ctxMessage, botName) {
35
+ this.traceId = (0, traceFactory_1.createTrace)(this, botName, (0, crypto_1.randomInt)(10000, 99999).toString());
35
36
  this.message_id = ctxMessage.message_id;
36
37
  this.from = ctxMessage.from;
37
38
  this.text = 'text' in ctxMessage ? ctxMessage.text : '';
@@ -2,13 +2,14 @@ import { IActionState } from '../../types/actionState';
2
2
  import { IActionWithState } from '../../types/actionWithState';
3
3
  import { IChatResponse } from '../../types/response';
4
4
  import { Milliseconds } from '../../types/timeValues';
5
+ import { TraceId } from '../../types/trace';
5
6
  import { ChatInfo } from '../chatInfo';
6
7
  export declare class DelayResponse implements IChatResponse {
7
8
  readonly kind: "delay";
8
9
  readonly chatInfo: ChatInfo;
9
- readonly traceId: number | string;
10
+ readonly traceId: TraceId;
10
11
  readonly delay: Milliseconds;
11
12
  readonly action: IActionWithState<IActionState>;
12
- constructor(delay: Milliseconds, chatInfo: ChatInfo, traceId: number | string, action: IActionWithState<IActionState>);
13
+ constructor(delay: Milliseconds, chatInfo: ChatInfo, traceId: TraceId, action: IActionWithState<IActionState>);
13
14
  }
14
15
  //# sourceMappingURL=delay.d.ts.map
@@ -1 +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"}
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,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,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,OAAO,CAAC;IAC1B,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,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
@@ -4,15 +4,16 @@ import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
5
  import { IActionState } from '../../types/actionState';
6
6
  import { ChatInfo } from '../chatInfo';
7
+ import { TraceId } from '../../types/trace';
7
8
  export declare class ImageMessage implements IReplyMessage<InputFile> {
8
9
  readonly kind: "image";
9
10
  readonly content: InputFile;
10
11
  readonly chatInfo: ChatInfo;
11
12
  readonly replyId: number | undefined;
12
- readonly traceId: string | number;
13
+ readonly traceId: TraceId;
13
14
  readonly disableWebPreview = false;
14
15
  readonly shouldPin: boolean;
15
16
  readonly action: IActionWithState<IActionState>;
16
- constructor(image: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
+ constructor(image: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: TraceId, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
18
  }
18
19
  //# sourceMappingURL=imageMessage.d.ts.map
@@ -1 +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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E,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
@@ -3,13 +3,14 @@ import { IChatResponse } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
4
  import { IActionState } from '../../types/actionState';
5
5
  import { ChatInfo } from '../chatInfo';
6
+ import { TraceId } from '../../types/trace';
6
7
  export declare class Reaction implements IChatResponse {
7
8
  readonly kind: "react";
8
9
  readonly chatInfo: ChatInfo;
9
10
  readonly messageId: number;
10
- readonly traceId: number | string;
11
+ readonly traceId: TraceId;
11
12
  readonly emoji: TelegramEmoji;
12
13
  readonly action: IActionWithState<IActionState>;
13
- constructor(traceId: number | string, chatInfo: ChatInfo, messageId: number, emoji: TelegramEmoji, action: IActionWithState<IActionState>);
14
+ constructor(traceId: TraceId, chatInfo: ChatInfo, messageId: number, emoji: TelegramEmoji, action: IActionWithState<IActionState>);
14
15
  }
15
16
  //# sourceMappingURL=reaction.d.ts.map
@@ -1 +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"}
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;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,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,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAQ7C"}
@@ -3,15 +3,16 @@ import { IReplyMessage } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
4
  import { IActionState } from '../../types/actionState';
5
5
  import { ChatInfo } from '../chatInfo';
6
+ import { TraceId } from '../../types/trace';
6
7
  export declare class TextMessage implements IReplyMessage<string> {
7
8
  readonly kind: "text";
8
9
  readonly content: string;
9
10
  readonly chatInfo: ChatInfo;
10
11
  readonly replyId: number | undefined;
11
- readonly traceId: string | number;
12
+ readonly traceId: TraceId;
12
13
  readonly disableWebPreview: boolean;
13
14
  readonly shouldPin: boolean;
14
15
  readonly action: IActionWithState<IActionState>;
15
- constructor(text: string, chatInfo: ChatInfo, replyId: number | undefined, traceId: string | number, action: IActionWithState<IActionState>, options?: TextMessageSendingOptions);
16
+ constructor(text: string, chatInfo: ChatInfo, replyId: number | undefined, traceId: TraceId, action: IActionWithState<IActionState>, options?: TextMessageSendingOptions);
16
17
  }
17
18
  //# sourceMappingURL=textMessage.d.ts.map
@@ -1 +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,gBAA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AAC,EAAE,yBAAyB;CAU1C"}
@@ -2,12 +2,13 @@ import { IChatResponse } from '../../types/response';
2
2
  import { IActionWithState } from '../../types/actionWithState';
3
3
  import { IActionState } from '../../types/actionState';
4
4
  import { ChatInfo } from '../chatInfo';
5
+ import { TraceId } from '../../types/trace';
5
6
  export declare class UnpinResponse implements IChatResponse {
6
7
  readonly kind: "unpin";
7
8
  readonly messageId: number;
8
9
  readonly chatInfo: ChatInfo;
9
- readonly traceId: number | string;
10
+ readonly traceId: TraceId;
10
11
  readonly action: IActionWithState<IActionState>;
11
- constructor(messageId: number, chatInfo: ChatInfo, traceId: number | string, action: IActionWithState<IActionState>);
12
+ constructor(messageId: number, chatInfo: ChatInfo, traceId: TraceId, action: IActionWithState<IActionState>);
12
13
  }
13
14
  //# sourceMappingURL=unpin.d.ts.map
@@ -1 +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"}
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;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,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,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"}
@@ -4,15 +4,16 @@ import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
5
  import { IActionState } from '../../types/actionState';
6
6
  import { ChatInfo } from '../chatInfo';
7
+ import { TraceId } from '../../types/trace';
7
8
  export declare class VideoMessage implements IReplyMessage<InputFile> {
8
9
  readonly kind: "video";
9
10
  readonly content: InputFile;
10
11
  readonly chatInfo: ChatInfo;
11
12
  readonly replyId: number | undefined;
12
- readonly traceId: string | number;
13
+ readonly traceId: TraceId;
13
14
  readonly disableWebPreview = false;
14
15
  readonly shouldPin: boolean;
15
16
  readonly action: IActionWithState<IActionState>;
16
- constructor(video: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
+ constructor(video: InputFile, chatInfo: ChatInfo, replyId: number | undefined, traceId: TraceId, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
17
18
  }
18
19
  //# sourceMappingURL=videoMessage.d.ts.map
@@ -1 +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"}
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;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,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,OAAO,CAAC;IAC1B,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,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
@@ -18,6 +18,7 @@ export declare class CommandAction<TActionState extends IActionState> implements
18
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
+ private checkIfShouldBeExecuted;
21
22
  private checkTrigger;
22
23
  }
23
24
  //# sourceMappingURL=commandAction.d.ts.map
@@ -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,CAAC,QAAQ,EAAE,cAAc,EAAE,CAAC;IACpC,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,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,OA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C,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;IAkD5C,OAAO,CAAC,uBAAuB;IAqC/B,OAAO,CAAC,YAAY;CAmCvB"}
@@ -8,8 +8,7 @@ const moment_1 = __importDefault(require("moment"));
8
8
  const timeConvertions_1 = require("../../helpers/timeConvertions");
9
9
  const toArray_1 = require("../../helpers/toArray");
10
10
  const commandTriggerCheckResult_1 = require("../../dtos/commandTriggerCheckResult");
11
- const logger_1 = require("../../services/logger");
12
- const actionExecutionResult_1 = require("../../dtos/actionExecutionResult");
11
+ const noop_1 = require("../../helpers/noop");
13
12
  class CommandAction {
14
13
  constructor(trigger, handler, name, active, cooldown, chatsBlacklist, allowedUsers, condition, stateConstructor) {
15
14
  this.triggers = (0, toArray_1.toArray)(trigger);
@@ -27,17 +26,14 @@ class CommandAction {
27
26
  if (!ctx.isInitialized)
28
27
  throw new Error(`Context for ${this.key} is not initialized or already consumed`);
29
28
  if (!this.active || this.chatsBlacklist.includes(ctx.chatInfo.id))
30
- return [];
31
- const isConditionMet = await this.condition(ctx);
32
- if (!isConditionMet)
33
- return [];
29
+ return noop_1.Noop.NoResponse;
34
30
  const state = await ctx.storage.getActionState(this, ctx.chatInfo.id);
35
- const { shouldTrigger, matchResults, skipCooldown } = this.triggers
36
- .map((x) => this.checkTrigger(ctx, x, state))
31
+ const { shouldExecute, matchResults, skipCooldown } = this.triggers
32
+ .map((x) => this.checkIfShouldBeExecuted(ctx, x, state))
37
33
  .reduce((acc, curr) => acc.mergeWith(curr), commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger);
38
- if (!shouldTrigger)
39
- return [];
40
- logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
34
+ if (!shouldExecute)
35
+ return noop_1.Noop.NoResponse;
36
+ ctx.logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
41
37
  ctx.matchResults = matchResults;
42
38
  await this.handler(ctx, state);
43
39
  if (skipCooldown) {
@@ -46,14 +42,10 @@ class CommandAction {
46
42
  if (ctx.startCooldown) {
47
43
  state.lastExecutedDate = (0, moment_1.default)().valueOf();
48
44
  }
49
- ctx.updateActions.forEach((action) => action(state));
50
- await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, new actionExecutionResult_1.ActionExecutionResult(state, ctx.startCooldown && shouldTrigger));
51
- ctx.isInitialized = false;
45
+ await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
52
46
  return ctx.responses;
53
47
  }
54
- checkTrigger(ctx, trigger, state) {
55
- let shouldTrigger = false;
56
- const matchResults = [];
48
+ checkIfShouldBeExecuted(ctx, trigger, state) {
57
49
  if (!ctx.fromUserId)
58
50
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
59
51
  const isUserAllowed = this.allowedUsers.length == 0 ||
@@ -65,29 +57,38 @@ class CommandAction {
65
57
  const onCooldown = (0, moment_1.default)().diff(lastExecutedDate) < cooldownInMilliseconds;
66
58
  if (onCooldown)
67
59
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger;
68
- if (trigger == ctx.messageType) {
69
- shouldTrigger = true;
70
- }
71
- else if (typeof trigger == 'string') {
72
- shouldTrigger = ctx.messageText.toLowerCase() == trigger;
73
- }
74
- else {
75
- trigger.lastIndex = 0;
76
- const execResult = trigger.exec(ctx.messageText);
77
- if (execResult != null) {
78
- matchResults.push(execResult);
79
- if (trigger.global) {
80
- while (true) {
81
- const nextResult = trigger.exec(ctx.messageText);
82
- if (nextResult == null)
83
- break;
84
- matchResults.push(nextResult);
85
- }
60
+ const isCustomConditionMet = this.condition(ctx);
61
+ if (!isCustomConditionMet)
62
+ return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown;
63
+ const { shouldTrigger, matchResults } = this.checkTrigger(ctx, trigger);
64
+ return new commandTriggerCheckResult_1.CommandTriggerCheckResult(shouldTrigger, matchResults, false);
65
+ }
66
+ checkTrigger(ctx, trigger) {
67
+ if (trigger == ctx.messageType)
68
+ return { shouldTrigger: true, matchResults: [] };
69
+ if (typeof trigger == 'string')
70
+ return {
71
+ shouldTrigger: ctx.messageText.toLowerCase() == trigger,
72
+ matchResults: []
73
+ };
74
+ const matchResults = [];
75
+ trigger.lastIndex = 0;
76
+ const execResult = trigger.exec(ctx.messageText);
77
+ if (execResult != null) {
78
+ matchResults.push(execResult);
79
+ if (trigger.global) {
80
+ while (true) {
81
+ const nextResult = trigger.exec(ctx.messageText);
82
+ if (nextResult == null)
83
+ break;
84
+ matchResults.push(nextResult);
86
85
  }
87
86
  }
88
- shouldTrigger = matchResults.length > 0;
89
87
  }
90
- return new commandTriggerCheckResult_1.CommandTriggerCheckResult(shouldTrigger, matchResults, false);
88
+ return {
89
+ shouldTrigger: matchResults.length > 0,
90
+ matchResults
91
+ };
91
92
  }
92
93
  }
93
94
  exports.CommandAction = CommandAction;
@@ -19,6 +19,6 @@ export declare class ScheduledAction<TActionState extends IActionState> implemen
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;
22
- private shouldTrigger;
22
+ private checkIfShouldBeExecuted;
23
23
  }
24
24
  //# sourceMappingURL=scheduledAction.d.ts.map
@@ -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,QAAQ,CAAC,KAAK,yBAAgC;IAErD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IAExB,QAAQ,CAAC,WAAW,uBAA8B;IAClD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IAC9C,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAC/D,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC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,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;YA0C3B,cAAc;IA+C5B,OAAO,CAAC,uBAAuB;CAalC"}
@@ -7,9 +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("../../dtos/actionExecutionResult");
11
- const logger_1 = require("../../services/logger");
12
- const taskScheduler_1 = require("../../services/taskScheduler");
10
+ const noop_1 = require("../../helpers/noop");
13
11
  class ScheduledAction {
14
12
  constructor(name, handler, timeinHours, active, whitelist, cachedStateFactories, stateConstructor) {
15
13
  this.cachedState = new Map();
@@ -26,20 +24,18 @@ class ScheduledAction {
26
24
  if (!ctx.isInitialized)
27
25
  throw new Error(`Context for ${this.key} is not initialized or already consumed`);
28
26
  if (!this.active || !this.chatsWhitelist.includes(ctx.chatInfo.id))
29
- return [];
27
+ return noop_1.Noop.NoResponse;
30
28
  const state = await ctx.storage.getActionState(this, ctx.chatInfo.id);
31
- const isAllowedToTrigger = this.shouldTrigger(state);
32
- if (isAllowedToTrigger) {
33
- logger_1.Logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
34
- await this.handler(ctx, (key) => this.getCachedValue(key, ctx.botName), state);
35
- state.lastExecutedDate = (0, moment_1.default)().valueOf();
36
- ctx.updateActions.forEach((action) => action(state));
37
- await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, new actionExecutionResult_1.ActionExecutionResult(state, isAllowedToTrigger));
38
- }
39
- ctx.isInitialized = false;
29
+ const isAllowedToTrigger = this.checkIfShouldBeExecuted(state);
30
+ if (!isAllowedToTrigger)
31
+ return noop_1.Noop.NoResponse;
32
+ ctx.logger.logWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, ` - Executing [${this.name}] in ${ctx.chatInfo.id}`);
33
+ await this.handler(ctx, (key) => this.getCachedValue(key, ctx.botName, ctx.scheduler), state);
34
+ state.lastExecutedDate = (0, moment_1.default)().valueOf();
35
+ await ctx.storage.saveActionExecutionResult(this, ctx.chatInfo.id, state);
40
36
  return ctx.responses;
41
37
  }
42
- async getCachedValue(key, botName) {
38
+ async getCachedValue(key, botName, scheduler) {
43
39
  if (!this.cachedStateFactories.has(key)) {
44
40
  throw new Error(`No shared cache was set up for the key [${key}] in action '${this.name}'`);
45
41
  }
@@ -60,14 +56,14 @@ class ScheduledAction {
60
56
  const cachedItemFactory = this.cachedStateFactories.get(key);
61
57
  const value = await cachedItemFactory.getValue();
62
58
  this.cachedState.set(key, value);
63
- taskScheduler_1.Scheduler.createOnetimeTask(`Drop cached value [${this.name} : ${key}]`, () => this.cachedState.delete(key), (0, timeConvertions_1.hoursToMilliseconds)(cachedItemFactory.invalidationTimeoutInHours), botName);
59
+ scheduler.createOnetimeTask(`Drop cached value [${this.name} : ${key}]`, () => this.cachedState.delete(key), (0, timeConvertions_1.hoursToMilliseconds)(cachedItemFactory.invalidationTimeoutInHours), botName);
64
60
  return value;
65
61
  }
66
62
  finally {
67
63
  semaphore.release();
68
64
  }
69
65
  }
70
- shouldTrigger(state) {
66
+ checkIfShouldBeExecuted(state) {
71
67
  const startOfToday = (0, moment_1.default)().startOf('day').valueOf();
72
68
  const lastExecutedDate = (0, moment_1.default)(state.lastExecutedDate);
73
69
  const currentTime = (0, moment_1.default)();
@@ -3,24 +3,32 @@ import { IStorageClient } from '../types/storage';
3
3
  import { IActionState } from '../types/actionState';
4
4
  import { CommandAction } from './actions/commandAction';
5
5
  import { ScheduledAction } from './actions/scheduledAction';
6
+ import { ILogger } from '../types/logger';
7
+ import { IScheduler } from '../types/scheduler';
6
8
  export declare class BotInstance {
7
- readonly name: string;
8
9
  private readonly api;
10
+ private readonly storage;
11
+ private readonly scheduler;
12
+ private readonly logger;
13
+ readonly name: string;
9
14
  private readonly telegraf;
10
15
  private readonly commands;
11
16
  private readonly scheduled;
12
17
  private readonly chats;
13
- readonly storage: IStorageClient;
14
18
  constructor(options: {
15
19
  name: string;
16
20
  token: string;
17
21
  commands: CommandAction<IActionState>[];
18
22
  scheduled: ScheduledAction<IActionState>[];
19
23
  chats: Record<string, number>;
20
- storageClient?: IStorageClient;
21
24
  storagePath?: string;
22
25
  scheduledPeriod?: Seconds;
23
26
  verboseLoggingForIncomingMessage?: boolean;
27
+ services?: {
28
+ storageClient?: IStorageClient;
29
+ logger?: ILogger;
30
+ scheduler?: IScheduler;
31
+ };
24
32
  });
25
33
  private initializeScheduledProcessing;
26
34
  private initializeMessageProcessing;
@@ -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,CAAC;AAGlD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAS5D,qBAAa,WAAW;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;I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