chz-telegram-bot 0.0.46 → 0.0.47

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 (44) hide show
  1. package/dist/entities/actionExecutionResult.d.ts +3 -3
  2. package/dist/entities/actionExecutionResult.d.ts.map +1 -1
  3. package/dist/entities/actions/commandAction.d.ts +1 -1
  4. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  5. package/dist/entities/actions/scheduledAction.d.ts +1 -1
  6. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  7. package/dist/entities/context/chatContext.d.ts +4 -3
  8. package/dist/entities/context/chatContext.d.ts.map +1 -1
  9. package/dist/entities/context/messageContext.d.ts +1 -1
  10. package/dist/entities/context/messageContext.d.ts.map +1 -1
  11. package/dist/entities/responses/imageMessage.d.ts +3 -2
  12. package/dist/entities/responses/imageMessage.d.ts.map +1 -1
  13. package/dist/entities/responses/reaction.d.ts +3 -2
  14. package/dist/entities/responses/reaction.d.ts.map +1 -1
  15. package/dist/entities/responses/textMessage.d.ts +3 -2
  16. package/dist/entities/responses/textMessage.d.ts.map +1 -1
  17. package/dist/entities/responses/unpin.d.ts +3 -2
  18. package/dist/entities/responses/unpin.d.ts.map +1 -1
  19. package/dist/entities/responses/videoMessage.d.ts +3 -2
  20. package/dist/entities/responses/videoMessage.d.ts.map +1 -1
  21. package/dist/services/jsonFileStorage.d.ts +5 -5
  22. package/dist/services/jsonFileStorage.d.ts.map +1 -1
  23. package/dist/services/jsonFileStorage.js +1 -1
  24. package/dist/types/actionWithState.d.ts +2 -2
  25. package/dist/types/actionWithState.d.ts.map +1 -1
  26. package/dist/types/response.d.ts +2 -1
  27. package/dist/types/response.d.ts.map +1 -1
  28. package/dist/types/storage.d.ts +4 -4
  29. package/dist/types/storage.d.ts.map +1 -1
  30. package/entities/actionExecutionResult.ts +3 -3
  31. package/entities/actions/commandAction.ts +7 -2
  32. package/entities/actions/scheduledAction.ts +7 -2
  33. package/entities/context/chatContext.ts +4 -3
  34. package/entities/context/messageContext.ts +1 -1
  35. package/entities/responses/imageMessage.ts +3 -2
  36. package/entities/responses/reaction.ts +3 -2
  37. package/entities/responses/textMessage.ts +3 -2
  38. package/entities/responses/unpin.ts +3 -2
  39. package/entities/responses/videoMessage.ts +3 -2
  40. package/package.json +1 -1
  41. package/services/jsonFileStorage.ts +22 -13
  42. package/types/actionWithState.ts +2 -2
  43. package/types/response.ts +2 -1
  44. package/types/storage.ts +9 -6
@@ -1,7 +1,7 @@
1
1
  import { IActionState } from '../types/actionState';
2
- export declare class ActionExecutionResult {
3
- data: IActionState;
2
+ export declare class ActionExecutionResult<TActionState extends IActionState> {
3
+ data: TActionState;
4
4
  shouldUpdate: boolean;
5
- constructor(data: IActionState, shouldUpdate: boolean);
5
+ constructor(data: TActionState, shouldUpdate: boolean);
6
6
  }
7
7
  //# sourceMappingURL=actionExecutionResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../entities/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB;IAC9B,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
1
+ {"version":3,"file":"actionExecutionResult.d.ts","sourceRoot":"","sources":["../../entities/actionExecutionResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,qBAAa,qBAAqB,CAAC,YAAY,SAAS,YAAY;IAChE,IAAI,EAAE,YAAY,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO;CAIxD"}
@@ -5,7 +5,7 @@ import { IActionState } from '../../types/actionState';
5
5
  import { IActionWithState, ActionKey } from '../../types/actionWithState';
6
6
  import { MessageContext } from '../context/messageContext';
7
7
  import { CommandTrigger } from '../../types/commandTrigger';
8
- export declare class CommandAction<TActionState extends IActionState> implements IActionWithState {
8
+ export declare class CommandAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
9
9
  triggers: CommandTrigger[];
10
10
  handler: CommandHandler<TActionState>;
11
11
  name: string;
@@ -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;IAE3B,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,EAAE,MAAM,YAAY,CAAC;IACrC,GAAG,EAAE,SAAS,CAAC;gBAGX,OAAO,EAAE,cAAc,GAAG,cAAc,EAAE,EAC1C,OAAO,EAAE,cAAc,CAAC,YAAY,CAAC,EACrC,IAAI,EAAE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AE,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,YAAY;CAwDvB"}
@@ -5,7 +5,7 @@ import { IActionState } from '../../types/actionState';
5
5
  import { IActionWithState, ActionKey } from '../../types/actionWithState';
6
6
  import { CachedStateFactory } from '../cachedStateFactory';
7
7
  import { ChatContext } from '../context/chatContext';
8
- export declare class ScheduledAction<TActionState extends IActionState> implements IActionWithState {
8
+ export declare class ScheduledAction<TActionState extends IActionState> implements IActionWithState<TActionState> {
9
9
  static locks: Map<string, Semaphore>;
10
10
  name: string;
11
11
  timeinHours: HoursOfDay;
@@ -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;IAE3B,MAAM,CAAC,KAAK,yBAAgC;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EzC,MAAM,CAAC,KAAK,yBAAgC;IAE5C,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,GAAG,EAAE,SAAS,CAAC;IAEf,WAAW,uBAA8B;IACzC,gBAAgB,EAAE,MAAM,YAAY,CAAC;IACrC,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACtD,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGpC,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;YAqC3B,cAAc;IA8C5B,OAAO,CAAC,aAAa;CAaxB"}
@@ -2,11 +2,12 @@ import { IBotApiInteractions } from '../../services/telegramApi';
2
2
  import { IStorageClient } from '../../types/storage';
3
3
  import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
5
6
  /**
6
7
  * Context of action executed in chat.
7
8
  */
8
- export declare class ChatContext<TActionState> {
9
- protected action: IActionWithState;
9
+ export declare class ChatContext<TActionState extends IActionState> {
10
+ protected action: IActionWithState<TActionState>;
10
11
  protected interactions: IBotApiInteractions;
11
12
  updateActions: Array<(state: TActionState) => void>;
12
13
  /** Trace id of a action execution. */
@@ -21,7 +22,7 @@ export declare class ChatContext<TActionState> {
21
22
  storage: IStorageClient;
22
23
  isInitialized: boolean;
23
24
  constructor();
24
- initializeChatContext(botName: string, action: IActionWithState, interactions: IBotApiInteractions, chatId: number, chatName: string, traceId: number | string, storage: IStorageClient): this;
25
+ initializeChatContext(botName: string, action: IActionWithState<TActionState>, interactions: IBotApiInteractions, chatId: number, chatName: string, traceId: number | string, storage: IStorageClient): this;
25
26
  /**
26
27
  * Manually update the state of an action.
27
28
  * @param stateUpdateAction Function that will modify state.
@@ -1 +1 @@
1
- {"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D;;GAEG;AACH,qBAAa,WAAW,CAAC,YAAY;IACjC,SAAS,CAAC,MAAM,EAAG,gBAAgB,CAAC;IACpC,SAAS,CAAC,YAAY,EAAG,mBAAmB,CAAC;IAC7C,aAAa,EAAE,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC,CAAM;IACzD,sCAAsC;IACtC,OAAO,EAAG,MAAM,GAAG,MAAM,CAAC;IAC1B,+CAA+C;IAC/C,OAAO,EAAG,MAAM,CAAC;IACjB,+CAA+C;IAC/C,MAAM,EAAG,MAAM,CAAC;IAChB,iDAAiD;IACjD,QAAQ,EAAG,MAAM,CAAC;IAClB,4CAA4C;IAC5C,OAAO,EAAG,cAAc,CAAC;IAEzB,aAAa,UAAS;;IAItB,qBAAqB,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,EACxB,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,EAAE,cAAc;IAgB3B;;;OAGG;IACH,WA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AItB,qBAAqB,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,YAAY,EAAE,mBAAmB,EACjC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,EAAE,cAAc;IAgB3B;;;OAGG;IACH,WAAW,CAAC,iBAAiB,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI;IAI5D;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAahE;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;;OAIG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;OAGG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;CAKjC"}
@@ -26,7 +26,7 @@ export declare class MessageContext<TActionState extends IActionState> extends C
26
26
  /** Type of message being received */
27
27
  messageType: MessageTypeValue;
28
28
  constructor();
29
- initializeMessageContext(botName: string, action: IActionWithState, interactions: IBotApiInteractions, message: IncomingMessage, storage: IStorageClient): this;
29
+ initializeMessageContext(botName: string, action: IActionWithState<TActionState>, interactions: IBotApiInteractions, message: IncomingMessage, storage: IStorageClient): this;
30
30
  /**
31
31
  * Loads state of another action. Changes to the loaded state will no affect actual state of other action.
32
32
  * @param commandName Name of an action to load state of.
@@ -1 +1 @@
1
- {"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM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ACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,WAAW,EAAE,MAAM,GACpB,OAAO,CAAC,mBAAmB,CAAC;IAe/B;;;;OAIG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAa/D;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc5D;;;;OAIG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc5D;;;OAGG;IACH,KAAK,CAAC,KAAK,EAAE,aAAa;CAW7B"}
@@ -2,6 +2,7 @@ import { InputFile } from 'telegraf/types';
2
2
  import { IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
5
6
  export declare class ImageMessage implements IReplyMessage<InputFile> {
6
7
  kind: "image";
7
8
  content: InputFile;
@@ -10,7 +11,7 @@ export declare class ImageMessage implements IReplyMessage<InputFile> {
10
11
  traceId: string | number;
11
12
  disableWebPreview: boolean;
12
13
  shouldPin: boolean;
13
- action: IActionWithState;
14
- constructor(image: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState, options?: MessageSendingOptions);
14
+ action: IActionWithState<IActionState>;
15
+ constructor(image: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
15
16
  }
16
17
  //# sourceMappingURL=imageMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../entities/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,mCAA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AE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,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,13 +1,14 @@
1
1
  import { TelegramEmoji } from 'telegraf/types';
2
2
  import { IChatResponse } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
4
5
  export declare class Reaction implements IChatResponse {
5
6
  kind: "react";
6
7
  chatId: number;
7
8
  messageId: number;
8
9
  traceId: number | string;
9
10
  emoji: TelegramEmoji;
10
- action: IActionWithState;
11
- constructor(traceId: number | string, chatId: number, messageId: number, emoji: TelegramEmoji, action: IActionWithState);
11
+ action: IActionWithState<IActionState>;
12
+ constructor(traceId: number | string, chatId: number, messageId: number, emoji: TelegramEmoji, action: IActionWithState<IActionState>);
12
13
  }
13
14
  //# 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;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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,MAAM,EAAE,gBAAgB,CAAC;gBAGrB,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB;CAQ/B"}
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;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,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,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAQ7C"}
@@ -1,6 +1,7 @@
1
1
  import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
2
2
  import { IReplyMessage } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
4
5
  export declare class TextMessage implements IReplyMessage<string> {
5
6
  kind: "text";
6
7
  content: string;
@@ -9,7 +10,7 @@ export declare class TextMessage implements IReplyMessage<string> {
9
10
  traceId: string | number;
10
11
  disableWebPreview: boolean;
11
12
  shouldPin: boolean;
12
- action: IActionWithState;
13
- constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number, action: IActionWithState, options?: TextMessageSendingOptions);
13
+ action: IActionWithState<IActionState>;
14
+ constructor(text: string, chatId: number, replyId: number | undefined, traceId: string | number, action: IActionWithState<IActionState>, options?: TextMessageSendingOptions);
14
15
  }
15
16
  //# sourceMappingURL=textMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/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;AAE/D,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,MAAM,EAAE,gBAAgB,CAAC;gBAGrB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
1
+ {"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../entities/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;AAEvD,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,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
@@ -1,11 +1,12 @@
1
1
  import { IChatResponse } from '../../types/response';
2
2
  import { IActionWithState } from '../../types/actionWithState';
3
+ import { IActionState } from '../../types/actionState';
3
4
  export declare class UnpinResponse implements IChatResponse {
4
5
  kind: "unpin";
5
6
  messageId: number;
6
7
  chatId: number;
7
8
  traceId: number | string;
8
- action: IActionWithState;
9
- constructor(messageId: number, chatId: number, traceId: number | string, action: IActionWithState);
9
+ action: IActionWithState<IActionState>;
10
+ constructor(messageId: number, chatId: number, traceId: number | string, action: IActionWithState<IActionState>);
10
11
  }
11
12
  //# sourceMappingURL=unpin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../entities/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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,MAAM,EAAE,gBAAgB,CAAC;gBAGrB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB;CAO/B"}
1
+ {"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../entities/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;AAEvD,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,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
@@ -2,6 +2,7 @@ import { InputFile } from 'telegraf/types';
2
2
  import { IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
5
6
  export declare class VideoMessage implements IReplyMessage<InputFile> {
6
7
  kind: "video";
7
8
  content: InputFile;
@@ -10,7 +11,7 @@ export declare class VideoMessage implements IReplyMessage<InputFile> {
10
11
  traceId: string | number;
11
12
  disableWebPreview: boolean;
12
13
  shouldPin: boolean;
13
- action: IActionWithState;
14
- constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState, options?: MessageSendingOptions);
14
+ action: IActionWithState<IActionState>;
15
+ constructor(video: InputFile, chatId: number, replyId: number | undefined, traceId: number | string, action: IActionWithState<IActionState>, options?: MessageSendingOptions);
15
16
  }
16
17
  //# 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,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,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,MAAM,EAAE,gBAAgB,CAAC;gBAGrB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,EACxB,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
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;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;AAEvD,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,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAGnC,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
@@ -7,16 +7,16 @@ export declare class JsonFileStorage implements IStorageClient {
7
7
  private cache;
8
8
  private storagePath;
9
9
  private botName;
10
- constructor(botName: string, actions: IActionWithState[], path?: string);
10
+ constructor(botName: string, actions: IActionWithState<IActionState>[], path?: string);
11
11
  private lock;
12
12
  private loadInternal;
13
13
  private save;
14
14
  private buidPathFromKey;
15
15
  load<TActionState extends IActionState>(key: ActionKey): Promise<Record<number, TActionState>>;
16
- saveMetadata(actions: IActionWithState[], botName: string): Promise<void>;
17
- getActionState<TActionState extends IActionState>(action: IActionWithState, chatId: number): Promise<TActionState>;
18
- saveActionExecutionResult(action: IActionWithState, chatId: number, transactionResult: ActionExecutionResult): Promise<void>;
16
+ saveMetadata(actions: IActionWithState<IActionState>[], botName: string): Promise<void>;
17
+ getActionState<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number): Promise<TActionState>;
18
+ saveActionExecutionResult<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, transactionResult: ActionExecutionResult<TActionState>): Promise<void>;
19
19
  close(): Promise<void>;
20
- updateStateFor<TActionState extends IActionState>(action: IActionWithState, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
20
+ updateStateFor<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
21
21
  }
22
22
  //# sourceMappingURL=jsonFileStorage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAIA,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,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEvE,qBAAa,eAAgB,YAAW,cAAc;IAClD,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,KAAK,CAA4C;IACzD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,OAAO,CAAS;gBAEZ,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM;YAgBzD,IAAI;YAgBJ,YAAY;YAqBZ,IAAI;IAalB,OAAO,CAAC,eAAe;IAOjB,IAAI,CAAC,YAAY,SAAS,YAAY,EAAE,GAAG,EAAE,SAAS;IAMtD,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM;IAUzD,cAAc,CAAC,YAAY,SAAS,YAAY,EAClD,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM;IAYZ,yBAAyB,CAC3B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,qBAAqB;IAYtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,cAAc,CAAC,YAAY,SAAS,YAAY,EAClD,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC;CAcrD"}
1
+ {"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","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-48,7 +48,7 @@ class JsonFileStorage {
48
48
  return (this.cache.get(key) ?? {});
49
49
  }
50
50
  async save(data, key) {
51
- this.cache.delete(key);
51
+ this.cache.set(key, data);
52
52
  const targetPath = this.buidPathFromKey(key);
53
53
  const folderName = (0, path_1.dirname)(targetPath);
54
54
  if (!(0, fs_1.existsSync)(folderName)) {
@@ -2,8 +2,8 @@ import { IActionState } from './actionState';
2
2
  export type ActionKey = string & {
3
3
  __brand: 'actionKey';
4
4
  };
5
- export interface IActionWithState {
5
+ export interface IActionWithState<TActionState extends IActionState> {
6
6
  key: ActionKey;
7
- stateConstructor: () => IActionState;
7
+ stateConstructor: () => TActionState;
8
8
  }
9
9
  //# sourceMappingURL=actionWithState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"actionWithState.d.ts","sourceRoot":"","sources":["../../types/actionWithState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,gBAAgB;IAC7B,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACxC"}
1
+ {"version":3,"file":"actionWithState.d.ts","sourceRoot":"","sources":["../../types/actionWithState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,WAAW,CAAA;CAAE,CAAC;AAE1D,MAAM,WAAW,gBAAgB,CAAC,YAAY,SAAS,YAAY;IAC/D,GAAG,EAAE,SAAS,CAAC;IACf,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACxC"}
@@ -3,6 +3,7 @@ import { Reaction } from '../entities/responses/reaction';
3
3
  import { TextMessage } from '../entities/responses/textMessage';
4
4
  import { UnpinResponse } from '../entities/responses/unpin';
5
5
  import { VideoMessage } from '../entities/responses/videoMessage';
6
+ import { IActionState } from './actionState';
6
7
  import { IActionWithState } from './actionWithState';
7
8
  export declare const BotResponseTypes: {
8
9
  readonly unpin: "unpin";
@@ -16,7 +17,7 @@ export interface IChatResponse {
16
17
  kind: keyof typeof BotResponseTypes;
17
18
  chatId: number;
18
19
  traceId: number | string;
19
- action: IActionWithState;
20
+ action: IActionWithState<IActionState>;
20
21
  }
21
22
  export interface IReplyMessage<TType> extends IChatResponse {
22
23
  content: TType;
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB,MAAM,EAAE,gBAAgB,CAAC;CAC5B;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;CACtB"}
1
+ {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAErD,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IAEzB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CAC1C;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,OAAO,EAAE,KAAK,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;CACtB"}
@@ -2,11 +2,11 @@ import { ActionExecutionResult } from '../entities/actionExecutionResult';
2
2
  import { IActionState } from './actionState';
3
3
  import { ActionKey, IActionWithState } from './actionWithState';
4
4
  export interface IStorageClient {
5
- updateStateFor<TActionState extends IActionState>(action: IActionWithState, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
5
+ updateStateFor<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
6
6
  close(): Promise<void>;
7
7
  load<TActionState extends IActionState>(key: ActionKey): Promise<Record<number, TActionState>>;
8
- saveMetadata(actions: IActionWithState[], botName: string): Promise<void>;
9
- getActionState<TActionState extends IActionState>(action: IActionWithState, chatId: number): Promise<TActionState>;
10
- saveActionExecutionResult(action: IActionWithState, chatId: number, transactionResult: ActionExecutionResult): Promise<void>;
8
+ saveMetadata<TActionState extends IActionState>(actions: IActionWithState<TActionState>[], botName: string): Promise<void>;
9
+ getActionState<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number): Promise<TActionState>;
10
+ saveActionExecutionResult<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, transactionResult: ActionExecutionResult<TActionState>): Promise<void>;
11
11
  }
12
12
  //# sourceMappingURL=storage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../types/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAEhE,MAAM,WAAW,cAAc;IAC3B,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAC/C,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,IAAI,CAAC,YAAY,SAAS,YAAY,EAClC,GAAG,EAAE,SAAS,GACf,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACzC,YAAY,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAA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yB,CAAC,YAAY,SAAS,YAAY,EACvD,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,iBAAiB,EAAE,qBAAqB,CAAC,YAAY,CAAC,GACvD,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
@@ -1,10 +1,10 @@
1
1
  import { IActionState } from '../types/actionState';
2
2
 
3
- export class ActionExecutionResult {
4
- data: IActionState;
3
+ export class ActionExecutionResult<TActionState extends IActionState> {
4
+ data: TActionState;
5
5
  shouldUpdate: boolean;
6
6
 
7
- constructor(data: IActionState, shouldUpdate: boolean) {
7
+ constructor(data: TActionState, shouldUpdate: boolean) {
8
8
  this.data = data;
9
9
  this.shouldUpdate = shouldUpdate;
10
10
  }
@@ -13,7 +13,7 @@ import { ActionExecutionResult } from '../actionExecutionResult';
13
13
  import { CommandTrigger } from '../../types/commandTrigger';
14
14
 
15
15
  export class CommandAction<TActionState extends IActionState>
16
- implements IActionWithState
16
+ implements IActionWithState<TActionState>
17
17
  {
18
18
  triggers: CommandTrigger[];
19
19
  handler: CommandHandler<TActionState>;
@@ -51,7 +51,10 @@ export class CommandAction<TActionState extends IActionState>
51
51
  }
52
52
 
53
53
  async exec(ctx: MessageContext<TActionState>) {
54
- if (!ctx.isInitialized) throw new Error('Context is not initialized');
54
+ if (!ctx.isInitialized)
55
+ throw new Error(
56
+ `Context for ${this.key} is not initialized or already consumed`
57
+ );
55
58
 
56
59
  if (!this.active || this.chatsBlacklist.includes(ctx.chatId)) return;
57
60
 
@@ -98,6 +101,8 @@ export class CommandAction<TActionState extends IActionState>
98
101
  ctx.chatId,
99
102
  new ActionExecutionResult(state, ctx.startCooldown && shouldTrigger)
100
103
  );
104
+
105
+ ctx.isInitialized = false;
101
106
  }
102
107
 
103
108
  private checkTrigger(
@@ -12,7 +12,7 @@ import { Logger } from '../../services/logger';
12
12
  import { Scheduler } from '../../services/taskScheduler';
13
13
 
14
14
  export class ScheduledAction<TActionState extends IActionState>
15
- implements IActionWithState
15
+ implements IActionWithState<TActionState>
16
16
  {
17
17
  static locks = new Map<string, Semaphore>();
18
18
 
@@ -47,7 +47,10 @@ export class ScheduledAction<TActionState extends IActionState>
47
47
  }
48
48
 
49
49
  async exec(ctx: ChatContext<TActionState>) {
50
- if (!ctx.isInitialized) throw new Error('Context is not initialized');
50
+ if (!ctx.isInitialized)
51
+ throw new Error(
52
+ `Context for ${this.key} is not initialized or already consumed`
53
+ );
51
54
 
52
55
  if (!this.active || !this.chatsWhitelist.includes(ctx.chatId)) return;
53
56
 
@@ -81,6 +84,8 @@ export class ScheduledAction<TActionState extends IActionState>
81
84
  new ActionExecutionResult(state, isAllowedToTrigger)
82
85
  );
83
86
  }
87
+
88
+ ctx.isInitialized = false;
84
89
  }
85
90
 
86
91
  private async getCachedValue<TResult>(
@@ -10,12 +10,13 @@ import {
10
10
  TextMessageSendingOptions
11
11
  } from '../../types/messageSendingOptions';
12
12
  import { IActionWithState } from '../../types/actionWithState';
13
+ import { IActionState } from '../../types/actionState';
13
14
 
14
15
  /**
15
16
  * Context of action executed in chat.
16
17
  */
17
- export class ChatContext<TActionState> {
18
- protected action!: IActionWithState;
18
+ export class ChatContext<TActionState extends IActionState> {
19
+ protected action!: IActionWithState<TActionState>;
19
20
  protected interactions!: IBotApiInteractions;
20
21
  updateActions: Array<(state: TActionState) => void> = [];
21
22
  /** Trace id of a action execution. */
@@ -35,7 +36,7 @@ export class ChatContext<TActionState> {
35
36
 
36
37
  initializeChatContext(
37
38
  botName: string,
38
- action: IActionWithState,
39
+ action: IActionWithState<TActionState>,
39
40
  interactions: IBotApiInteractions,
40
41
  chatId: number,
41
42
  chatName: string,
@@ -44,7 +44,7 @@ export class MessageContext<
44
44
 
45
45
  initializeMessageContext(
46
46
  botName: string,
47
- action: IActionWithState,
47
+ action: IActionWithState<TActionState>,
48
48
  interactions: IBotApiInteractions,
49
49
  message: IncomingMessage,
50
50
  storage: IStorageClient
@@ -2,6 +2,7 @@ import { InputFile } from 'telegraf/types';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
5
6
 
6
7
  export class ImageMessage implements IReplyMessage<InputFile> {
7
8
  kind = BotResponseTypes.image;
@@ -12,14 +13,14 @@ export class ImageMessage implements IReplyMessage<InputFile> {
12
13
  traceId: string | number;
13
14
  disableWebPreview = false;
14
15
  shouldPin: boolean;
15
- action: IActionWithState;
16
+ action: IActionWithState<IActionState>;
16
17
 
17
18
  constructor(
18
19
  image: InputFile,
19
20
  chatId: number,
20
21
  replyId: number | undefined,
21
22
  traceId: number | string,
22
- action: IActionWithState,
23
+ action: IActionWithState<IActionState>,
23
24
  options?: MessageSendingOptions
24
25
  ) {
25
26
  this.content = image;
@@ -1,6 +1,7 @@
1
1
  import { TelegramEmoji } from 'telegraf/types';
2
2
  import { BotResponseTypes, IChatResponse } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
4
5
 
5
6
  export class Reaction implements IChatResponse {
6
7
  kind = BotResponseTypes.react;
@@ -9,14 +10,14 @@ export class Reaction implements IChatResponse {
9
10
  messageId: number;
10
11
  traceId: number | string;
11
12
  emoji: TelegramEmoji;
12
- action: IActionWithState;
13
+ action: IActionWithState<IActionState>;
13
14
 
14
15
  constructor(
15
16
  traceId: number | string,
16
17
  chatId: number,
17
18
  messageId: number,
18
19
  emoji: TelegramEmoji,
19
- action: IActionWithState
20
+ action: IActionWithState<IActionState>
20
21
  ) {
21
22
  this.chatId = chatId;
22
23
  this.messageId = messageId;
@@ -1,6 +1,7 @@
1
1
  import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
3
  import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionState } from '../../types/actionState';
4
5
 
5
6
  export class TextMessage implements IReplyMessage<string> {
6
7
  kind = BotResponseTypes.text;
@@ -11,14 +12,14 @@ export class TextMessage implements IReplyMessage<string> {
11
12
  traceId: string | number;
12
13
  disableWebPreview: boolean;
13
14
  shouldPin: boolean;
14
- action: IActionWithState;
15
+ action: IActionWithState<IActionState>;
15
16
 
16
17
  constructor(
17
18
  text: string,
18
19
  chatId: number,
19
20
  replyId: number | undefined,
20
21
  traceId: string | number,
21
- action: IActionWithState,
22
+ action: IActionWithState<IActionState>,
22
23
  options?: TextMessageSendingOptions
23
24
  ) {
24
25
  this.content = text;
@@ -1,5 +1,6 @@
1
1
  import { BotResponseTypes, IChatResponse } from '../../types/response';
2
2
  import { IActionWithState } from '../../types/actionWithState';
3
+ import { IActionState } from '../../types/actionState';
3
4
 
4
5
  export class UnpinResponse implements IChatResponse {
5
6
  kind = BotResponseTypes.unpin;
@@ -7,13 +8,13 @@ export class UnpinResponse implements IChatResponse {
7
8
  messageId: number;
8
9
  chatId: number;
9
10
  traceId: number | string;
10
- action: IActionWithState;
11
+ action: IActionWithState<IActionState>;
11
12
 
12
13
  constructor(
13
14
  messageId: number,
14
15
  chatId: number,
15
16
  traceId: number | string,
16
- action: IActionWithState
17
+ action: IActionWithState<IActionState>
17
18
  ) {
18
19
  this.messageId = messageId;
19
20
  this.chatId = chatId;
@@ -2,6 +2,7 @@ import { InputFile } from 'telegraf/types';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
4
  import { IActionWithState } from '../../types/actionWithState';
5
+ import { IActionState } from '../../types/actionState';
5
6
 
6
7
  export class VideoMessage implements IReplyMessage<InputFile> {
7
8
  kind = BotResponseTypes.video;
@@ -12,14 +13,14 @@ export class VideoMessage implements IReplyMessage<InputFile> {
12
13
  traceId: string | number;
13
14
  disableWebPreview = false;
14
15
  shouldPin: boolean;
15
- action: IActionWithState;
16
+ action: IActionWithState<IActionState>;
16
17
 
17
18
  constructor(
18
19
  video: InputFile,
19
20
  chatId: number,
20
21
  replyId: number | undefined,
21
22
  traceId: number | string,
22
- action: IActionWithState,
23
+ action: IActionWithState<IActionState>,
23
24
  options?: MessageSendingOptions
24
25
  ) {
25
26
  this.content = video;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chz-telegram-bot",
3
- "version": "0.0.46",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "async-sema": "^3.1.1",
@@ -3,7 +3,6 @@ import { dirname } from 'path';
3
3
  import { mkdir, readFile, writeFile } from 'fs/promises';
4
4
  import { Sema as Semaphore } from 'async-sema';
5
5
  import { IStorageClient } from '../types/storage';
6
- import { ActionStateBase } from '../entities/states/actionStateBase';
7
6
  import { ActionExecutionResult } from '../entities/actionExecutionResult';
8
7
  import { IActionState } from '../types/actionState';
9
8
  import { IActionWithState, ActionKey } from '../types/actionWithState';
@@ -14,7 +13,11 @@ export class JsonFileStorage implements IStorageClient {
14
13
  private storagePath: string;
15
14
  private botName: string;
16
15
 
17
- constructor(botName: string, actions: IActionWithState[], path?: string) {
16
+ constructor(
17
+ botName: string,
18
+ actions: IActionWithState<IActionState>[],
19
+ path?: string
20
+ ) {
18
21
  this.cache = new Map<string, Record<number, IActionState>>();
19
22
  this.botName = botName;
20
23
  this.storagePath = path ?? 'storage';
@@ -67,8 +70,11 @@ export class JsonFileStorage implements IStorageClient {
67
70
  return (this.cache.get(key) ?? {}) as Record<number, TActionState>;
68
71
  }
69
72
 
70
- private async save(data: Record<number, ActionStateBase>, key: ActionKey) {
71
- this.cache.delete(key);
73
+ private async save<TActionState extends IActionState>(
74
+ data: Record<number, TActionState>,
75
+ key: ActionKey
76
+ ) {
77
+ this.cache.set(key, data);
72
78
 
73
79
  const targetPath = this.buidPathFromKey(key);
74
80
  const folderName = dirname(targetPath);
@@ -93,7 +99,10 @@ export class JsonFileStorage implements IStorageClient {
93
99
  });
94
100
  }
95
101
 
96
- async saveMetadata(actions: IActionWithState[], botName: string) {
102
+ async saveMetadata(
103
+ actions: IActionWithState<IActionState>[],
104
+ botName: string
105
+ ) {
97
106
  const targetPath = this.buidPathFromKey(
98
107
  `Metadata-${botName}` as ActionKey
99
108
  );
@@ -104,7 +113,7 @@ export class JsonFileStorage implements IStorageClient {
104
113
  }
105
114
 
106
115
  async getActionState<TActionState extends IActionState>(
107
- action: IActionWithState,
116
+ action: IActionWithState<TActionState>,
108
117
  chatId: number
109
118
  ) {
110
119
  return await this.lock(action.key, async () => {
@@ -117,13 +126,13 @@ export class JsonFileStorage implements IStorageClient {
117
126
  });
118
127
  }
119
128
 
120
- async saveActionExecutionResult(
121
- action: IActionWithState,
129
+ async saveActionExecutionResult<TActionState extends IActionState>(
130
+ action: IActionWithState<TActionState>,
122
131
  chatId: number,
123
- transactionResult: ActionExecutionResult
132
+ transactionResult: ActionExecutionResult<TActionState>
124
133
  ) {
125
134
  await this.lock(action.key, async () => {
126
- const data = await this.loadInternal(action.key);
135
+ const data = await this.loadInternal<TActionState>(action.key);
127
136
 
128
137
  if (transactionResult.shouldUpdate) {
129
138
  data[chatId] = transactionResult.data;
@@ -139,16 +148,16 @@ export class JsonFileStorage implements IStorageClient {
139
148
  }
140
149
 
141
150
  async updateStateFor<TActionState extends IActionState>(
142
- action: IActionWithState,
151
+ action: IActionWithState<TActionState>,
143
152
  chatId: number,
144
153
  update: (state: TActionState) => Promise<void>
145
154
  ) {
146
155
  await this.lock(action.key, async () => {
147
- const data = await this.loadInternal(action.key);
156
+ const data = await this.loadInternal<TActionState>(action.key);
148
157
  const state = Object.assign(
149
158
  action.stateConstructor(),
150
159
  data[chatId]
151
- ) as TActionState;
160
+ );
152
161
 
153
162
  await update(state);
154
163
 
@@ -2,7 +2,7 @@ import { IActionState } from './actionState';
2
2
 
3
3
  export type ActionKey = string & { __brand: 'actionKey' };
4
4
 
5
- export interface IActionWithState {
5
+ export interface IActionWithState<TActionState extends IActionState> {
6
6
  key: ActionKey;
7
- stateConstructor: () => IActionState;
7
+ stateConstructor: () => TActionState;
8
8
  }
package/types/response.ts CHANGED
@@ -3,6 +3,7 @@ import { Reaction } from '../entities/responses/reaction';
3
3
  import { TextMessage } from '../entities/responses/textMessage';
4
4
  import { UnpinResponse } from '../entities/responses/unpin';
5
5
  import { VideoMessage } from '../entities/responses/videoMessage';
6
+ import { IActionState } from './actionState';
6
7
  import { IActionWithState } from './actionWithState';
7
8
 
8
9
  export const BotResponseTypes = {
@@ -25,7 +26,7 @@ export interface IChatResponse {
25
26
  chatId: number;
26
27
  traceId: number | string;
27
28
 
28
- action: IActionWithState;
29
+ action: IActionWithState<IActionState>;
29
30
  }
30
31
 
31
32
  export interface IReplyMessage<TType> extends IChatResponse {
package/types/storage.ts CHANGED
@@ -4,7 +4,7 @@ import { ActionKey, IActionWithState } from './actionWithState';
4
4
 
5
5
  export interface IStorageClient {
6
6
  updateStateFor<TActionState extends IActionState>(
7
- action: IActionWithState,
7
+ action: IActionWithState<TActionState>,
8
8
  chatId: number,
9
9
  update: (state: TActionState) => Promise<void>
10
10
  ): Promise<void>;
@@ -12,14 +12,17 @@ export interface IStorageClient {
12
12
  load<TActionState extends IActionState>(
13
13
  key: ActionKey
14
14
  ): Promise<Record<number, TActionState>>;
15
- saveMetadata(actions: IActionWithState[], botName: string): Promise<void>;
15
+ saveMetadata<TActionState extends IActionState>(
16
+ actions: IActionWithState<TActionState>[],
17
+ botName: string
18
+ ): Promise<void>;
16
19
  getActionState<TActionState extends IActionState>(
17
- action: IActionWithState,
20
+ action: IActionWithState<TActionState>,
18
21
  chatId: number
19
22
  ): Promise<TActionState>;
20
- saveActionExecutionResult(
21
- action: IActionWithState,
23
+ saveActionExecutionResult<TActionState extends IActionState>(
24
+ action: IActionWithState<TActionState>,
22
25
  chatId: number,
23
- transactionResult: ActionExecutionResult
26
+ transactionResult: ActionExecutionResult<TActionState>
24
27
  ): Promise<void>;
25
28
  }