chz-telegram-bot 0.5.1 → 0.5.3

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 (222) hide show
  1. package/dtos/chatHistoryMessage.ts +9 -1
  2. package/entities/botInstance.ts +1 -1
  3. package/entities/context/messageContext.ts +3 -3
  4. package/entities/context/replyContext.ts +3 -3
  5. package/{eslint.config.js → eslint.config.ts} +8 -5
  6. package/index.ts +3 -0
  7. package/package.json +38 -37
  8. package/services/actionProcessors/commandActionProcessor.ts +7 -7
  9. package/services/jsonFileStorage.ts +1 -1
  10. package/services/nodeTimeoutScheduler.ts +2 -2
  11. package/tsconfig.json +2 -2
  12. package/bun.lock +0 -301
  13. package/dist/builtin/helpAction.d.ts +0 -2
  14. package/dist/builtin/helpAction.d.ts.map +0 -1
  15. package/dist/builtin/helpAction.js +0 -17
  16. package/dist/dtos/chatHistoryMessage.d.ts +0 -13
  17. package/dist/dtos/chatHistoryMessage.d.ts.map +0 -1
  18. package/dist/dtos/chatHistoryMessage.js +0 -20
  19. package/dist/dtos/chatInfo.d.ts +0 -17
  20. package/dist/dtos/chatInfo.d.ts.map +0 -1
  21. package/dist/dtos/chatInfo.js +0 -20
  22. package/dist/dtos/commandTriggerCheckResult.d.ts +0 -24
  23. package/dist/dtos/commandTriggerCheckResult.d.ts.map +0 -1
  24. package/dist/dtos/commandTriggerCheckResult.js +0 -38
  25. package/dist/dtos/cooldownInfo.d.ts +0 -13
  26. package/dist/dtos/cooldownInfo.d.ts.map +0 -1
  27. package/dist/dtos/cooldownInfo.js +0 -16
  28. package/dist/dtos/incomingMessage.d.ts +0 -19
  29. package/dist/dtos/incomingMessage.d.ts.map +0 -1
  30. package/dist/dtos/incomingMessage.js +0 -67
  31. package/dist/dtos/incomingQuery.d.ts +0 -10
  32. package/dist/dtos/incomingQuery.d.ts.map +0 -1
  33. package/dist/dtos/incomingQuery.js +0 -18
  34. package/dist/dtos/messageInfo.d.ts +0 -22
  35. package/dist/dtos/messageInfo.d.ts.map +0 -1
  36. package/dist/dtos/messageInfo.js +0 -24
  37. package/dist/dtos/propertyProviderSets.d.ts +0 -16
  38. package/dist/dtos/propertyProviderSets.d.ts.map +0 -1
  39. package/dist/dtos/propertyProviderSets.js +0 -2
  40. package/dist/dtos/replyInfo.d.ts +0 -6
  41. package/dist/dtos/replyInfo.d.ts.map +0 -1
  42. package/dist/dtos/replyInfo.js +0 -12
  43. package/dist/dtos/responses/delay.d.ts +0 -16
  44. package/dist/dtos/responses/delay.d.ts.map +0 -1
  45. package/dist/dtos/responses/delay.js +0 -19
  46. package/dist/dtos/responses/imageMessage.d.ts +0 -22
  47. package/dist/dtos/responses/imageMessage.d.ts.map +0 -1
  48. package/dist/dtos/responses/imageMessage.js +0 -25
  49. package/dist/dtos/responses/inlineQueryResponse.d.ts +0 -13
  50. package/dist/dtos/responses/inlineQueryResponse.d.ts.map +0 -1
  51. package/dist/dtos/responses/inlineQueryResponse.js +0 -19
  52. package/dist/dtos/responses/reaction.d.ts +0 -16
  53. package/dist/dtos/responses/reaction.d.ts.map +0 -1
  54. package/dist/dtos/responses/reaction.js +0 -21
  55. package/dist/dtos/responses/textMessage.d.ts +0 -23
  56. package/dist/dtos/responses/textMessage.d.ts.map +0 -1
  57. package/dist/dtos/responses/textMessage.js +0 -28
  58. package/dist/dtos/responses/unpin.d.ts +0 -15
  59. package/dist/dtos/responses/unpin.d.ts.map +0 -1
  60. package/dist/dtos/responses/unpin.js +0 -19
  61. package/dist/dtos/responses/videoMessage.d.ts +0 -22
  62. package/dist/dtos/responses/videoMessage.d.ts.map +0 -1
  63. package/dist/dtos/responses/videoMessage.js +0 -25
  64. package/dist/dtos/userInfo.d.ts +0 -12
  65. package/dist/dtos/userInfo.d.ts.map +0 -1
  66. package/dist/dtos/userInfo.js +0 -16
  67. package/dist/entities/actions/commandAction.d.ts +0 -31
  68. package/dist/entities/actions/commandAction.d.ts.map +0 -1
  69. package/dist/entities/actions/commandAction.js +0 -146
  70. package/dist/entities/actions/inlineQueryAction.d.ts +0 -14
  71. package/dist/entities/actions/inlineQueryAction.d.ts.map +0 -1
  72. package/dist/entities/actions/inlineQueryAction.js +0 -47
  73. package/dist/entities/actions/replyCaptureAction.d.ts +0 -15
  74. package/dist/entities/actions/replyCaptureAction.d.ts.map +0 -1
  75. package/dist/entities/actions/replyCaptureAction.js +0 -62
  76. package/dist/entities/actions/scheduledAction.d.ts +0 -24
  77. package/dist/entities/actions/scheduledAction.d.ts.map +0 -1
  78. package/dist/entities/actions/scheduledAction.js +0 -79
  79. package/dist/entities/botInstance.d.ts +0 -37
  80. package/dist/entities/botInstance.d.ts.map +0 -1
  81. package/dist/entities/botInstance.js +0 -41
  82. package/dist/entities/cachedStateFactory.d.ts +0 -7
  83. package/dist/entities/cachedStateFactory.d.ts.map +0 -1
  84. package/dist/entities/cachedStateFactory.js +0 -12
  85. package/dist/entities/context/baseContext.d.ts +0 -39
  86. package/dist/entities/context/baseContext.d.ts.map +0 -1
  87. package/dist/entities/context/baseContext.js +0 -59
  88. package/dist/entities/context/chatContext.d.ts +0 -50
  89. package/dist/entities/context/chatContext.d.ts.map +0 -1
  90. package/dist/entities/context/chatContext.js +0 -69
  91. package/dist/entities/context/inlineQueryContext.d.ts +0 -27
  92. package/dist/entities/context/inlineQueryContext.d.ts.map +0 -1
  93. package/dist/entities/context/inlineQueryContext.js +0 -33
  94. package/dist/entities/context/messageContext.d.ts +0 -92
  95. package/dist/entities/context/messageContext.d.ts.map +0 -1
  96. package/dist/entities/context/messageContext.js +0 -120
  97. package/dist/entities/context/replyContext.d.ts +0 -89
  98. package/dist/entities/context/replyContext.d.ts.map +0 -1
  99. package/dist/entities/context/replyContext.js +0 -128
  100. package/dist/entities/states/actionStateBase.d.ts +0 -6
  101. package/dist/entities/states/actionStateBase.d.ts.map +0 -1
  102. package/dist/entities/states/actionStateBase.js +0 -8
  103. package/dist/entities/taskRecord.d.ts +0 -8
  104. package/dist/entities/taskRecord.d.ts.map +0 -1
  105. package/dist/entities/taskRecord.js +0 -14
  106. package/dist/helpers/builders/commandActionBuilder.d.ts +0 -100
  107. package/dist/helpers/builders/commandActionBuilder.d.ts.map +0 -1
  108. package/dist/helpers/builders/commandActionBuilder.js +0 -151
  109. package/dist/helpers/builders/inlineQueryActionBuilder.d.ts +0 -37
  110. package/dist/helpers/builders/inlineQueryActionBuilder.d.ts.map +0 -1
  111. package/dist/helpers/builders/inlineQueryActionBuilder.js +0 -54
  112. package/dist/helpers/builders/scheduledActionBuilder.d.ts +0 -68
  113. package/dist/helpers/builders/scheduledActionBuilder.d.ts.map +0 -1
  114. package/dist/helpers/builders/scheduledActionBuilder.js +0 -100
  115. package/dist/helpers/mapUtils.d.ts +0 -10
  116. package/dist/helpers/mapUtils.d.ts.map +0 -1
  117. package/dist/helpers/mapUtils.js +0 -17
  118. package/dist/helpers/noop.d.ts +0 -9
  119. package/dist/helpers/noop.d.ts.map +0 -1
  120. package/dist/helpers/noop.js +0 -21
  121. package/dist/helpers/objectFromEntries.d.ts +0 -2
  122. package/dist/helpers/objectFromEntries.d.ts.map +0 -1
  123. package/dist/helpers/objectFromEntries.js +0 -7
  124. package/dist/helpers/timeConvertions.d.ts +0 -5
  125. package/dist/helpers/timeConvertions.d.ts.map +0 -1
  126. package/dist/helpers/timeConvertions.js +0 -14
  127. package/dist/helpers/toArray.d.ts +0 -2
  128. package/dist/helpers/toArray.d.ts.map +0 -1
  129. package/dist/helpers/toArray.js +0 -6
  130. package/dist/helpers/traceFactory.d.ts +0 -3
  131. package/dist/helpers/traceFactory.d.ts.map +0 -1
  132. package/dist/helpers/traceFactory.js +0 -6
  133. package/dist/index.d.ts +0 -24
  134. package/dist/index.d.ts.map +0 -1
  135. package/dist/index.js +0 -41
  136. package/dist/main.d.ts +0 -52
  137. package/dist/main.d.ts.map +0 -1
  138. package/dist/main.js +0 -37
  139. package/dist/services/actionProcessingService.d.ts +0 -25
  140. package/dist/services/actionProcessingService.d.ts.map +0 -1
  141. package/dist/services/actionProcessingService.js +0 -54
  142. package/dist/services/actionProcessors/baseProcessor.d.ts +0 -18
  143. package/dist/services/actionProcessors/baseProcessor.d.ts.map +0 -1
  144. package/dist/services/actionProcessors/baseProcessor.js +0 -33
  145. package/dist/services/actionProcessors/commandActionProcessor.d.ts +0 -20
  146. package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +0 -1
  147. package/dist/services/actionProcessors/commandActionProcessor.js +0 -119
  148. package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +0 -11
  149. package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +0 -1
  150. package/dist/services/actionProcessors/inlineQueryActionProcessor.js +0 -65
  151. package/dist/services/actionProcessors/scheduledActionProcessor.d.ts +0 -17
  152. package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +0 -1
  153. package/dist/services/actionProcessors/scheduledActionProcessor.js +0 -63
  154. package/dist/services/jsonFileStorage.d.ts +0 -23
  155. package/dist/services/jsonFileStorage.d.ts.map +0 -1
  156. package/dist/services/jsonFileStorage.js +0 -113
  157. package/dist/services/jsonLogger.d.ts +0 -11
  158. package/dist/services/jsonLogger.d.ts.map +0 -1
  159. package/dist/services/jsonLogger.js +0 -70
  160. package/dist/services/nodeTimeoutScheduler.d.ts +0 -13
  161. package/dist/services/nodeTimeoutScheduler.d.ts.map +0 -1
  162. package/dist/services/nodeTimeoutScheduler.js +0 -35
  163. package/dist/services/responseProcessingQueue.d.ts +0 -12
  164. package/dist/services/responseProcessingQueue.d.ts.map +0 -1
  165. package/dist/services/responseProcessingQueue.js +0 -41
  166. package/dist/services/telegramApi.d.ts +0 -23
  167. package/dist/services/telegramApi.d.ts.map +0 -1
  168. package/dist/services/telegramApi.js +0 -137
  169. package/dist/types/action.d.ts +0 -14
  170. package/dist/types/action.d.ts.map +0 -1
  171. package/dist/types/action.js +0 -2
  172. package/dist/types/actionState.d.ts +0 -5
  173. package/dist/types/actionState.d.ts.map +0 -1
  174. package/dist/types/actionState.js +0 -2
  175. package/dist/types/cachedValueAccessor.d.ts +0 -2
  176. package/dist/types/cachedValueAccessor.d.ts.map +0 -1
  177. package/dist/types/cachedValueAccessor.js +0 -2
  178. package/dist/types/capture.d.ts +0 -24
  179. package/dist/types/capture.d.ts.map +0 -1
  180. package/dist/types/capture.js +0 -2
  181. package/dist/types/commandCondition.d.ts +0 -8
  182. package/dist/types/commandCondition.d.ts.map +0 -1
  183. package/dist/types/commandCondition.js +0 -2
  184. package/dist/types/commandTrigger.d.ts +0 -2
  185. package/dist/types/commandTrigger.d.ts.map +0 -1
  186. package/dist/types/commandTrigger.js +0 -2
  187. package/dist/types/externalAliases.d.ts +0 -11
  188. package/dist/types/externalAliases.d.ts.map +0 -1
  189. package/dist/types/externalAliases.js +0 -2
  190. package/dist/types/handlers.d.ts +0 -21
  191. package/dist/types/handlers.d.ts.map +0 -1
  192. package/dist/types/handlers.js +0 -2
  193. package/dist/types/inputFile.d.ts +0 -5
  194. package/dist/types/inputFile.d.ts.map +0 -1
  195. package/dist/types/inputFile.js +0 -2
  196. package/dist/types/logger.d.ts +0 -13
  197. package/dist/types/logger.d.ts.map +0 -1
  198. package/dist/types/logger.js +0 -2
  199. package/dist/types/messageSendingOptions.d.ts +0 -9
  200. package/dist/types/messageSendingOptions.d.ts.map +0 -1
  201. package/dist/types/messageSendingOptions.js +0 -2
  202. package/dist/types/messageTypes.d.ts +0 -20
  203. package/dist/types/messageTypes.d.ts.map +0 -1
  204. package/dist/types/messageTypes.js +0 -21
  205. package/dist/types/propertyProvider.d.ts +0 -8
  206. package/dist/types/propertyProvider.d.ts.map +0 -1
  207. package/dist/types/propertyProvider.js +0 -2
  208. package/dist/types/response.d.ts +0 -39
  209. package/dist/types/response.d.ts.map +0 -1
  210. package/dist/types/response.js +0 -12
  211. package/dist/types/scheduler.d.ts +0 -7
  212. package/dist/types/scheduler.d.ts.map +0 -1
  213. package/dist/types/scheduler.js +0 -2
  214. package/dist/types/storage.d.ts +0 -11
  215. package/dist/types/storage.d.ts.map +0 -1
  216. package/dist/types/storage.js +0 -2
  217. package/dist/types/timeValues.d.ts +0 -15
  218. package/dist/types/timeValues.d.ts.map +0 -1
  219. package/dist/types/timeValues.js +0 -2
  220. package/dist/types/trace.d.ts +0 -6
  221. package/dist/types/trace.d.ts.map +0 -1
  222. package/dist/types/trace.js +0 -2
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BotInstance = void 0;
4
- const jsonFileStorage_1 = require("../services/jsonFileStorage");
5
- const jsonLogger_1 = require("../services/jsonLogger");
6
- const nodeTimeoutScheduler_1 = require("../services/nodeTimeoutScheduler");
7
- const traceFactory_1 = require("../helpers/traceFactory");
8
- const actionProcessingService_1 = require("../services/actionProcessingService");
9
- class BotInstance {
10
- storage;
11
- scheduler;
12
- logger;
13
- actionProcessingService;
14
- name;
15
- constructor(options) {
16
- const actions = [
17
- ...options.actions.commands,
18
- ...options.actions.scheduled
19
- ];
20
- this.name = options.name;
21
- this.logger = options.services?.logger ?? new jsonLogger_1.JsonLogger();
22
- this.scheduler =
23
- options.services?.scheduler ??
24
- new nodeTimeoutScheduler_1.NodeTimeoutScheduler(this.logger);
25
- this.storage =
26
- options.services?.storageClient ??
27
- new jsonFileStorage_1.JsonFileStorage(options.name, actions, options.storagePath);
28
- this.actionProcessingService = new actionProcessingService_1.ActionProcessingService(this.name, options.chats, this.storage, this.scheduler, this.logger);
29
- }
30
- async start(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage) {
31
- this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Start'), 'System', 'Starting bot...');
32
- await this.actionProcessingService.initialize(token, actions, scheduledPeriod, verboseLoggingForIncomingMessage);
33
- }
34
- async stop() {
35
- this.logger.logWithTraceId(this.name, (0, traceFactory_1.createTrace)(this, this.name, 'Stop'), 'System', 'Stopping bot...');
36
- this.scheduler.stopAll();
37
- await this.storage.close();
38
- await this.actionProcessingService.stop();
39
- }
40
- }
41
- exports.BotInstance = BotInstance;
@@ -1,7 +0,0 @@
1
- import { Hours } from '../types/timeValues';
2
- export declare class CachedStateFactory {
3
- readonly getValue: () => Promise<unknown>;
4
- readonly invalidationTimeoutInHours: Hours;
5
- constructor(itemFactory: () => Promise<unknown>, invalidationTimeout: Hours);
6
- }
7
- //# sourceMappingURL=cachedStateFactory.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cachedStateFactory.d.ts","sourceRoot":"","sources":["../../entities/cachedStateFactory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,qBAAa,kBAAkB;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1C,QAAQ,CAAC,0BAA0B,EAAE,KAAK,CAAC;gBAGvC,WAAW,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EACnC,mBAAmB,EAAE,KAAK;CAKjC"}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CachedStateFactory = void 0;
4
- class CachedStateFactory {
5
- getValue;
6
- invalidationTimeoutInHours;
7
- constructor(itemFactory, invalidationTimeout) {
8
- this.getValue = itemFactory;
9
- this.invalidationTimeoutInHours = invalidationTimeout;
10
- }
11
- }
12
- exports.CachedStateFactory = CachedStateFactory;
@@ -1,39 +0,0 @@
1
- import { ChatInfo } from '../../dtos/chatInfo';
2
- import { IAction, IActionWithState } from '../../types/action';
3
- import { IActionState } from '../../types/actionState';
4
- import { ICaptureController } from '../../types/capture';
5
- import { IScopedLogger } from '../../types/logger';
6
- import { BotResponse, IReplyResponse } from '../../types/response';
7
- import { IScheduler } from '../../types/scheduler';
8
- import { IStorageClient } from '../../types/storage';
9
- import { TraceId } from '../../types/trace';
10
- export type BaseContextPropertiesToOmit = 'action' | 'isInitialized' | 'storage' | 'scheduler' | 'logger' | 'responses' | 'traceId';
11
- export declare abstract class BaseContextInternal<TAction extends IAction> {
12
- isInitialized: boolean;
13
- private _responses;
14
- action: TAction;
15
- /** Storage client instance for the bot executing this action. */
16
- readonly storage: IStorageClient;
17
- /** Scheduler instance for the bot executing this action */
18
- readonly scheduler: IScheduler;
19
- logger: IScopedLogger;
20
- /** Trace id of a action execution. */
21
- traceId: TraceId;
22
- /** Name of a bot that executes this action. */
23
- botName: string;
24
- /** Chat information. */
25
- chatInfo: ChatInfo;
26
- get actionKey(): import("../../types/action").ActionKey;
27
- /** Ordered collection of responses to be processed */
28
- get responses(): BotResponse[];
29
- set responses(value: BotResponse[]);
30
- constructor(storage: IStorageClient, scheduler: IScheduler);
31
- protected createCaptureController(response: IReplyResponse): ICaptureController;
32
- /**
33
- * Loads state of another action for current chat.
34
- * @param action Action to load state of.
35
- * @template TAnotherActionState - Type of a state that is used by another action.
36
- */
37
- loadStateOf<TAnotherActionState extends IActionState>(action: IActionWithState<TAnotherActionState>): Promise<Readonly<TAnotherActionState>>;
38
- }
39
- //# sourceMappingURL=baseContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"baseContext.d.ts","sourceRoot":"","sources":["../../../entities/context/baseContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAG5C,MAAM,MAAM,2BAA2B,GACjC,QAAQ,GACR,eAAe,GACf,SAAS,GACT,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,CAAC;AAEhB,8BAAsB,mBAAmB,CAAC,OAAO,SAAS,OAAO;IAC7D,aAAa,UAAS;IACtB,OAAO,CAAC,UAAU,CAAqB;IAEvC,MAAM,EAAG,OAAO,CAAC;IAEjB,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAC;IAC/B,MAAM,EAAG,aAAa,CAAC;IACvB,sCAAsC;IACtC,OAAO,EAAG,OAAO,CAAC;IAClB,+CAA+C;IAC/C,OAAO,EAAG,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAG,QAAQ,CAAC;IACpB,IAAI,SAAS,2CAEZ;IAED,uDAAuD;IACvD,IAAW,SAAS,IAAI,WAAW,EAAE,CAEpC;IACD,IAAW,SAAS,CAAC,KAAK,EAAE,WAAW,EAAE,EAExC;gBAEW,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,UAAU;IAK1D,SAAS,CAAC,uBAAuB,CAC7B,QAAQ,EAAE,cAAc,GACzB,kBAAkB;IAmBrB;;;;OAIG;IACG,WAAW,CAAC,mBAAmB,SAAS,YAAY,EACtD,MAAM,EAAE,gBAAgB,CAAC,mBAAmB,CAAC;CAWpD"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseContextInternal = void 0;
4
- class BaseContextInternal {
5
- isInitialized = false;
6
- _responses = [];
7
- action;
8
- /** Storage client instance for the bot executing this action. */
9
- storage;
10
- /** Scheduler instance for the bot executing this action */
11
- scheduler;
12
- logger;
13
- /** Trace id of a action execution. */
14
- traceId;
15
- /** Name of a bot that executes this action. */
16
- botName;
17
- /** Chat information. */
18
- chatInfo;
19
- get actionKey() {
20
- return this.action.key;
21
- }
22
- /** Ordered collection of responses to be processed */
23
- get responses() {
24
- return this._responses;
25
- }
26
- set responses(value) {
27
- this._responses = value;
28
- }
29
- constructor(storage, scheduler) {
30
- this.storage = storage;
31
- this.scheduler = scheduler;
32
- }
33
- createCaptureController(response) {
34
- return {
35
- captureReplies: (trigger, handler, abortController) => {
36
- response.captures.push({
37
- trigger,
38
- handler,
39
- abortController: abortController ?? new AbortController(),
40
- action: this.action
41
- });
42
- }
43
- };
44
- }
45
- /**
46
- * Loads state of another action for current chat.
47
- * @param action Action to load state of.
48
- * @template TAnotherActionState - Type of a state that is used by another action.
49
- */
50
- async loadStateOf(action) {
51
- const allStates = await this.storage.load(action.key);
52
- const stateForChat = allStates[this.chatInfo.id];
53
- if (!stateForChat) {
54
- return Object.freeze(action.stateConstructor());
55
- }
56
- return Object.freeze(stateForChat);
57
- }
58
- }
59
- exports.BaseContextInternal = BaseContextInternal;
@@ -1,50 +0,0 @@
1
- import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
2
- import { IActionWithState } from '../../types/action';
3
- import { IActionState } from '../../types/actionState';
4
- import { Milliseconds } from '../../types/timeValues';
5
- import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
6
- import { ScheduledAction } from '../actions/scheduledAction';
7
- export type ChatContext<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> = Omit<ChatContextInternal<TActionState, TAction>, BaseContextPropertiesToOmit>;
8
- /**
9
- * Context of action executed in chat.
10
- */
11
- export declare class ChatContextInternal<TActionState extends IActionState, TAction extends IActionWithState<TActionState> = ScheduledAction<TActionState>> extends BaseContextInternal<TAction> {
12
- /**
13
- * Collection of actions that send something to chat as a standalone message.
14
- */
15
- send: {
16
- /**
17
- * Sends text message to chat after action execution is finished.
18
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
19
- * @param text Message contents.
20
- * @param options Message sending option.
21
- */
22
- text: (text: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
23
- /**
24
- * Sends image message to chat after action execution is finished.
25
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
26
- * @param name Message contents.
27
- * @param options Message sending option.
28
- */
29
- image: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
30
- /**
31
- * Sends video/gif message to chat after action execution is finished.
32
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
33
- * @param name Message contents.
34
- * @param options Message sending option.
35
- */
36
- video: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
37
- };
38
- /**
39
- * Unpins message after action execution is finished.
40
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
41
- * @param messageId Message id.
42
- */
43
- unpinMessage(messageId: number): void;
44
- /**
45
- * Delays next responses by specified amount of time.
46
- * @param delay Delay in milliseconds.
47
- */
48
- wait(delay: Milliseconds): void;
49
- }
50
- //# sourceMappingURL=chatContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAE7D,MAAM,MAAM,WAAW,CACnB,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,IAC9E,IAAI,CACJ,mBAAmB,CAAC,YAAY,EAAE,OAAO,CAAC,EAC1C,2BAA2B,CAC9B,CAAC;AAEF;;GAEG;AACH,qBAAa,mBAAmB,CAC5B,YAAY,SAAS,YAAY,EACjC,OAAO,SAAS,gBAAgB,CAAC,YAAY,CAAC,GAAG,eAAe,CAAC,YAAY,CAAC,CAChF,SAAQ,mBAAmB,CAAC,OAAO,CAAC;IAClC;;OAEG;IACH,IAAI;QACA;;;;;WAKG;qBACU,MAAM,YAAY,yBAAyB;QAexD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;QAerD;;;;;WAKG;sBACW,MAAM,YAAY,qBAAqB;MAcvD;IAEF;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAK3B"}
@@ -1,69 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ChatContextInternal = void 0;
4
- const path_1 = require("path");
5
- const imageMessage_1 = require("../../dtos/responses/imageMessage");
6
- const textMessage_1 = require("../../dtos/responses/textMessage");
7
- const videoMessage_1 = require("../../dtos/responses/videoMessage");
8
- const unpin_1 = require("../../dtos/responses/unpin");
9
- const delay_1 = require("../../dtos/responses/delay");
10
- const baseContext_1 = require("./baseContext");
11
- /**
12
- * Context of action executed in chat.
13
- */
14
- class ChatContextInternal extends baseContext_1.BaseContextInternal {
15
- /**
16
- * Collection of actions that send something to chat as a standalone message.
17
- */
18
- send = {
19
- /**
20
- * Sends text message to chat after action execution is finished.
21
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
22
- * @param text Message contents.
23
- * @param options Message sending option.
24
- */
25
- text: (text, options) => {
26
- const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, undefined, options);
27
- this.responses.push(response);
28
- return this.createCaptureController(response);
29
- },
30
- /**
31
- * Sends image message to chat after action execution is finished.
32
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
33
- * @param name Message contents.
34
- * @param options Message sending option.
35
- */
36
- image: (name, options) => {
37
- const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, undefined, options);
38
- this.responses.push(response);
39
- return this.createCaptureController(response);
40
- },
41
- /**
42
- * Sends video/gif message to chat after action execution is finished.
43
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
44
- * @param name Message contents.
45
- * @param options Message sending option.
46
- */
47
- video: (name, options) => {
48
- const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, undefined, options);
49
- this.responses.push(response);
50
- return this.createCaptureController(response);
51
- }
52
- };
53
- /**
54
- * Unpins message after action execution is finished.
55
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
56
- * @param messageId Message id.
57
- */
58
- unpinMessage(messageId) {
59
- this.responses.push(new unpin_1.UnpinResponse(messageId, this.chatInfo, this.traceId, this.action));
60
- }
61
- /**
62
- * Delays next responses by specified amount of time.
63
- * @param delay Delay in milliseconds.
64
- */
65
- wait(delay) {
66
- this.responses.push(new delay_1.DelayResponse(delay, this.chatInfo, this.traceId, this.action));
67
- }
68
- }
69
- exports.ChatContextInternal = ChatContextInternal;
@@ -1,27 +0,0 @@
1
- import { BotResponse } from '../../types/response';
2
- import { InlineQueryAction } from '../actions/inlineQueryAction';
3
- import { BaseContextInternal, BaseContextPropertiesToOmit } from './baseContext';
4
- import { TelegramInlineQueryResult } from '../../types/externalAliases';
5
- export type InlineQueryContext = Omit<InlineQueryContextInternal, BaseContextPropertiesToOmit | 'queryResults' | 'queryId'>;
6
- export declare class InlineQueryContextInternal extends BaseContextInternal<InlineQueryAction> {
7
- queryResults: TelegramInlineQueryResult[];
8
- /**
9
- * Abort signal to be utilized in query handler.
10
- * Signal will be aborted if new query comes from the same user.
11
- */
12
- abortSignal: AbortSignal;
13
- /** Ordered collection of responses to be processed */
14
- get responses(): BotResponse[];
15
- /** Inline query text */
16
- queryText: string;
17
- /** Internal query id */
18
- queryId: string;
19
- /** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
20
- matchResults: RegExpMatchArray[];
21
- /**
22
- * This result will be shown to user as a response to inline query.
23
- * @param queryResult Inline query result to be shown to user.
24
- */
25
- showInlineQueryResult(queryResult: TelegramInlineQueryResult): void;
26
- }
27
- //# sourceMappingURL=inlineQueryContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inlineQueryContext.d.ts","sourceRoot":"","sources":["../../../entities/context/inlineQueryContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,OAAO,EACH,mBAAmB,EACnB,2BAA2B,EAC9B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AAExE,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACjC,0BAA0B,EAC1B,2BAA2B,GAAG,cAAc,GAAG,SAAS,CAC3D,CAAC;AAEF,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,iBAAiB,CAAC;IAClF,YAAY,EAAE,yBAAyB,EAAE,CAAM;IAC/C;;;OAGG;IACH,WAAW,EAAG,WAAW,CAAC;IAE1B,uDAAuD;IACvD,IAAI,SAAS,IAAI,WAAW,EAAE,CAS7B;IACD,wBAAwB;IACxB,SAAS,EAAG,MAAM,CAAC;IACnB,wBAAwB;IACxB,OAAO,EAAG,MAAM,CAAC;IACjB,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IAEtC;;;OAGG;IACH,qBAAqB,CAAC,WAAW,EAAE,yBAAyB;CAG/D"}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InlineQueryContextInternal = void 0;
4
- const inlineQueryResponse_1 = require("../../dtos/responses/inlineQueryResponse");
5
- const baseContext_1 = require("./baseContext");
6
- class InlineQueryContextInternal extends baseContext_1.BaseContextInternal {
7
- queryResults = [];
8
- /**
9
- * Abort signal to be utilized in query handler.
10
- * Signal will be aborted if new query comes from the same user.
11
- */
12
- abortSignal;
13
- /** Ordered collection of responses to be processed */
14
- get responses() {
15
- return [
16
- new inlineQueryResponse_1.InlineQueryResponse(this.queryResults, this.queryId, this.traceId, this.action)
17
- ];
18
- }
19
- /** Inline query text */
20
- queryText;
21
- /** Internal query id */
22
- queryId;
23
- /** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
24
- matchResults = [];
25
- /**
26
- * This result will be shown to user as a response to inline query.
27
- * @param queryResult Inline query result to be shown to user.
28
- */
29
- showInlineQueryResult(queryResult) {
30
- this.queryResults.push(queryResult);
31
- }
32
- }
33
- exports.InlineQueryContextInternal = InlineQueryContextInternal;
@@ -1,92 +0,0 @@
1
- import { IActionState } from '../../types/actionState';
2
- import { ChatContextInternal } from './chatContext';
3
- import { MessageSendingOptions, TextMessageSendingOptions } from '../../types/messageSendingOptions';
4
- import { CommandAction } from '../actions/commandAction';
5
- import { Seconds } from '../../types/timeValues';
6
- import { BaseContextPropertiesToOmit } from './baseContext';
7
- import { MessageInfo } from '../../dtos/messageInfo';
8
- import { UserInfo } from '../../dtos/userInfo';
9
- import { BotInfo, TelegramEmoji } from '../../types/externalAliases';
10
- export type MessageContext<TActionState extends IActionState> = Omit<MessageContextInternal<TActionState>, BaseContextPropertiesToOmit | 'startCooldown' | 'customCooldown'>;
11
- /**
12
- * Context of action executed in chat, in response to a message
13
- */
14
- export declare class MessageContextInternal<TActionState extends IActionState> extends ChatContextInternal<TActionState, CommandAction<TActionState>> {
15
- /** Information about the user that triggered this action */
16
- userInfo: UserInfo;
17
- /** Information about the message that triggered this action */
18
- messageInfo: MessageInfo;
19
- /** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
20
- matchResults: RegExpMatchArray[];
21
- /** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
22
- startCooldown: boolean;
23
- /** Bot info from Telegram */
24
- botInfo: BotInfo;
25
- customCooldown: Seconds | undefined;
26
- private getQuotePart;
27
- private replyWithText;
28
- private replyWithImage;
29
- private replyWithVideo;
30
- skipCooldown(): void;
31
- startCustomCooldown(customCooldown: Seconds): void;
32
- /**
33
- * Collection of actions that can be done as a reply to a message that triggered this action
34
- */
35
- reply: {
36
- /**
37
- * Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
38
- * If regex is matched, first match will be quoted
39
- */
40
- andQuote: {
41
- /**
42
- * Reply with text message to message that triggered this action after action execution is finished.
43
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
44
- * @param text Message contents.
45
- * @param options Message sending option.
46
- */
47
- withText: (text: string, quote?: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
48
- /**
49
- * Reply with image message to message that triggered this action after action execution is finished.
50
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
51
- * @param text Message contents.
52
- * @param options Message sending option.
53
- */
54
- withImage: (name: string, quote?: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
55
- /**
56
- * Reply with video/gif message to message that triggered this action after action execution is finished.
57
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
58
- * @param text Message contents.
59
- * @param options Message sending option.
60
- */
61
- withVideo: (name: string, quote?: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
62
- };
63
- /**
64
- * Reply with text message to message that triggered this action after action execution is finished.
65
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
66
- * @param text Message contents.
67
- * @param options Message sending option.
68
- */
69
- withText: (text: string, options?: TextMessageSendingOptions) => import("../..").ICaptureController;
70
- /**
71
- * Reply with image message to message that triggered this action after action execution is finished.
72
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
73
- * @param text Message contents.
74
- * @param options Message sending option.
75
- */
76
- withImage: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
77
- /**
78
- * Reply with video/gif message to message that triggered this action after action execution is finished.
79
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
80
- * @param text Message contents.
81
- * @param options Message sending option.
82
- */
83
- withVideo: (name: string, options?: MessageSendingOptions) => import("../..").ICaptureController;
84
- /**
85
- * React to the message that triggered this action after action execution is finished.
86
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
87
- * @param emoji Telegram emoji to react with.
88
- */
89
- withReaction: (emoji: TelegramEmoji) => void;
90
- };
91
- }
92
- //# sourceMappingURL=messageContext.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"messageContext.d.ts","sourceRoot":"","sources":["../../../entities/context/messageContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,MAAM,cAAc,CAAC,YAAY,SAAS,YAAY,IAAI,IAAI,CAChE,sBAAsB,CAAC,YAAY,CAAC,EACpC,2BAA2B,GAAG,eAAe,GAAG,gBAAgB,CACnE,CAAC;AAEF;;GAEG;AACH,qBAAa,sBAAsB,CAC/B,YAAY,SAAS,YAAY,CACnC,SAAQ,mBAAmB,CAAC,YAAY,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;IACpE,4DAA4D;IAC5D,QAAQ,EAAG,QAAQ,CAAC;IACpB,+DAA+D;IAC/D,WAAW,EAAG,WAAW,CAAC;IAC1B,4HAA4H;IAC5H,YAAY,EAAE,gBAAgB,EAAE,CAAM;IACtC,kGAAkG;IAClG,aAAa,EAAE,OAAO,CAAQ;IAC9B,6BAA6B;IAC7B,OAAO,EAAG,OAAO,CAAC;IAClB,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IAEpC,OAAO,CAAC,YAAY;IAQpB,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,cAAc;IAqBtB,YAAY;IAIZ,mBAAmB,CAAC,cAAc,EAAE,OAAO;IAK3C;;OAEG;IACH,KAAK;QACD;;;WAGG;;YAEC;;;;;eAKG;6BAEO,MAAM,UACJ,MAAM,YACJ,yBAAyB;YAEvC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;YAGnC;;;;;eAKG;8BAEO,MAAM,UACJ,MAAM,YACJ,qBAAqB;;QAIvC;;;;;WAKG;yBACc,MAAM,YAAY,yBAAyB;QAE5D;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;;WAKG;0BACe,MAAM,YAAY,qBAAqB;QAGzD;;;;WAIG;8BACmB,aAAa;MAWrC;CACL"}
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MessageContextInternal = void 0;
4
- const path_1 = require("path");
5
- const imageMessage_1 = require("../../dtos/responses/imageMessage");
6
- const reaction_1 = require("../../dtos/responses/reaction");
7
- const textMessage_1 = require("../../dtos/responses/textMessage");
8
- const videoMessage_1 = require("../../dtos/responses/videoMessage");
9
- const chatContext_1 = require("./chatContext");
10
- const replyInfo_1 = require("../../dtos/replyInfo");
11
- /**
12
- * Context of action executed in chat, in response to a message
13
- */
14
- class MessageContextInternal extends chatContext_1.ChatContextInternal {
15
- /** Information about the user that triggered this action */
16
- userInfo;
17
- /** Information about the message that triggered this action */
18
- messageInfo;
19
- /** Collection of Regexp match results on a message that triggered this action. Will be empty if trigger is not a Regexp. */
20
- matchResults = [];
21
- /** Indicates if cooldown should be started after action is executed. Set to `true` by default. */
22
- startCooldown = true;
23
- /** Bot info from Telegram */
24
- botInfo;
25
- customCooldown;
26
- getQuotePart(quote) {
27
- if (typeof quote != 'boolean')
28
- return quote;
29
- return this.matchResults.length != 0
30
- ? this.matchResults[0][1]
31
- : this.messageInfo.text;
32
- }
33
- replyWithText(text, quote, options) {
34
- const quotedPart = this.getQuotePart(quote);
35
- const response = new textMessage_1.TextMessage(text, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
36
- this.responses.push(response);
37
- return this.createCaptureController(response);
38
- }
39
- replyWithImage(name, quote, options) {
40
- const quotedPart = this.getQuotePart(quote);
41
- const response = new imageMessage_1.ImageMessage({ source: (0, path_1.resolve)(`./content/${name}.png`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
42
- this.responses.push(response);
43
- return this.createCaptureController(response);
44
- }
45
- replyWithVideo(name, quote, options) {
46
- const quotedPart = this.getQuotePart(quote);
47
- const response = new videoMessage_1.VideoMessage({ source: (0, path_1.resolve)(`./content/${name}.mp4`) }, this.chatInfo, this.traceId, this.action, new replyInfo_1.ReplyInfo(this.messageInfo.id, quote ? quotedPart : undefined), options);
48
- this.responses.push(response);
49
- return this.createCaptureController(response);
50
- }
51
- skipCooldown() {
52
- this.startCooldown = false;
53
- }
54
- startCustomCooldown(customCooldown) {
55
- this.startCooldown = true;
56
- this.customCooldown = customCooldown;
57
- }
58
- /**
59
- * Collection of actions that can be done as a reply to a message that triggered this action
60
- */
61
- reply = {
62
- /**
63
- * Collection of actions that can be done as a reply to a message, quoting the part that triggered this action
64
- * If regex is matched, first match will be quoted
65
- */
66
- andQuote: {
67
- /**
68
- * Reply with text message to message that triggered this action after action execution is finished.
69
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
70
- * @param text Message contents.
71
- * @param options Message sending option.
72
- */
73
- withText: (text, quote, options) => this.replyWithText(text, quote ?? true, options),
74
- /**
75
- * Reply with image message to message that triggered this action after action execution is finished.
76
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
77
- * @param text Message contents.
78
- * @param options Message sending option.
79
- */
80
- withImage: (name, quote, options) => this.replyWithImage(name, quote ?? true, options),
81
- /**
82
- * Reply with video/gif message to message that triggered this action after action execution is finished.
83
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
84
- * @param text Message contents.
85
- * @param options Message sending option.
86
- */
87
- withVideo: (name, quote, options) => this.replyWithVideo(name, quote ?? true, options)
88
- },
89
- /**
90
- * Reply with text message to message that triggered this action after action execution is finished.
91
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
92
- * @param text Message contents.
93
- * @param options Message sending option.
94
- */
95
- withText: (text, options) => this.replyWithText(text, false, options),
96
- /**
97
- * Reply with image message to message that triggered this action after action execution is finished.
98
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
99
- * @param text Message contents.
100
- * @param options Message sending option.
101
- */
102
- withImage: (name, options) => this.replyWithImage(name, false, options),
103
- /**
104
- * Reply with video/gif message to message that triggered this action after action execution is finished.
105
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
106
- * @param text Message contents.
107
- * @param options Message sending option.
108
- */
109
- withVideo: (name, options) => this.replyWithVideo(name, false, options),
110
- /**
111
- * React to the message that triggered this action after action execution is finished.
112
- * If multiple responses are sent, they will be sent in the order they were added, with delay of at least 35ms as per Telegram rate-limit.
113
- * @param emoji Telegram emoji to react with.
114
- */
115
- withReaction: (emoji) => {
116
- this.responses.push(new reaction_1.Reaction(this.traceId, this.chatInfo, this.messageInfo.id, emoji, this.action));
117
- }
118
- };
119
- }
120
- exports.MessageContextInternal = MessageContextInternal;