chz-telegram-bot 0.3.13 → 0.3.15

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 (84) hide show
  1. package/README.md +92 -73
  2. package/dist/dtos/chatInfo.d.ts +10 -1
  3. package/dist/dtos/chatInfo.d.ts.map +1 -1
  4. package/dist/dtos/chatInfo.js +11 -5
  5. package/dist/dtos/commandTriggerCheckResult.d.ts +5 -5
  6. package/dist/dtos/commandTriggerCheckResult.d.ts.map +1 -1
  7. package/dist/dtos/commandTriggerCheckResult.js +4 -4
  8. package/dist/dtos/cooldownInfo.d.ts +9 -3
  9. package/dist/dtos/cooldownInfo.d.ts.map +1 -1
  10. package/dist/dtos/cooldownInfo.js +5 -1
  11. package/dist/dtos/incomingMessage.d.ts +1 -1
  12. package/dist/dtos/incomingMessage.d.ts.map +1 -1
  13. package/dist/dtos/incomingMessage.js +2 -2
  14. package/dist/dtos/incomingQuery.d.ts.map +1 -1
  15. package/dist/dtos/messageInfo.d.ts +21 -0
  16. package/dist/dtos/messageInfo.d.ts.map +1 -0
  17. package/dist/dtos/messageInfo.js +24 -0
  18. package/dist/dtos/userInfo.d.ts +12 -0
  19. package/dist/dtos/userInfo.d.ts.map +1 -0
  20. package/dist/dtos/userInfo.js +16 -0
  21. package/dist/entities/actions/commandAction.d.ts +2 -2
  22. package/dist/entities/actions/commandAction.d.ts.map +1 -1
  23. package/dist/entities/actions/commandAction.js +11 -8
  24. package/dist/entities/actions/inlineQueryAction.d.ts +2 -2
  25. package/dist/entities/actions/inlineQueryAction.d.ts.map +1 -1
  26. package/dist/entities/actions/replyCaptureAction.d.ts +4 -4
  27. package/dist/entities/actions/replyCaptureAction.d.ts.map +1 -1
  28. package/dist/entities/actions/replyCaptureAction.js +4 -4
  29. package/dist/entities/actions/scheduledAction.d.ts +2 -2
  30. package/dist/entities/actions/scheduledAction.d.ts.map +1 -1
  31. package/dist/entities/context/baseContext.d.ts +2 -1
  32. package/dist/entities/context/baseContext.d.ts.map +1 -1
  33. package/dist/entities/context/baseContext.js +3 -3
  34. package/dist/entities/context/chatContext.d.ts +3 -2
  35. package/dist/entities/context/chatContext.d.ts.map +1 -1
  36. package/dist/entities/context/chatContext.js +3 -3
  37. package/dist/entities/context/inlineQueryContext.d.ts +3 -2
  38. package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
  39. package/dist/entities/context/inlineQueryContext.js +3 -3
  40. package/dist/entities/context/messageContext.d.ts +11 -15
  41. package/dist/entities/context/messageContext.d.ts.map +1 -1
  42. package/dist/entities/context/messageContext.js +15 -20
  43. package/dist/entities/context/replyContext.d.ts +9 -15
  44. package/dist/entities/context/replyContext.d.ts.map +1 -1
  45. package/dist/entities/context/replyContext.js +12 -20
  46. package/dist/helpers/mapUtils.d.ts +9 -2
  47. package/dist/helpers/mapUtils.d.ts.map +1 -1
  48. package/dist/helpers/mapUtils.js +1 -1
  49. package/dist/services/actionProcessors/baseProcessor.d.ts +2 -2
  50. package/dist/services/actionProcessors/baseProcessor.d.ts.map +1 -1
  51. package/dist/services/actionProcessors/commandActionProcessor.d.ts +1 -0
  52. package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
  53. package/dist/services/actionProcessors/commandActionProcessor.js +18 -19
  54. package/dist/services/actionProcessors/inlineQueryActionProcessor.js +1 -1
  55. package/dist/services/actionProcessors/scheduledActionProcessor.d.ts.map +1 -1
  56. package/dist/services/actionProcessors/scheduledActionProcessor.js +2 -2
  57. package/dist/types/action.d.ts +2 -2
  58. package/dist/types/action.d.ts.map +1 -1
  59. package/dist/types/capture.d.ts +3 -3
  60. package/dist/types/capture.d.ts.map +1 -1
  61. package/dtos/chatInfo.ts +10 -9
  62. package/dtos/commandTriggerCheckResult.ts +5 -15
  63. package/dtos/cooldownInfo.ts +6 -1
  64. package/dtos/incomingMessage.ts +7 -2
  65. package/dtos/incomingQuery.ts +4 -12
  66. package/dtos/messageInfo.ts +17 -0
  67. package/dtos/userInfo.ts +8 -0
  68. package/entities/actions/commandAction.ts +16 -12
  69. package/entities/actions/inlineQueryAction.ts +2 -2
  70. package/entities/actions/replyCaptureAction.ts +9 -9
  71. package/entities/actions/scheduledAction.ts +2 -2
  72. package/entities/context/baseContext.ts +11 -1
  73. package/entities/context/chatContext.ts +16 -5
  74. package/entities/context/inlineQueryContext.ts +10 -2
  75. package/entities/context/messageContext.ts +24 -25
  76. package/entities/context/replyContext.ts +26 -25
  77. package/helpers/mapUtils.ts +15 -2
  78. package/package.json +1 -1
  79. package/services/actionProcessors/baseProcessor.ts +3 -3
  80. package/services/actionProcessors/commandActionProcessor.ts +43 -21
  81. package/services/actionProcessors/inlineQueryActionProcessor.ts +3 -3
  82. package/services/actionProcessors/scheduledActionProcessor.ts +7 -4
  83. package/types/action.ts +2 -2
  84. package/types/capture.ts +5 -3
package/README.md CHANGED
@@ -26,13 +26,13 @@ botFramework is a TypeScript library that provides a structured approach to buil
26
26
 
27
27
  ```bash
28
28
  # Using npm
29
- npm install chz-bot-framework
29
+ npm install chz-telegram-bot
30
30
 
31
31
  # Using yarn
32
- yarn add chz-bot-framework
32
+ yarn add chz-telegram-bot
33
33
 
34
34
  # Using bun
35
- bun add chz-bot-framework
35
+ bun add chz-telegram-bot
36
36
  ```
37
37
 
38
38
  ## Quick Start
@@ -59,6 +59,7 @@ import {
59
59
  startBot,
60
60
  stopBots,
61
61
  CommandActionBuilder,
62
+ MessageType,
62
63
  Seconds
63
64
  } from 'chz-telegram-bot';
64
65
 
@@ -66,31 +67,52 @@ import {
66
67
  const commands = [
67
68
  new CommandActionBuilder('HelloWorld')
68
69
  .on('/hello')
69
- .do(async (ctx) => {
70
- ctx.replyWithText('Hello, world!');
70
+ .do((ctx) => {
71
+ ctx.reply.withText('Hello, world!');
72
+ })
73
+ .build(),
74
+
75
+ new CommandActionBuilder('Welcome')
76
+ .on(MessageType.NewChatMember)
77
+ .do((ctx) => {
78
+ ctx.reply, withText('Welcome to the group!');
71
79
  })
72
80
  .build()
73
81
  ];
74
82
 
75
- // Define scheduled actions (if needed)
76
- const scheduled = [];
77
-
78
83
  async function main() {
79
- // Start the bot
80
- startBot({
81
- name: 'MyFirstBot',
82
- tokenFilePath: './token.txt',
83
- commands: commands,
84
- scheduled: scheduled,
85
- chats: {
86
- MyChat: -1001234567890 // Replace with your actual chat ID,
87
- },
88
- scheduledPeriod: (60 * 5) as Seconds
89
- });
90
-
91
- // Set up graceful shutdown
92
- process.on('SIGINT', () => stopBots('SIGINT'));
93
- process.on('SIGTERM', () => stopBots('SIGTERM'));
84
+ try {
85
+ // Start the bot
86
+ const bot = await startBot({
87
+ name: 'MyFirstBot',
88
+ tokenFilePath: './token.txt',
89
+ commands,
90
+ scheduled: [], // Add scheduled actions if needed
91
+ chats: {
92
+ MyChat: -1001234567890 // Replace with your chat ID
93
+ },
94
+ scheduledPeriod: (60 * 5) as Seconds,
95
+ // Optional settings
96
+ storagePath: './data',
97
+ verboseLoggingForIncomingMessage: false
98
+ });
99
+
100
+ // Proper cleanup on shutdown
101
+ const cleanup = async (signal: string) => {
102
+ console.log(`Received ${signal}, cleaning up...`);
103
+ await stopBots(signal);
104
+ process.exit(0);
105
+ };
106
+
107
+ process.on('SIGINT', () => cleanup('SIGINT'));
108
+ process.on('SIGTERM', () => cleanup('SIGTERM'));
109
+
110
+ console.log('Bot started successfully!');
111
+ return bot;
112
+ } catch (error) {
113
+ console.error('Failed to start bot:', error);
114
+ process.exit(1);
115
+ }
94
116
  }
95
117
 
96
118
  main().catch(console.error);
@@ -113,21 +135,21 @@ import { CommandActionBuilder } from 'chz-telegram-bot';
113
135
 
114
136
  const myCommand = new CommandActionBuilder('StartCommand')
115
137
  .on('/start')
116
- .do(async (ctx) => {
117
- ctx.replyWithText('Welcome to my bot!');
138
+ .do((ctx) => {
139
+ ctx.reply.withText('Welcome to my bot!');
118
140
  })
119
141
  .build();
120
142
  ```
121
143
 
122
- Message types are also can trigger commands:
144
+ Message types can also trigger commands:
123
145
 
124
146
  ```typescript
125
147
  import { CommandActionBuilder, MessageType } from 'chz-telegram-bot';
126
148
 
127
149
  const myCommand = new CommandActionBuilder('WelcomeMessage')
128
150
  .on(MessageType.NewChatMember)
129
- .do(async (ctx) => {
130
- ctx.replyWithText('Welcome to my group chat!');
151
+ .do((ctx) => {
152
+ ctx.reply.withText('Welcome to my group chat!');
131
153
  })
132
154
  .build();
133
155
  ```
@@ -141,38 +163,38 @@ import { ScheduledActionBuilder, Hours } from 'chz-telegram-bot';
141
163
 
142
164
  const dailyNotification = new ScheduledActionBuilder('GM')
143
165
  .runAt(9 as Hours) // Run at 9 AM
144
- .do(async (ctx) => {
145
- ctx.sendTextToChat('Good morning!');
166
+ .do((ctx) => {
167
+ ctx.send.text('Good morning!');
146
168
  })
147
169
  .build();
148
170
  ```
149
171
 
150
172
  ### Replies and message sending
151
173
 
152
- Depending on a type of action, you will have access to following interaction options:
174
+ Depending on the type of action, you will have access to the following interaction options:
153
175
 
154
- | Method | Action type | Description |
155
- | ----------------- | ----------- | ------------------------------------------------------------ |
156
- | `sendTextToChat` | Both | Send text to chat as a standalone message |
157
- | `sendImageToChat` | Both | Send image to chat as a standalone message |
158
- | `sendVideoToChat` | Both | Send video/gif to chat as a standalone message |
159
- | `unpinMessage` | Both | Unpins message by its ID |
160
- | `wait` | Both | Delays next replies from this action by given amount of ms |
161
- | `replyWithText` | Command | Replies with text to a message that triggered an action |
162
- | `replyWithImage` | Command | Replies with image to a message that triggered an action |
163
- | `replyWithVideo` | Command | Replies with video/gif to a message that triggered an action |
164
- | `react` | Command | Sets an emoji reaction to a message that triggered an action |
176
+ | Method | Action type | Description |
177
+ | -------------------- | ----------- | ------------------------------------------------------------ |
178
+ | `send.text` | Both | Send text to chat as a standalone message |
179
+ | `send.image` | Both | Send image to chat as a standalone message |
180
+ | `send.video` | Both | Send video/gif to chat as a standalone message |
181
+ | `unpinMessage` | Both | Unpins message by its ID |
182
+ | `wait` | Both | Delays next replies from this action by given amount of ms |
183
+ | `reply.withText` | Command | Replies with text to a message that triggered an action |
184
+ | `reply.withImage` | Command | Replies with image to a message that triggered an action |
185
+ | `reply.withVideo` | Command | Replies with video/gif to a message that triggered an action |
186
+ | `reply.withReaction` | Command | Sets an emoji reaction to a message that triggered an action |
165
187
 
166
- Keep in mind that reply sending is deferred until action execution finished and will be done in order of calling in action handler.
167
- Ex:
188
+ Keep in mind that reply sending is deferred until action execution finishes and will be done in order of calling in the action handler.
189
+ Example:
168
190
 
169
191
  ```typescript
170
- ctx.sendTextToChat('Message 1');
192
+ ctx.send.text('Message 1');
171
193
  ctx.wait(5000 as Millisecond);
172
- ctx.sendTextToChat('Message 2');
194
+ ctx.send.text('Message 2');
173
195
  ```
174
196
 
175
- This will result in `Message 1` text being send, followed by `Message 2` after 5 second delay.
197
+ This will result in `Message 1` being sent, followed by `Message 2` after a 5 second delay.
176
198
 
177
199
  ## Configuration Options
178
200
 
@@ -182,27 +204,19 @@ When starting a bot, you can provide the following configuration:
182
204
  | ----------------- | ------------------------ | --------------------------- | ----------------------------------------------------------------------------------------- |
183
205
  | `name` | `string` | Yes | Bot name used in logging |
184
206
  | `tokenFilePath` | `string` | Yes | Path to file containing Telegram Bot token |
185
- | `actions` | | Yes | Object containing actions to be executed by bot |
207
+ | `commands` | `CommandAction[] ` | Yes (can be empty) | Collection of command actions |
208
+ | `scheduled` | `ScheduledAction[]` | Yes (can be empty) | Collection of scheduled actions |
186
209
  | `chats` | `Record<string, number>` | Yes | Object containing chat name-id pairs. Used for logging and execution of scheduled action. |
187
210
  | `storagePath` | `string` | No | Custom storage path for default JsonFileStorage client |
188
211
  | `scheduledPeriod` | `Seconds` | No (will default to 1 hour) | Period between scheduled action executions |
189
212
  | `services` | | No | Custom services to be used instead of default ones |
190
213
 
191
- Actions object should have following structure:
192
-
193
- | Option | Type | Required | Description |
194
- | --------------- | --------------------- | ------------------ | ---------------------------------- |
195
- | `commands` | `CommandAction[] ` | Yes (can be empty) | Collection of command actions |
196
- | `scheduled` | `ScheduledAction[]` | Yes (can be empty) | Collection of scheduled actions |
197
- | `inlineQueries` | `InlineQueryAction[]` | Yes (can be empty) | Collection of inline query actions |
198
-
199
214
  Services object should have following structure:
200
-
201
- | Option | Type | Required | Description |
202
- | --------------- | ---------------- | ------------------------------------------- | ---------------------------------- |
203
- | `storageClient` | `IStorageClient` | No (will default to `JsonFileStorage`) | Persistance state provide |
204
- | `logger` | `ILogger` | No (will default to `JsonLogger`) | Logger service |
205
- | `scheduler` | `IScheduler` | No (will default to `NodeTimeoutScheduler`) | Scheduler used to scheduled action |
215
+ | Option | Type | Required | Description |
216
+ |------------------|--------------------------|----------|---------------------------------------------------------------|
217
+ | `storageClient` | `IStorageClient` | No (will default to `JsonFileStorage`) | Persistance state provide |
218
+ | `logger` | `ILogger` | No (will default to `JsonLogger`) | Logger service |
219
+ | `scheduler` | `IScheduler` | No (will default to `NodeTimeoutScheduler`) | Scheduler used to scheduled action|
206
220
 
207
221
  ## Advanced Usage
208
222
 
@@ -224,7 +238,7 @@ const counterCommand = new CommandActionBuilderWithState<MyCustomState>(
224
238
  .on('/count')
225
239
  .do(async (ctx, state) => {
226
240
  state.counter++;
227
- ctx.replyWithText(`Count: ${state.counter}`);
241
+ ctx.reply.withText(`Count: ${state.counter}`);
228
242
  })
229
243
  .build();
230
244
  ```
@@ -239,15 +253,20 @@ The framework provides support for handling inline queries with type-safe builde
239
253
  import { InlineQueryActionBuilder } from 'chz-telegram-bot';
240
254
 
241
255
  const searchCommand = new InlineQueryActionBuilder('Search')
242
- .do(async (ctx) => {
256
+ .do((ctx) => {
243
257
  const query = ctx.queryText;
244
258
  // Process the query and return inline results
245
- ctx.showInlineQueryResult({
246
- id: '1',
247
- type: 'article',
248
- title: `Search results for: ${query}`,
249
- description: 'Click to send'
250
- });
259
+ ctx.showInlineQueryResult([
260
+ {
261
+ id: '1',
262
+ type: 'article',
263
+ title: `Search results for: ${query}`,
264
+ description: 'Click to send',
265
+ input_message_content: {
266
+ message_text: `Search result for: ${query}`
267
+ }
268
+ }
269
+ ]);
251
270
  })
252
271
  .build();
253
272
  ```
@@ -257,9 +276,9 @@ const searchCommand = new InlineQueryActionBuilder('Search')
257
276
  The framework includes a response processing queue that ensures reliable message delivery and proper ordering of responses:
258
277
 
259
278
  ```typescript
260
- ctx.sendTextToChat('First message');
261
- ctx.sendImageToChat('image.jpg');
262
- ctx.react('👍');
279
+ await ctx.send.text('First message');
280
+ await ctx.send.image('image');
281
+ await ctx.reply.withReaction('👍');
263
282
  ```
264
283
 
265
284
  All responses are queued and processed in order, ensuring proper sequencing of messages and reactions.
@@ -1,8 +1,17 @@
1
+ import { IncomingMessage } from './incomingMessage';
1
2
  export declare class ChatInfo {
2
3
  /** Id of a chat that action is executed in. */
3
4
  readonly id: number;
4
5
  /** Name of a chat that action is executed in. */
5
6
  readonly name: string;
6
- constructor(chatId: number, chatName: string);
7
+ /** Last 100 messages in chat where action is executed */
8
+ readonly messageHistory: IncomingMessage[];
9
+ constructor(
10
+ /** Id of a chat that action is executed in. */
11
+ id: number,
12
+ /** Name of a chat that action is executed in. */
13
+ name: string,
14
+ /** Last 100 messages in chat where action is executed */
15
+ messageHistory: IncomingMessage[]);
7
16
  }
8
17
  //# sourceMappingURL=chatInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chatInfo.d.ts","sourceRoot":"","sources":["../../dtos/chatInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACjB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBAEV,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAI/C"}
1
+ {"version":3,"file":"chatInfo.d.ts","sourceRoot":"","sources":["../../dtos/chatInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,QAAQ;IAEb,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,iDAAiD;IACjD,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,yDAAyD;IACzD,QAAQ,CAAC,cAAc,EAAE,eAAe,EAAE;;IAL1C,+CAA+C;IACtC,EAAE,EAAE,MAAM;IACnB,iDAAiD;IACxC,IAAI,EAAE,MAAM;IACrB,yDAAyD;IAChD,cAAc,EAAE,eAAe,EAAE;CAEjD"}
@@ -2,13 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ChatInfo = void 0;
4
4
  class ChatInfo {
5
- /** Id of a chat that action is executed in. */
6
5
  id;
7
- /** Name of a chat that action is executed in. */
8
6
  name;
9
- constructor(chatId, chatName) {
10
- this.id = chatId;
11
- this.name = chatName;
7
+ messageHistory;
8
+ constructor(
9
+ /** Id of a chat that action is executed in. */
10
+ id,
11
+ /** Name of a chat that action is executed in. */
12
+ name,
13
+ /** Last 100 messages in chat where action is executed */
14
+ messageHistory) {
15
+ this.id = id;
16
+ this.name = name;
17
+ this.messageHistory = messageHistory;
12
18
  }
13
19
  }
14
20
  exports.ChatInfo = ChatInfo;
@@ -8,14 +8,14 @@ declare const _SkipTriggerReasonsObject: {
8
8
  };
9
9
  export type SkipTriggerReasons = keyof typeof _SkipTriggerReasonsObject;
10
10
  export declare class CommandTriggerCheckResult {
11
- static DontTriggerAndSkipCooldown(reason: SkipTriggerReasons): CommandTriggerCheckResult;
12
- static DoNotTrigger(reason: SkipTriggerReasons): CommandTriggerCheckResult;
13
- static Trigger(): CommandTriggerCheckResult;
14
11
  readonly shouldExecute: boolean;
15
12
  readonly matchResults: RegExpExecArray[];
16
13
  readonly skipCooldown: boolean;
17
- readonly reason: SkipTriggerReasons | undefined;
18
- constructor(shouldExecute: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean, reason?: SkipTriggerReasons);
14
+ readonly reason?: SkipTriggerReasons | undefined;
15
+ static DontTriggerAndSkipCooldown(reason: SkipTriggerReasons): CommandTriggerCheckResult;
16
+ static DoNotTrigger(reason: SkipTriggerReasons): CommandTriggerCheckResult;
17
+ static Trigger(): CommandTriggerCheckResult;
18
+ constructor(shouldExecute: boolean, matchResults: RegExpExecArray[], skipCooldown: boolean, reason?: SkipTriggerReasons | undefined);
19
19
  mergeWith(other: CommandTriggerCheckResult): CommandTriggerCheckResult;
20
20
  }
21
21
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../dtos/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,yBAAyB;;;;;;;CAOrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAExE,qBAAa,yBAAyB;IAClC,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,kBAAkB;IAG5D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB;IAG9C,MAAM,CAAC,OAAO;IAId,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC;IAChC,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE,CAAC;IACzC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;gBAG5C,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,MAAM,CAAC,EAAE,kBAAkB;IAQ/B,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAQ7C"}
1
+ {"version":3,"file":"commandTriggerCheckResult.d.ts","sourceRoot":"","sources":["../../dtos/commandTriggerCheckResult.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,yBAAyB;;;;;;;CAOrB,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,yBAAyB,CAAC;AAExE,qBAAa,yBAAyB;IAY9B,QAAQ,CAAC,aAAa,EAAE,OAAO;IAC/B,QAAQ,CAAC,YAAY,EAAE,eAAe,EAAE;IACxC,QAAQ,CAAC,YAAY,EAAE,OAAO;IAC9B,QAAQ,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAdxC,MAAM,CAAC,0BAA0B,CAAC,MAAM,EAAE,kBAAkB;IAG5D,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,kBAAkB;IAG9C,MAAM,CAAC,OAAO;gBAKD,aAAa,EAAE,OAAO,EACtB,YAAY,EAAE,eAAe,EAAE,EAC/B,YAAY,EAAE,OAAO,EACrB,MAAM,CAAC,EAAE,kBAAkB,YAAA;IAGxC,SAAS,CAAC,KAAK,EAAE,yBAAyB;CAQ7C"}
@@ -10,6 +10,10 @@ const _SkipTriggerReasonsObject = {
10
10
  Other: 'Other'
11
11
  };
12
12
  class CommandTriggerCheckResult {
13
+ shouldExecute;
14
+ matchResults;
15
+ skipCooldown;
16
+ reason;
13
17
  static DontTriggerAndSkipCooldown(reason) {
14
18
  return new CommandTriggerCheckResult(false, [], true, reason);
15
19
  }
@@ -19,10 +23,6 @@ class CommandTriggerCheckResult {
19
23
  static Trigger() {
20
24
  return new CommandTriggerCheckResult(true, [], false);
21
25
  }
22
- shouldExecute;
23
- matchResults;
24
- skipCooldown;
25
- reason;
26
26
  constructor(shouldExecute, matchResults, skipCooldown, reason) {
27
27
  this.shouldExecute = shouldExecute;
28
28
  this.matchResults = matchResults;
@@ -1,7 +1,13 @@
1
1
  import { Seconds } from '../types/timeValues';
2
2
  export declare class CooldownInfo {
3
- seconds: Seconds;
4
- message: string | undefined;
5
- constructor(seconds: Seconds, message: string | undefined);
3
+ /** New one-time cooldown in seconds */
4
+ readonly seconds: Seconds;
5
+ /** Cooldown message to be shown */
6
+ readonly message: string | undefined;
7
+ constructor(
8
+ /** New one-time cooldown in seconds */
9
+ seconds: Seconds,
10
+ /** Cooldown message to be shown */
11
+ message: string | undefined);
6
12
  }
7
13
  //# sourceMappingURL=cooldownInfo.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cooldownInfo.d.ts","sourceRoot":"","sources":["../../dtos/cooldownInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,YAAY;IACF,OAAO,EAAE,OAAO;IAAS,OAAO,EAAE,MAAM,GAAG,SAAS;gBAApD,OAAO,EAAE,OAAO,EAAS,OAAO,EAAE,MAAM,GAAG,SAAS;CAC1E"}
1
+ {"version":3,"file":"cooldownInfo.d.ts","sourceRoot":"","sources":["../../dtos/cooldownInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,qBAAa,YAAY;IAEjB,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO;IACzB,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS;;IAHpC,uCAAuC;IAC9B,OAAO,EAAE,OAAO;IACzB,mCAAmC;IAC1B,OAAO,EAAE,MAAM,GAAG,SAAS;CAE3C"}
@@ -4,7 +4,11 @@ exports.CooldownInfo = void 0;
4
4
  class CooldownInfo {
5
5
  seconds;
6
6
  message;
7
- constructor(seconds, message) {
7
+ constructor(
8
+ /** New one-time cooldown in seconds */
9
+ seconds,
10
+ /** Cooldown message to be shown */
11
+ message) {
8
12
  this.seconds = seconds;
9
13
  this.message = message;
10
14
  }
@@ -12,6 +12,6 @@ export declare class IncomingMessage {
12
12
  readonly replyToMessageId: number | undefined;
13
13
  readonly updateObject: TelegrafContextMessage;
14
14
  private detectMessageType;
15
- constructor(ctxMessage: TelegrafContextMessage, botName: string);
15
+ constructor(ctxMessage: TelegrafContextMessage, botName: string, history: IncomingMessage[]);
16
16
  }
17
17
  //# sourceMappingURL=incomingMessage.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"incomingMessage.d.ts","sourceRoot":"","sources":["../../dtos/incomingMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,IAAI,EAAE,MAAM,g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B,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAE9C,QAAQ,CAAC,YAAY,EAAE,sBAAsB,CAAC;IAE9C,OAAO,CAAC,iBAAiB;gBAqBrB,UAAU,EAAE,sBAAsB,EAClC,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,EAAE;CA6BjC"}
@@ -43,7 +43,7 @@ class IncomingMessage {
43
43
  return messageTypes_1.MessageType.Location;
44
44
  return messageTypes_1.MessageType.Unknown;
45
45
  }
46
- constructor(ctxMessage, botName) {
46
+ constructor(ctxMessage, botName, history) {
47
47
  this.traceId = (0, traceFactory_1.createTrace)(this, botName, (0, crypto_1.randomInt)(10000, 99999).toString());
48
48
  this.messageId = ctxMessage.message_id;
49
49
  this.replyToMessageId =
@@ -59,7 +59,7 @@ class IncomingMessage {
59
59
  : '';
60
60
  this.chatInfo = new chatInfo_1.ChatInfo(ctxMessage.chat.id, 'title' in ctxMessage.chat
61
61
  ? `${ctxMessage.chat.title} ${ctxMessage.chat.id}`
62
- : 'DM');
62
+ : 'DM', history);
63
63
  this.type = this.detectMessageType(ctxMessage);
64
64
  this.updateObject = ctxMessage;
65
65
  }
@@ -1 +1 @@
1
- {"version":3,"file":"incomingQuery.d.ts","sourceRoot":"","sources":["../../dtos/incomingQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,mBAAmB;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAGtC,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO;CAQvB"}
1
+ {"version":3,"file":"incomingQuery.d.ts","sourceRoot":"","sources":["../../dtos/incomingQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,mBAAmB;IAIxB,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO;IAN7B,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;gBAG7B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,OAAO;CAIhC"}
@@ -0,0 +1,21 @@
1
+ import { MessageTypeValue, TelegrafContextMessage } from '../types/messageTypes';
2
+ export declare class MessageInfo {
3
+ /** Id of a message that triggered this action. */
4
+ readonly id: number;
5
+ /** Text of a message that triggered this action. */
6
+ readonly text: string;
7
+ /** Type of message being received */
8
+ readonly type: MessageTypeValue;
9
+ /** Message object recieved from Telegram */
10
+ readonly telegramUpdateObject: TelegrafContextMessage;
11
+ constructor(
12
+ /** Id of a message that triggered this action. */
13
+ id: number,
14
+ /** Text of a message that triggered this action. */
15
+ text: string,
16
+ /** Type of message being received */
17
+ type: MessageTypeValue,
18
+ /** Message object recieved from Telegram */
19
+ telegramUpdateObject: TelegrafContextMessage);
20
+ }
21
+ //# sourceMappingURL=messageInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messageInfo.d.ts","sourceRoot":"","sources":["../../dtos/messageInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAChB,sBAAsB,EACzB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,WAAW;IAEhB,kDAAkD;IAClD,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,oDAAoD;IACpD,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB;IAC/B,4CAA4C;IAC5C,QAAQ,CAAC,oBAAoB,EAAE,sBAAsB;;IAPrD,kDAAkD;IACzC,EAAE,EAAE,MAAM;IACnB,oDAAoD;IAC3C,IAAI,EAAE,MAAM;IACrB,qCAAqC;IAC5B,IAAI,EAAE,gBAAgB;IAC/B,4CAA4C;IACnC,oBAAoB,EAAE,sBAAsB;CAE5D"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MessageInfo = void 0;
4
+ class MessageInfo {
5
+ id;
6
+ text;
7
+ type;
8
+ telegramUpdateObject;
9
+ constructor(
10
+ /** Id of a message that triggered this action. */
11
+ id,
12
+ /** Text of a message that triggered this action. */
13
+ text,
14
+ /** Type of message being received */
15
+ type,
16
+ /** Message object recieved from Telegram */
17
+ telegramUpdateObject) {
18
+ this.id = id;
19
+ this.text = text;
20
+ this.type = type;
21
+ this.telegramUpdateObject = telegramUpdateObject;
22
+ }
23
+ }
24
+ exports.MessageInfo = MessageInfo;
@@ -0,0 +1,12 @@
1
+ export declare class UserInfo {
2
+ /** Id of a user that sent a message that triggered this action. */
3
+ readonly id: number;
4
+ /** Name of a user that sent a message that triggered this action. */
5
+ readonly name: string;
6
+ constructor(
7
+ /** Id of a user that sent a message that triggered this action. */
8
+ id: number,
9
+ /** Name of a user that sent a message that triggered this action. */
10
+ name: string);
11
+ }
12
+ //# sourceMappingURL=userInfo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"userInfo.d.ts","sourceRoot":"","sources":["../../dtos/userInfo.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IAEb,mEAAmE;IACnE,QAAQ,CAAC,EAAE,EAAE,MAAM;IACnB,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,MAAM;;IAHrB,mEAAmE;IAC1D,EAAE,EAAE,MAAM;IACnB,qEAAqE;IAC5D,IAAI,EAAE,MAAM;CAE5B"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UserInfo = void 0;
4
+ class UserInfo {
5
+ id;
6
+ name;
7
+ constructor(
8
+ /** Id of a user that sent a message that triggered this action. */
9
+ id,
10
+ /** Name of a user that sent a message that triggered this action. */
11
+ name) {
12
+ this.id = id;
13
+ this.name = name;
14
+ }
15
+ }
16
+ exports.UserInfo = UserInfo;
@@ -2,7 +2,7 @@ import { CommandHandler } from '../../types/handlers';
2
2
  import { CommandCondition } from '../../types/commandCondition';
3
3
  import { IActionState } from '../../types/actionState';
4
4
  import { IActionWithState, ActionKey } from '../../types/action';
5
- import { MessageContext } from '../context/messageContext';
5
+ import { MessageContextInternal } from '../context/messageContext';
6
6
  import { CommandTrigger } from '../../types/commandTrigger';
7
7
  import { Sema as Semaphore } from 'async-sema';
8
8
  import { CooldownInfo } from '../../dtos/cooldownInfo';
@@ -23,7 +23,7 @@ export declare class CommandAction<TActionState extends IActionState> implements
23
23
  readonly maxAllowedSimultaniousExecutions: number;
24
24
  lastCustomCooldown: Seconds | undefined;
25
25
  constructor(trigger: CommandTrigger | CommandTrigger[], handler: CommandHandler<TActionState>, name: string, active: boolean, cooldownInfo: CooldownInfo, chatsBlacklist: number[], allowedUsers: number[], maxAllowedSimultaniousExecutions: number, condition: CommandCondition<TActionState>, stateConstructor: () => TActionState, readmeFactory: (botName: string) => string);
26
- exec(ctx: MessageContext<TActionState>): Promise<import("../../types/response").BotResponse[]>;
26
+ exec(ctx: MessageContextInternal<TActionState>): Promise<import("../../types/response").BotResponse[]>;
27
27
  private checkIfShouldBeExecuted;
28
28
  private checkTrigger;
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"commandAction.d.ts","sourceRoot":"","sources":["../../../entities/actions/commandAction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAA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.TextMessage(this.cooldownInfo.message, ctx.chatInfo, ctx.traceId, this, new replyInfo_1.ReplyInfo(ctx.messageId))
65
+ new textMessage_1.TextMessage(this.cooldownInfo.message, ctx.chatInfo, ctx.traceId, this, new replyInfo_1.ReplyInfo(ctx.messageInfo.id))
66
66
  ];
67
67
  return noop_1.Noop.NoResponse;
68
68
  }
@@ -84,10 +84,13 @@ class CommandAction {
84
84
  }
85
85
  }
86
86
  checkIfShouldBeExecuted(ctx, trigger, state) {
87
- if (!ctx.fromUserId)
87
+ const triggerCheckResult = this.checkTrigger(ctx, trigger);
88
+ if (!triggerCheckResult.shouldExecute)
89
+ return triggerCheckResult;
90
+ if (!ctx.userInfo.id)
88
91
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown('UserIdMissing');
89
92
  const isUserAllowed = this.allowedUsers.length == 0 ||
90
- this.allowedUsers.includes(ctx.fromUserId);
93
+ this.allowedUsers.includes(ctx.userInfo.id);
91
94
  if (!isUserAllowed)
92
95
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown('UserForbidden');
93
96
  const lastExecutedDate = (0, moment_1.default)(state.lastExecutedDate);
@@ -98,24 +101,24 @@ class CommandAction {
98
101
  const isCustomConditionMet = this.condition(ctx, state);
99
102
  if (!isCustomConditionMet)
100
103
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.DontTriggerAndSkipCooldown('CustomConditionNotMet');
101
- return this.checkTrigger(ctx, trigger);
104
+ return triggerCheckResult;
102
105
  }
103
106
  checkTrigger(ctx, trigger) {
104
- if (trigger == messageTypes_1.MessageType.Any || trigger == ctx.messageType)
107
+ if (trigger == messageTypes_1.MessageType.Any || trigger == ctx.messageInfo.type)
105
108
  return commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger();
106
109
  if (typeof trigger == 'string')
107
- return ctx.messageText.toLowerCase() == trigger.toLowerCase()
110
+ return ctx.messageInfo.text.toLowerCase() == trigger.toLowerCase()
108
111
  ? commandTriggerCheckResult_1.CommandTriggerCheckResult.Trigger()
109
112
  : commandTriggerCheckResult_1.CommandTriggerCheckResult.DoNotTrigger('TriggerNotSatisfied');
110
113
  const matchResults = [];
111
114
  trigger.lastIndex = 0;
112
- const execResult = trigger.exec(ctx.messageText);
115
+ const execResult = trigger.exec(ctx.messageInfo.text);
113
116
  if (execResult != null) {
114
117
  let regexMatchLimit = 100;
115
118
  matchResults.push(execResult);
116
119
  if (trigger.global) {
117
120
  while (regexMatchLimit > 0) {
118
- const nextResult = trigger.exec(ctx.messageText);
121
+ const nextResult = trigger.exec(ctx.messageInfo.text);
119
122
  if (nextResult == null)
120
123
  break;
121
124
  matchResults.push(nextResult);
@@ -1,5 +1,5 @@
1
1
  import { ActionKey, IAction } from '../../types/action';
2
- import { InlineQueryContext } from '../context/inlineQueryContext';
2
+ import { InlineQueryContextInternal } from '../context/inlineQueryContext';
3
3
  import { InlineQueryHandler } from '../../types/handlers';
4
4
  export declare class InlineQueryAction implements IAction {
5
5
  readonly key: ActionKey;
@@ -8,6 +8,6 @@ export declare class InlineQueryAction implements IAction {
8
8
  readonly name: string;
9
9
  readonly pattern: RegExp;
10
10
  constructor(handler: InlineQueryHandler, name: string, active: boolean, pattern: RegExp);
11
- exec(ctx: InlineQueryContext): Promise<import("../../types/response").BotResponse[]>;
11
+ exec(ctx: InlineQueryContextInternal): Promise<import("../../types/response").BotResponse[]>;
12
12
  }
13
13
  //# sourceMappingURL=inlineQueryAction.d.ts.map