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.
- package/README.md +9 -10
- package/bun.lock +630 -307
- package/dist/dtos/chatHistoryMessage.d.ts +1 -1
- package/dist/dtos/chatHistoryMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.d.ts +4 -4
- package/dist/dtos/incomingMessage.d.ts.map +1 -1
- package/dist/dtos/incomingMessage.js +1 -1
- package/dist/dtos/messageInfo.d.ts +4 -3
- package/dist/dtos/messageInfo.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.d.ts +1 -1
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- package/dist/dtos/responses/inlineQueryResponse.d.ts +1 -1
- package/dist/dtos/responses/inlineQueryResponse.d.ts.map +1 -1
- package/dist/dtos/responses/reaction.d.ts +1 -1
- package/dist/dtos/responses/reaction.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.d.ts +1 -1
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/entities/botInstance.d.ts +1 -1
- package/dist/entities/botInstance.d.ts.map +1 -1
- package/dist/entities/botInstance.js +2 -2
- package/dist/entities/context/inlineQueryContext.d.ts +1 -1
- package/dist/entities/context/inlineQueryContext.d.ts.map +1 -1
- package/dist/entities/context/messageContext.d.ts +2 -2
- package/dist/entities/context/messageContext.d.ts.map +1 -1
- package/dist/entities/context/replyContext.d.ts +2 -2
- package/dist/entities/context/replyContext.d.ts.map +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +2 -2
- package/dist/services/actionProcessingService.d.ts +2 -2
- package/dist/services/actionProcessingService.d.ts.map +1 -1
- package/dist/services/actionProcessingService.js +13 -11
- package/dist/services/actionProcessors/commandActionProcessor.d.ts +2 -3
- package/dist/services/actionProcessors/commandActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/commandActionProcessor.js +7 -7
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts +2 -2
- package/dist/services/actionProcessors/inlineQueryActionProcessor.d.ts.map +1 -1
- package/dist/services/actionProcessors/inlineQueryActionProcessor.js +4 -4
- package/dist/services/jsonLogger.d.ts +1 -1
- package/dist/services/jsonLogger.d.ts.map +1 -1
- package/dist/services/jsonLogger.js +33 -22
- package/dist/services/telegramApi.d.ts +2 -2
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +19 -18
- package/dist/types/inputFile.d.ts +5 -0
- package/dist/types/inputFile.d.ts.map +1 -0
- package/dist/types/inputFile.js +2 -0
- package/dist/types/logger.d.ts +2 -2
- package/dist/types/logger.d.ts.map +1 -1
- package/dist/types/messageTypes.d.ts +0 -2
- package/dist/types/messageTypes.d.ts.map +1 -1
- package/dtos/chatHistoryMessage.ts +1 -1
- package/dtos/incomingMessage.ts +7 -13
- package/dtos/messageInfo.ts +3 -5
- package/dtos/responses/imageMessage.ts +1 -1
- package/dtos/responses/inlineQueryResponse.ts +1 -1
- package/dtos/responses/reaction.ts +1 -1
- package/dtos/responses/videoMessage.ts +1 -1
- package/entities/botInstance.ts +2 -2
- package/entities/context/inlineQueryContext.ts +1 -1
- package/entities/context/messageContext.ts +2 -2
- package/entities/context/replyContext.ts +2 -2
- package/main.ts +2 -2
- package/package.json +3 -7
- package/services/actionProcessingService.ts +13 -13
- package/services/actionProcessors/commandActionProcessor.ts +15 -16
- package/services/actionProcessors/inlineQueryActionProcessor.ts +10 -10
- package/services/jsonLogger.ts +42 -27
- package/services/telegramApi.ts +30 -31
- package/types/inputFile.ts +4 -0
- package/types/logger.ts +2 -6
- 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
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
-
|
|
280
|
-
|
|
281
|
-
|
|
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(
|
|
293
|
+
await stopBots();
|
|
295
294
|
```
|