chz-telegram-bot 0.1.2 → 0.1.4

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 (96) hide show
  1. package/README.md +73 -11
  2. package/dist/dtos/incomingQuery.d.ts +9 -0
  3. package/dist/dtos/incomingQuery.d.ts.map +1 -0
  4. package/dist/dtos/incomingQuery.js +12 -0
  5. package/dist/dtos/responses/delay.d.ts +1 -1
  6. package/dist/dtos/responses/delay.d.ts.map +1 -1
  7. package/dist/dtos/responses/imageMessage.d.ts +1 -1
  8. package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
  9. package/dist/dtos/responses/inlineQueryResponse.d.ts +13 -0
  10. package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -0
  11. package/dist/dtos/responses/inlineQueryResponse.js +15 -0
  12. package/dist/dtos/responses/reaction.d.ts +1 -1
  13. package/dist/dtos/responses/reaction.d.ts.map +1 -1
  14. package/dist/dtos/responses/textMessage.d.ts +1 -1
  15. package/dist/dtos/responses/textMessage.d.ts.map +1 -1
  16. package/dist/dtos/responses/unpin.d.ts +1 -1
  17. package/dist/dtos/responses/unpin.d.ts.map +1 -1
  18. package/dist/dtos/responses/videoMessage.d.ts +1 -1
  19. package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
  20. package/dist/entities/actions/commandAction.d.ts +1 -1
  21. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  22. package/dist/entities/actions/inlineQueryAction.d.ts +14 -0
  23. package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -0
  24. package/dist/entities/actions/inlineQueryAction.js +40 -0
  25. package/dist/entities/actions/scheduledAction.d.ts +1 -1
  26. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  27. package/dist/entities/botInstance.d.ts +8 -2
  28. package/dist/entities/botInstance.d.ts.map +1 -1
  29. package/dist/entities/botInstance.js +34 -2
  30. package/dist/entities/context/chatContext.d.ts +1 -1
  31. package/dist/entities/context/chatContext.d.ts.map +1 -1
  32. package/dist/entities/context/inlineQueryContext.d.ts +38 -0
  33. package/dist/entities/context/inlineQueryContext.d.ts.map +1 -0
  34. package/dist/entities/context/inlineQueryContext.js +40 -0
  35. package/dist/entities/context/messageContext.d.ts +1 -1
  36. package/dist/entities/context/messageContext.d.ts.map +1 -1
  37. package/dist/helpers/builders/inlineQueryActionBuilder.d.ts +34 -0
  38. package/dist/helpers/builders/inlineQueryActionBuilder.d.ts.map +1 -0
  39. package/dist/helpers/builders/inlineQueryActionBuilder.js +48 -0
  40. package/dist/helpers/noop.d.ts +1 -0
  41. package/dist/helpers/noop.d.ts.map +1 -1
  42. package/dist/helpers/noop.js +1 -1
  43. package/dist/helpers/traceFactory.d.ts +1 -1
  44. package/dist/helpers/traceFactory.d.ts.map +1 -1
  45. package/dist/helpers/traceFactory.js +1 -1
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +2 -3
  49. package/dist/main.d.ts +44 -35
  50. package/dist/main.d.ts.map +1 -1
  51. package/dist/main.js +34 -31
  52. package/dist/services/jsonFileStorage.d.ts +1 -1
  53. package/dist/services/jsonFileStorage.d.ts.map +1 -1
  54. package/dist/services/telegramApi.d.ts.map +1 -1
  55. package/dist/services/telegramApi.js +6 -1
  56. package/dist/types/handlers.d.ts +4 -0
  57. package/dist/types/handlers.d.ts.map +1 -1
  58. package/dist/types/response.d.ts +4 -2
  59. package/dist/types/response.d.ts.map +1 -1
  60. package/dist/types/response.js +2 -1
  61. package/dist/types/statefulAction.d.ts +9 -0
  62. package/dist/types/statefulAction.d.ts.map +1 -0
  63. package/dist/types/statefulAction.js +2 -0
  64. package/dist/types/statelessAction.d.ts +5 -0
  65. package/dist/types/statelessAction.d.ts.map +1 -0
  66. package/dist/types/statelessAction.js +2 -0
  67. package/dist/types/storage.d.ts +1 -1
  68. package/dist/types/storage.d.ts.map +1 -1
  69. package/dtos/incomingQuery.ts +20 -0
  70. package/dtos/responses/delay.ts +1 -1
  71. package/dtos/responses/imageMessage.ts +1 -1
  72. package/dtos/responses/inlineQueryResponse.ts +26 -0
  73. package/dtos/responses/reaction.ts +1 -1
  74. package/dtos/responses/textMessage.ts +1 -1
  75. package/dtos/responses/unpin.ts +1 -1
  76. package/dtos/responses/videoMessage.ts +1 -1
  77. package/entities/actions/commandAction.ts +1 -1
  78. package/entities/actions/inlineQueryAction.ts +68 -0
  79. package/entities/actions/scheduledAction.ts +1 -1
  80. package/entities/botInstance.ts +86 -4
  81. package/entities/context/chatContext.ts +4 -4
  82. package/entities/context/inlineQueryContext.ts +83 -0
  83. package/entities/context/messageContext.ts +1 -1
  84. package/helpers/builders/inlineQueryActionBuilder.ts +62 -0
  85. package/helpers/noop.ts +3 -1
  86. package/helpers/traceFactory.ts +4 -2
  87. package/index.ts +1 -1
  88. package/main.ts +65 -58
  89. package/package.json +1 -1
  90. package/services/jsonFileStorage.ts +1 -1
  91. package/services/telegramApi.ts +10 -1
  92. package/types/handlers.ts +6 -0
  93. package/types/response.ts +5 -2
  94. package/types/statelessAction.ts +5 -0
  95. package/types/storage.ts +1 -1
  96. /package/types/{actionWithState.ts → statefulAction.ts} +0 -0
@@ -0,0 +1,34 @@
1
+ import { InlineQueryHandler } from '../../types/handlers';
2
+ import { Seconds } from '../../types/timeValues';
3
+ import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
4
+ /**
5
+ * Builder for `InlineQueryAction`
6
+ */
7
+ export declare class InlineQueryActionBuilder {
8
+ name: string;
9
+ pattern: RegExp;
10
+ active: boolean;
11
+ cooldownSeconds: Seconds;
12
+ blacklist: number[];
13
+ allowedUsers: number[];
14
+ handler: InlineQueryHandler;
15
+ /**
16
+ * Builder for `InlineQueryAction`
17
+ * @param name Action name, will be used for logging and storage
18
+ */
19
+ constructor(name: string);
20
+ /**
21
+ * Defines action pattern to check if action should be executed, if not setup, check will default to true
22
+ * @param trigger RegExp to check
23
+ */
24
+ on(pattern: RegExp): this;
25
+ /** Defines action logic itself, will be executed.
26
+ * @param handler Callback that will be called
27
+ */
28
+ do(handler: InlineQueryHandler): this;
29
+ /** If called during building, action is marked as disabled and never checked. */
30
+ disabled(): this;
31
+ /** Builds action */
32
+ build(): InlineQueryAction;
33
+ }
34
+ //# sourceMappingURL=inlineQueryActionBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineQueryActionBuilder.d.ts","sourceRoot":"","sources":["../../../helpers/builders/inlineQueryActionBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E;;GAEG;AACH,qBAAa,wBAAwB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAU;IAEzB,MAAM,UAAQ;IACd,eAAe,EAAE,OAAO,CAAgB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAM;IACzB,YAAY,EAAE,MAAM,EAAE,CAAM;IAC5B,OAAO,EAAE,kBAAkB,CAAa;IAExC;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAIxB;;;OAGG;IACH,EAAE,CAAC,OAAO,EAAE,MAAM;IAMlB;;OAEG;IACH,EAAE,CAAC,OAAO,EAAE,kBAAkB;IAM9B,iFAAiF;IACjF,QAAQ;IAMR,oBAAoB;IACpB,KAAK;CAQR"}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InlineQueryActionBuilder = void 0;
4
+ const noop_1 = require("../noop");
5
+ const inlineQueryAction_1 = require("../../entities/actions/inlineQueryAction");
6
+ /**
7
+ * Builder for `InlineQueryAction`
8
+ */
9
+ class InlineQueryActionBuilder {
10
+ /**
11
+ * Builder for `InlineQueryAction`
12
+ * @param name Action name, will be used for logging and storage
13
+ */
14
+ constructor(name) {
15
+ this.pattern = /.+/gi;
16
+ this.active = true;
17
+ this.cooldownSeconds = 0;
18
+ this.blacklist = [];
19
+ this.allowedUsers = [];
20
+ this.handler = noop_1.Noop.call;
21
+ this.name = name;
22
+ }
23
+ /**
24
+ * Defines action pattern to check if action should be executed, if not setup, check will default to true
25
+ * @param trigger RegExp to check
26
+ */
27
+ on(pattern) {
28
+ this.pattern = pattern;
29
+ return this;
30
+ }
31
+ /** Defines action logic itself, will be executed.
32
+ * @param handler Callback that will be called
33
+ */
34
+ do(handler) {
35
+ this.handler = handler;
36
+ return this;
37
+ }
38
+ /** If called during building, action is marked as disabled and never checked. */
39
+ disabled() {
40
+ this.active = false;
41
+ return this;
42
+ }
43
+ /** Builds action */
44
+ build() {
45
+ return new inlineQueryAction_1.InlineQueryAction(this.handler, this.name, this.active, this.pattern);
46
+ }
47
+ }
48
+ exports.InlineQueryActionBuilder = InlineQueryActionBuilder;
@@ -3,6 +3,7 @@ export declare class Noop {
3
3
  static NoResponse: BotResponse[];
4
4
  static true<T1>(arg1: T1): boolean;
5
5
  static false<T1>(arg1: T1): boolean;
6
+ static call<T1>(arg1: T1): Promise<void>;
6
7
  static call<T1, T2>(arg1: T1, arg2: T2): Promise<void>;
7
8
  }
8
9
  //# sourceMappingURL=noop.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,IAAI;IACb,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IACtC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;IAGxB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;WAGZ,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAE/D"}
1
+ {"version":3,"file":"noop.d.ts","sourceRoot":"","sources":["../../helpers/noop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,IAAI;IACb,MAAM,CAAC,UAAU,EAAE,WAAW,EAAE,CAAM;IACtC,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;IAGxB,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE;WAIZ,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;WACjC,IAAI,CAAC,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAE/D"}
@@ -9,7 +9,7 @@ class Noop {
9
9
  static false(arg1) {
10
10
  return false;
11
11
  }
12
- static async call(arg1) { }
12
+ static async call(arg1, arg2) { }
13
13
  }
14
14
  exports.Noop = Noop;
15
15
  Noop.NoResponse = [];
@@ -1,3 +1,3 @@
1
1
  import { TraceId } from '../types/trace';
2
- export declare function createTrace<T extends object>(traceOwner: T, botName: string, traceName: string): TraceId;
2
+ export declare function createTrace<T extends object>(traceOwner: T | string, botName: string, traceName: string): TraceId;
3
3
  //# sourceMappingURL=traceFactory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,EACb,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAEkD,OAAO,CAC7E"}
1
+ {"version":3,"file":"traceFactory.d.ts","sourceRoot":"","sources":["../../helpers/traceFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EACxC,UAAU,EAAE,CAAC,GAAG,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,GAIa,OAAO,CACxC"}
@@ -2,5 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createTrace = createTrace;
4
4
  function createTrace(traceOwner, botName, traceName) {
5
- return `${traceOwner.constructor.name}:${botName}-${traceName}`;
5
+ return `${typeof traceOwner == 'string' ? traceOwner : traceOwner.constructor.name}:${botName}-${traceName}`;
6
6
  }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { startBot, stopBots } from './main';
1
+ export { botOrchestrator } from './main';
2
2
  export { CommandActionBuilder } from './helpers/builders/commandActionBuilder';
3
3
  export { CommandActionBuilderWithState } from './helpers/builders/commandActionBuilder';
4
4
  export { IStorageClient } from './types/storage';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAC/E,OAAO,EAAE,6BAA6B,EAAE,MAAM,yCAAyC,CAAC;AACxF,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qBAAqB,CAAC;AACpC,cAAc,mCAAmC,CAAC;AAClD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -14,10 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MessageType = exports.CommandActionBuilderWithState = exports.CommandActionBuilder = exports.stopBots = exports.startBot = void 0;
17
+ exports.MessageType = exports.CommandActionBuilderWithState = exports.CommandActionBuilder = exports.botOrchestrator = void 0;
18
18
  var main_1 = require("./main");
19
- Object.defineProperty(exports, "startBot", { enumerable: true, get: function () { return main_1.startBot; } });
20
- Object.defineProperty(exports, "stopBots", { enumerable: true, get: function () { return main_1.stopBots; } });
19
+ Object.defineProperty(exports, "botOrchestrator", { enumerable: true, get: function () { return main_1.botOrchestrator; } });
21
20
  var commandActionBuilder_1 = require("./helpers/builders/commandActionBuilder");
22
21
  Object.defineProperty(exports, "CommandActionBuilder", { enumerable: true, get: function () { return commandActionBuilder_1.CommandActionBuilder; } });
23
22
  var commandActionBuilder_2 = require("./helpers/builders/commandActionBuilder");
package/dist/main.d.ts CHANGED
@@ -1,43 +1,52 @@
1
1
  import { IStorageClient } from './types/storage';
2
2
  import { CommandAction } from './entities/actions/commandAction';
3
3
  import { ScheduledAction } from './entities/actions/scheduledAction';
4
- import { IActionState } from './types/actionState';
5
4
  import { BotInstance } from './entities/botInstance';
6
5
  import { Seconds } from './types/timeValues';
7
6
  import { IScheduler } from './types/scheduler';
8
7
  import { ILogger } from './types/logger';
9
- /**
10
- * Starts bot
11
- */
12
- declare function startBot(options: {
13
- /** Bot name, used in logging */
14
- name: string;
15
- /** Path to file containing Telegram Bot token. */
16
- tokenFilePath: string;
17
- /** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
18
- commands: CommandAction<IActionState>[];
19
- /** Collection of actions that will be executed on timer. Created using `ScheduledActionBuilder`.*/
20
- scheduled: ScheduledAction<IActionState>[];
21
- /** Object containing chat name and chat id pairs. Used for logging and execution of scheduled action. */
22
- chats: Record<string, number>;
23
- /** Storage path for default `JsonFileStorage` client. Will be used only if `storageClient` is not provided. If not provided, default value of `./storage/` will be used.*/
24
- storagePath?: string;
25
- /** Period of time between execution of scheduled actions. */
26
- scheduledPeriod?: Seconds;
27
- /** If true, telegram API objects will be logged instead of message content. */
28
- verboseLoggingForIncomingMessage?: boolean;
29
- services?: {
30
- /** Storage client for bot state storage. If not provided, default `JsonFileStorage` will be used. */
31
- storageClient?: IStorageClient;
32
- /** Logger client for bot logging. If not provided, default `JsonFileStorage` will be used. */
33
- logger?: ILogger;
34
- /** Scheduler client for bot scheduling. If not provided, default `NodeTimeoutScheduler` will be used. */
35
- scheduler?: IScheduler;
36
- };
37
- }): Promise<BotInstance>;
38
- /**
39
- * Terminates all scheduled tasks, closes storage connections and stops all bots.
40
- */
41
- declare function stopBots(reason: string): Promise<void>;
42
- export { startBot, stopBots };
8
+ import { ActionStateBase } from './entities/states/actionStateBase';
9
+ import { InlineQueryAction } from './entities/actions/inlineQueryAction';
10
+ declare class BotOrchestrator {
11
+ bots: BotInstance[];
12
+ /**
13
+ * Starts bot
14
+ */
15
+ startBot(options: {
16
+ /** Bot name, used in logging */
17
+ name: string;
18
+ /** Path to file containing Telegram Bot token. */
19
+ tokenFilePath: string;
20
+ actions: {
21
+ /** Collection of actions that will be executed as a response to message from used. Created using `CommandActionBuilder`.*/
22
+ commands: CommandAction<ActionStateBase>[];
23
+ /** Collection of actions that will be executed on timer. Created using `ScheduledActionBuilder`.*/
24
+ scheduled: ScheduledAction<ActionStateBase>[];
25
+ /** Collection of actions that will handle inline queries */
26
+ inlineQueries: InlineQueryAction[];
27
+ };
28
+ /** Object containing chat name and chat id pairs. Used for logging and execution of scheduled action. */
29
+ chats: Record<string, number>;
30
+ /** Storage path for default `JsonFileStorage` client. Will be used only if `storageClient` is not provided. If not provided, default value of `./storage/` will be used.*/
31
+ storagePath?: string;
32
+ /** Period of time between execution of scheduled actions. */
33
+ scheduledPeriod?: Seconds;
34
+ /** If true, telegram API objects will be logged instead of message content. */
35
+ verboseLoggingForIncomingMessage?: boolean;
36
+ services?: {
37
+ /** Storage client for bot state storage. If not provided, default `JsonFileStorage` will be used. */
38
+ storageClient?: IStorageClient;
39
+ /** Logger client for bot logging. If not provided, default `JsonFileStorage` will be used. */
40
+ logger?: ILogger;
41
+ /** Scheduler client for bot scheduling. If not provided, default `NodeTimeoutScheduler` will be used. */
42
+ scheduler?: IScheduler;
43
+ };
44
+ }): Promise<BotInstance>;
45
+ /**
46
+ * Terminates all scheduled tasks, closes storage connections and stops all bots.
47
+ */
48
+ stopBots(reason: string): Promise<void>;
49
+ }
50
+ export declare const botOrchestrator: BotOrchestrator;
51
+ export {};
43
52
  //# sourceMappingURL=main.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../main.ts"],"names":[],"mappings":"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AC,EAAE,cAAc,CAAC;YAC/B,8FAA8F;YAC9F,MAAM,CAAC,EAAE,OAAO,CAAC;YACjB,yGAAyG;YACzG,SAAS,CAAC,EAAE,UAAU,CAAC;SAC1B,CAAC;KACL;IAuBD;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM;CAKhC;AAED,eAAO,MAAM,eAAe,iBAAwB,CAAC"}
package/dist/main.js CHANGED
@@ -1,38 +1,41 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.startBot = startBot;
4
- exports.stopBots = stopBots;
3
+ exports.botOrchestrator = void 0;
5
4
  const promises_1 = require("fs/promises");
6
5
  const botInstance_1 = require("./entities/botInstance");
7
- const bots = [];
8
- /**
9
- * Starts bot
10
- */
11
- async function startBot(options) {
12
- const token = await (0, promises_1.readFile)(options.tokenFilePath, 'utf8');
13
- const bot = new botInstance_1.BotInstance({
14
- name: options.name,
15
- token,
16
- commands: options.commands,
17
- scheduled: options.scheduled,
18
- chats: options.chats,
19
- storagePath: options.storagePath,
20
- scheduledPeriod: options.scheduledPeriod,
21
- verboseLoggingForIncomingMessage: options.verboseLoggingForIncomingMessage,
22
- services: {
23
- storageClient: options.services?.storageClient,
24
- logger: options.services?.logger,
25
- scheduler: options.services?.scheduler
6
+ class BotOrchestrator {
7
+ constructor() {
8
+ this.bots = [];
9
+ }
10
+ /**
11
+ * Starts bot
12
+ */
13
+ async startBot(options) {
14
+ const token = await (0, promises_1.readFile)(options.tokenFilePath, 'utf8');
15
+ const bot = new botInstance_1.BotInstance({
16
+ name: options.name,
17
+ token,
18
+ actions: options.actions,
19
+ chats: options.chats,
20
+ storagePath: options.storagePath,
21
+ scheduledPeriod: options.scheduledPeriod,
22
+ verboseLoggingForIncomingMessage: options.verboseLoggingForIncomingMessage,
23
+ services: {
24
+ storageClient: options.services?.storageClient,
25
+ logger: options.services?.logger,
26
+ scheduler: options.services?.scheduler
27
+ }
28
+ });
29
+ this.bots.push(bot);
30
+ return bot;
31
+ }
32
+ /**
33
+ * Terminates all scheduled tasks, closes storage connections and stops all bots.
34
+ */
35
+ async stopBots(reason) {
36
+ for (const bot of this.bots) {
37
+ await bot.stop(reason);
26
38
  }
27
- });
28
- bots.push(bot);
29
- return bot;
30
- }
31
- /**
32
- * Terminates all scheduled tasks, closes storage connections and stops all bots.
33
- */
34
- async function stopBots(reason) {
35
- for (const bot of bots) {
36
- await bot.stop(reason);
37
39
  }
38
40
  }
41
+ exports.botOrchestrator = new BotOrchestrator();
@@ -1,6 +1,6 @@
1
1
  import { IStorageClient } from '../types/storage';
2
2
  import { IActionState } from '../types/actionState';
3
- import { IActionWithState, ActionKey } from '../types/actionWithState';
3
+ import { IActionWithState, ActionKey } from '../types/statefulAction';
4
4
  export declare class JsonFileStorage implements IStorageClient {
5
5
  private readonly locks;
6
6
  private readonly cache;
@@ -1 +1 @@
1
- {"version":3,"file":"jsonFileStorage.d.ts","sourceRoot":"","sources":["../../services/jsonFileStorage.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,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,QAAQ,CAAC,KAAK,CAAmC;IACzD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA4C;IAClE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG7B,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,CAAC,YAAY,CAAC,EAAE,EACzC,IAAI,CAAC,EAAE,MAAM;YAiBH,IAAI;YAgBJ,YAAY;YAqBZ,IAAI;IAgBlB,OAAO,CAAC,eAAe;IAOjB,IAAI,CAAC,YAAY,SAAS,YAAY,EAAE,GAAG,EAAE,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AC,SAAS,EAAE,WAAW,EAAE;IA4BhD,cAAc;YAIA,WAAW;YAqBX,eAAe;CA4EhC"}
1
+ {"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO;IAQnB,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE;IA8BhD,cAAc;YAIA,WAAW;YAqBX,eAAe;CAmFhC"}
@@ -23,7 +23,9 @@ class TelegramApiService {
23
23
  await this.processResponse(response);
24
24
  }
25
25
  catch (error) {
26
- this.logger.errorWithTraceId(this.botName, response.traceId, response.chatInfo.name, error, response);
26
+ this.logger.errorWithTraceId(this.botName, response.traceId, 'chatInfo' in response
27
+ ? response.chatInfo.name
28
+ : 'Unknown', error, response);
27
29
  }
28
30
  },
29
31
  priority: response.createdAt + offset
@@ -82,6 +84,9 @@ class TelegramApiService {
82
84
  state.pinnedMessages = state.pinnedMessages.filter((x) => x != response.messageId);
83
85
  });
84
86
  break;
87
+ case 'inlineQuery':
88
+ await this.telegram.answerInlineQuery(response.queryId, response.queryResults, { cache_time: 3600 });
89
+ break;
85
90
  case 'delay':
86
91
  break;
87
92
  }
@@ -1,7 +1,11 @@
1
1
  import { ChatContext } from '../entities/context/chatContext';
2
+ import { InlineQueryContext } from '../entities/context/inlineQueryContext';
2
3
  import { MessageContext } from '../entities/context/messageContext';
3
4
  import { IActionState } from './actionState';
4
5
  import { CachedValueAccessor } from './cachedValueAccessor';
6
+ export type InlineQueryHandler = (
7
+ /** Context of inline query executed in chat, in response to a message. */
8
+ ctx: InlineQueryContext) => Promise<void>;
5
9
  export type CommandHandler<TActionState extends IActionState> = (
6
10
  /** Context of action executed in chat, in response to a message. */
7
11
  ctx: MessageContext<TActionState>,
@@ -1 +1 @@
1
- {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../types/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI;AAC5D,oEAAoE;AACpE,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;AACjC,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI;AAC9D,0CAA0C;AAC1C,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;AAC9B,yIAAyI;AACzI,SAAS,EAAE,mBAAmB;AAC9B,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../types/handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,MAAM,kBAAkB,GAAG;AAC7B,0EAA0E;AAC1E,GAAG,EAAE,kBAAkB,KACtB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI;AAC5D,oEAAoE;AACpE,GAAG,EAAE,cAAc,CAAC,YAAY,CAAC;AACjC,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,MAAM,gBAAgB,CAAC,YAAY,SAAS,YAAY,IAAI;AAC9D,0CAA0C;AAC1C,GAAG,EAAE,WAAW,CAAC,YAAY,CAAC;AAC9B,yIAAyI;AACzI,SAAS,EAAE,mBAAmB;AAC9B,yCAAyC;AACzC,KAAK,EAAE,YAAY,KAClB,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -1,12 +1,13 @@
1
1
  import { ChatInfo } from '../dtos/chatInfo';
2
2
  import { DelayResponse } from '../dtos/responses/delay';
3
3
  import { ImageMessage } from '../dtos/responses/imageMessage';
4
+ import { InlineQueryResponse } from '../dtos/responses/inlineQueryResponse';
4
5
  import { Reaction } from '../dtos/responses/reaction';
5
6
  import { TextMessage } from '../dtos/responses/textMessage';
6
7
  import { UnpinResponse } from '../dtos/responses/unpin';
7
8
  import { VideoMessage } from '../dtos/responses/videoMessage';
8
9
  import { IActionState } from './actionState';
9
- import { IActionWithState } from './actionWithState';
10
+ import { IActionWithState } from './statefulAction';
10
11
  import { TraceId } from './trace';
11
12
  export declare const BotResponseTypes: {
12
13
  readonly unpin: "unpin";
@@ -15,8 +16,9 @@ export declare const BotResponseTypes: {
15
16
  readonly video: "video";
16
17
  readonly react: "react";
17
18
  readonly delay: "delay";
19
+ readonly inlineQuery: "inlineQuery";
18
20
  };
19
- export type BotResponse = UnpinResponse | Reaction | TextMessage | VideoMessage | DelayResponse | ImageMessage;
21
+ export type BotResponse = UnpinResponse | Reaction | TextMessage | VideoMessage | DelayResponse | InlineQueryResponse | ImageMessage;
20
22
  export interface IChatResponse {
21
23
  readonly kind: keyof typeof BotResponseTypes;
22
24
  readonly chatInfo: ChatInfo;
@@ -1 +1 @@
1
- {"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,S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AQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC/B"}
@@ -7,5 +7,6 @@ exports.BotResponseTypes = {
7
7
  image: 'image',
8
8
  video: 'video',
9
9
  react: 'react',
10
- delay: 'delay'
10
+ delay: 'delay',
11
+ inlineQuery: 'inlineQuery'
11
12
  };
@@ -0,0 +1,9 @@
1
+ import { IActionState } from './actionState';
2
+ export type ActionKey = string & {
3
+ __brand: 'actionKey';
4
+ };
5
+ export interface IActionWithState<TActionState extends IActionState> {
6
+ readonly key: ActionKey;
7
+ readonly stateConstructor: () => TActionState;
8
+ }
9
+ //# sourceMappingURL=statefulAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statefulAction.d.ts","sourceRoot":"","sources":["../../types/statefulAction.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,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,YAAY,CAAC;CACjD"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ import { ActionKey } from './statefulAction';
2
+ export interface IActionWithoutState {
3
+ readonly key: ActionKey;
4
+ }
5
+ //# sourceMappingURL=statelessAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statelessAction.d.ts","sourceRoot":"","sources":["../../types/statelessAction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC;CAC3B"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,5 @@
1
1
  import { IActionState } from './actionState';
2
- import { ActionKey, IActionWithState } from './actionWithState';
2
+ import { ActionKey, IActionWithState } from './statefulAction';
3
3
  export interface IStorageClient {
4
4
  updateStateFor<TActionState extends IActionState>(action: IActionWithState<TActionState>, chatId: number, update: (state: TActionState) => Promise<void>): Promise<void>;
5
5
  close(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../types/storage.ts"],"names":[],"mappings":"AAAA,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,CAAC,YAAY,CAAC,EACtC,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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,CAAC,CAAC;IACjB,cAAc,CAAC,YAAY,SAAS,YAAY,EAC5C,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,MAAM,EAAE,MAAM,GACf,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB,yBAAyB,CAAC,YAAY,SAAS,YAAY,EACvD,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,YAAY,GACpB,OAAO,CAAC,IAAI,CAAC,CAAC;CACpB"}
@@ -0,0 +1,20 @@
1
+ import { TraceId } from '../types/trace';
2
+
3
+ export class IncomingInlineQuery {
4
+ readonly queryId: string;
5
+ readonly query: string;
6
+ readonly userId: number;
7
+ readonly traceId: TraceId;
8
+
9
+ constructor(
10
+ queryId: string,
11
+ query: string,
12
+ userId: number,
13
+ traceId: TraceId
14
+ ) {
15
+ this.queryId = queryId;
16
+ this.query = query;
17
+ this.userId = userId;
18
+ this.traceId = traceId;
19
+ }
20
+ }
@@ -1,5 +1,5 @@
1
1
  import { IActionState } from '../../types/actionState';
2
- import { IActionWithState } from '../../types/actionWithState';
2
+ import { IActionWithState } from '../../types/statefulAction';
3
3
  import { BotResponseTypes, IChatResponse } from '../../types/response';
4
4
  import { Milliseconds } from '../../types/timeValues';
5
5
  import { TraceId } from '../../types/trace';
@@ -1,7 +1,7 @@
1
1
  import { InputFile } from 'telegraf/types';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
- import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionWithState } from '../../types/statefulAction';
5
5
  import { IActionState } from '../../types/actionState';
6
6
  import { ChatInfo } from '../chatInfo';
7
7
  import { TraceId } from '../../types/trace';
@@ -0,0 +1,26 @@
1
+ import { InlineQueryResult } from 'telegraf/types';
2
+ import { InlineQueryAction } from '../../entities/actions/inlineQueryAction';
3
+ import { BotResponseTypes } from '../../types/response';
4
+ import { TraceId } from '../../types/trace';
5
+
6
+ export class InlineQueryResponse {
7
+ readonly kind = BotResponseTypes.inlineQuery;
8
+ readonly createdAt = Date.now();
9
+
10
+ readonly queryId: string;
11
+ readonly traceId: TraceId;
12
+ readonly action: InlineQueryAction;
13
+ readonly queryResults: InlineQueryResult[];
14
+
15
+ constructor(
16
+ queryResult: InlineQueryResult[],
17
+ queryId: string,
18
+ traceId: TraceId,
19
+ action: InlineQueryAction
20
+ ) {
21
+ this.queryResults = queryResult;
22
+ this.queryId = queryId;
23
+ this.traceId = traceId;
24
+ this.action = action;
25
+ }
26
+ }
@@ -1,6 +1,6 @@
1
1
  import { TelegramEmoji } from 'telegraf/types';
2
2
  import { BotResponseTypes, IChatResponse } from '../../types/response';
3
- import { IActionWithState } from '../../types/actionWithState';
3
+ import { IActionWithState } from '../../types/statefulAction';
4
4
  import { IActionState } from '../../types/actionState';
5
5
  import { ChatInfo } from '../chatInfo';
6
6
  import { TraceId } from '../../types/trace';
@@ -1,6 +1,6 @@
1
1
  import { TextMessageSendingOptions } from '../../types/messageSendingOptions';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
- import { IActionWithState } from '../../types/actionWithState';
3
+ import { IActionWithState } from '../../types/statefulAction';
4
4
  import { IActionState } from '../../types/actionState';
5
5
  import { ChatInfo } from '../chatInfo';
6
6
  import { TraceId } from '../../types/trace';
@@ -1,5 +1,5 @@
1
1
  import { BotResponseTypes, IChatResponse } from '../../types/response';
2
- import { IActionWithState } from '../../types/actionWithState';
2
+ import { IActionWithState } from '../../types/statefulAction';
3
3
  import { IActionState } from '../../types/actionState';
4
4
  import { ChatInfo } from '../chatInfo';
5
5
  import { TraceId } from '../../types/trace';
@@ -1,7 +1,7 @@
1
1
  import { InputFile } from 'telegraf/types';
2
2
  import { BotResponseTypes, IReplyMessage } from '../../types/response';
3
3
  import { MessageSendingOptions } from '../../types/messageSendingOptions';
4
- import { IActionWithState } from '../../types/actionWithState';
4
+ import { IActionWithState } from '../../types/statefulAction';
5
5
  import { IActionState } from '../../types/actionState';
6
6
  import { ChatInfo } from '../chatInfo';
7
7
  import { TraceId } from '../../types/trace';
@@ -5,7 +5,7 @@ import { Seconds } from '../../types/timeValues';
5
5
  import { secondsToMilliseconds } from '../../helpers/timeConvertions';
6
6
  import { toArray } from '../../helpers/toArray';
7
7
  import { IActionState } from '../../types/actionState';
8
- import { IActionWithState, ActionKey } from '../../types/actionWithState';
8
+ import { IActionWithState, ActionKey } from '../../types/statefulAction';
9
9
  import { CommandTriggerCheckResult } from '../../dtos/commandTriggerCheckResult';
10
10
  import { MessageContext } from '../context/messageContext';
11
11
  import { CommandTrigger } from '../../types/commandTrigger';