chz-telegram-bot 0.3.30 → 0.4.0

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 (72) hide show
  1. package/README.md +9 -10
  2. package/bun.lock +630 -307
  3. package/dist/dtos/chatHistoryMessage.d.ts +1 -1
  4. package/dist/dtos/chatHistoryMessage.d.ts.map +1 -1
  5. package/dist/dtos/incomingMessage.d.ts +4 -4
  6. package/dist/dtos/incomingMessage.d.ts.map +1 -1
  7. package/dist/dtos/incomingMessage.js +1 -1
  8. package/dist/dtos/messageInfo.d.ts +4 -3
  9. package/dist/dtos/messageInfo.d.ts.map +1 -1
  10. package/dist/dtos/responses/imageMessage.d.ts +1 -1
  11. package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
  12. package/dist/dtos/responses/inlineQueryResponse.d.ts +1 -1
  13. package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -1
  14. package/dist/dtos/responses/reaction.d.ts +1 -1
  15. package/dist/dtos/responses/reaction.d.ts.map +1 -1
  16. package/dist/dtos/responses/videoMessage.d.ts +1 -1
  17. package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
  18. package/dist/entities/botInstance.d.ts +1 -1
  19. package/dist/entities/botInstance.d.ts.map +1 -1
  20. package/dist/entities/botInstance.js +2 -2
  21. package/dist/entities/context/inlineQueryContext.d.ts +1 -1
  22. package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
  23. package/dist/entities/context/messageContext.d.ts +2 -2
  24. package/dist/entities/context/messageContext.d.ts.map +1 -1
  25. package/dist/entities/context/replyContext.d.ts +2 -2
  26. package/dist/entities/context/replyContext.d.ts.map +1 -1
  27. package/dist/main.d.ts +1 -1
  28. package/dist/main.d.ts.map +1 -1
  29. package/dist/main.js +2 -2
  30. package/dist/services/actionProcessingService.d.ts +2 -2
  31. package/dist/services/actionProcessingService.d.ts.map +1 -1
  32. package/dist/services/actionProcessingService.js +13 -11
  33. package/dist/services/actionProcessors/commandActionProcessor.d.ts +2 -3
  34. package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
  35. package/dist/services/actionProcessors/commandActionProcessor.js +7 -7
  36. package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +2 -2
  37. package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
  38. package/dist/services/actionProcessors/inlineQueryActionProcessor.js +4 -4
  39. package/dist/services/jsonLogger.d.ts +1 -1
  40. package/dist/services/jsonLogger.d.ts.map +1 -1
  41. package/dist/services/jsonLogger.js +33 -22
  42. package/dist/services/telegramApi.d.ts +2 -2
  43. package/dist/services/telegramApi.d.ts.map +1 -1
  44. package/dist/services/telegramApi.js +19 -18
  45. package/dist/types/inputFile.d.ts +5 -0
  46. package/dist/types/inputFile.d.ts.map +1 -0
  47. package/dist/types/inputFile.js +2 -0
  48. package/dist/types/logger.d.ts +2 -2
  49. package/dist/types/logger.d.ts.map +1 -1
  50. package/dist/types/messageTypes.d.ts +0 -2
  51. package/dist/types/messageTypes.d.ts.map +1 -1
  52. package/dtos/chatHistoryMessage.ts +1 -1
  53. package/dtos/incomingMessage.ts +7 -13
  54. package/dtos/messageInfo.ts +3 -5
  55. package/dtos/responses/imageMessage.ts +1 -1
  56. package/dtos/responses/inlineQueryResponse.ts +1 -1
  57. package/dtos/responses/reaction.ts +1 -1
  58. package/dtos/responses/videoMessage.ts +1 -1
  59. package/entities/botInstance.ts +2 -2
  60. package/entities/context/inlineQueryContext.ts +1 -1
  61. package/entities/context/messageContext.ts +2 -2
  62. package/entities/context/replyContext.ts +2 -2
  63. package/main.ts +2 -2
  64. package/package.json +3 -7
  65. package/services/actionProcessingService.ts +13 -13
  66. package/services/actionProcessors/commandActionProcessor.ts +15 -16
  67. package/services/actionProcessors/inlineQueryActionProcessor.ts +10 -10
  68. package/services/jsonLogger.ts +42 -27
  69. package/services/telegramApi.ts +30 -31
  70. package/types/inputFile.ts +4 -0
  71. package/types/logger.ts +2 -6
  72. package/types/messageTypes.ts +0 -4
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Overview
6
6
 
7
- botFramework is a TypeScript library that provides a structured approach to building Telegram bots. It offers a comprehensive set of features for managing bot lifecycles, message processing, scheduled tasks, and state persistence, built on top of the popular Telegraf library.
7
+ botFramework is a TypeScript library that provides a structured approach to building Telegram bots. It offers a comprehensive set of features for managing bot lifecycles, message processing, scheduled tasks, and state persistence.
8
8
 
9
9
  ## Features
10
10
 
@@ -56,8 +56,7 @@ Create an `index.ts` file with the following content:
56
56
 
57
57
  ```typescript
58
58
  import {
59
- startBot,
60
- stopBots,
59
+ botOrchestrator,
61
60
  CommandActionBuilder,
62
61
  MessageType,
63
62
  Seconds
@@ -75,7 +74,7 @@ const commands = [
75
74
  new CommandActionBuilder('Welcome')
76
75
  .on(MessageType.NewChatMember)
77
76
  .do((ctx) => {
78
- ctx.reply, withText('Welcome to the group!');
77
+ ctx.reply.withText('Welcome to the group!');
79
78
  })
80
79
  .build()
81
80
  ];
@@ -83,7 +82,7 @@ const commands = [
83
82
  async function main() {
84
83
  try {
85
84
  // Start the bot
86
- const bot = await startBot({
85
+ const bot = await botOrchestrator.startBot({
87
86
  name: 'MyFirstBot',
88
87
  tokenFilePath: './token.txt',
89
88
  commands,
@@ -100,7 +99,7 @@ async function main() {
100
99
  // Proper cleanup on shutdown
101
100
  const cleanup = async (signal: string) => {
102
101
  console.log(`Received ${signal}, cleaning up...`);
103
- await stopBots(signal);
102
+ await botOrchestrator.stopBots();
104
103
  process.exit(0);
105
104
  };
106
105
 
@@ -276,9 +275,9 @@ const searchCommand = new InlineQueryActionBuilder('Search')
276
275
  The framework includes a response processing queue that ensures reliable message delivery and proper ordering of responses:
277
276
 
278
277
  ```typescript
279
- await ctx.send.text('First message');
280
- await ctx.send.image('image');
281
- await ctx.reply.withReaction('👍');
278
+ ctx.send.text('First message');
279
+ ctx.send.image('image');
280
+ ctx.reply.withReaction('👍');
282
281
  ```
283
282
 
284
283
  All responses are queued and processed in order, ensuring proper sequencing of messages and reactions.
@@ -291,5 +290,5 @@ To properly terminate your bot and clean up resources:
291
290
  import { stopBots } from 'chz-telegram-bot';
292
291
 
293
292
  // Call when your application is shutting down
294
- await stopBots('SHUTDOWN');
293
+ await stopBots();
295
294
  ```