chz-telegram-bot 0.1.0 → 0.1.2
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 +124 -115
- package/dist/dtos/responses/delay.d.ts +1 -0
- package/dist/dtos/responses/delay.d.ts.map +1 -1
- package/dist/dtos/responses/delay.js +1 -0
- package/dist/dtos/responses/imageMessage.d.ts +1 -0
- package/dist/dtos/responses/imageMessage.d.ts.map +1 -1
- package/dist/dtos/responses/imageMessage.js +1 -0
- package/dist/dtos/responses/reaction.d.ts +1 -0
- package/dist/dtos/responses/reaction.d.ts.map +1 -1
- package/dist/dtos/responses/reaction.js +1 -0
- package/dist/dtos/responses/textMessage.d.ts +1 -0
- package/dist/dtos/responses/textMessage.d.ts.map +1 -1
- package/dist/dtos/responses/textMessage.js +1 -0
- package/dist/dtos/responses/unpin.d.ts +1 -0
- package/dist/dtos/responses/unpin.d.ts.map +1 -1
- package/dist/dtos/responses/unpin.js +1 -0
- package/dist/dtos/responses/videoMessage.d.ts +1 -0
- package/dist/dtos/responses/videoMessage.d.ts.map +1 -1
- package/dist/dtos/responses/videoMessage.js +1 -0
- package/dist/entities/botInstance.js +2 -2
- package/dist/entities/context/chatContext.d.ts +2 -2
- package/dist/entities/context/chatContext.d.ts.map +1 -1
- package/dist/entities/context/chatContext.js +2 -2
- package/dist/services/responseProcessingQueue.d.ts +12 -0
- package/dist/services/responseProcessingQueue.d.ts.map +1 -0
- package/dist/services/responseProcessingQueue.js +45 -0
- package/dist/services/telegramApi.d.ts +2 -3
- package/dist/services/telegramApi.d.ts.map +1 -1
- package/dist/services/telegramApi.js +22 -25
- package/dist/types/response.d.ts +1 -0
- package/dist/types/response.d.ts.map +1 -1
- package/dtos/responses/delay.ts +1 -0
- package/dtos/responses/imageMessage.ts +1 -0
- package/dtos/responses/reaction.ts +1 -0
- package/dtos/responses/textMessage.ts +1 -0
- package/dtos/responses/unpin.ts +1 -0
- package/dtos/responses/videoMessage.ts +1 -0
- package/entities/botInstance.ts +2 -2
- package/entities/context/chatContext.ts +2 -2
- package/package.json +1 -1
- package/services/responseProcessingQueue.ts +57 -0
- package/services/telegramApi.ts +28 -35
- package/types/response.ts +1 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
1
|
# chz-bot-Framework
|
|
3
2
|
|
|
4
3
|
[](https://deepwiki.com/AlexSolari/botFramework)
|
|
4
|
+
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
botFramework is a TypeScript library that provides a structured approach to building Telegram bots. It handles the complexities of bot lifecycle management, message processing, scheduled tasks, and state persistence.
|
|
@@ -9,8 +9,8 @@ botFramework is a TypeScript library that provides a structured approach to buil
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
11
|
```
|
|
12
|
-
npm install chz-bot-framework
|
|
13
|
-
# or
|
|
12
|
+
npm install chz-bot-framework
|
|
13
|
+
# or
|
|
14
14
|
bun install chz-bot-framework
|
|
15
15
|
```
|
|
16
16
|
|
|
@@ -19,54 +19,59 @@ bun install chz-bot-framework
|
|
|
19
19
|
### 1. Create a new bot project
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
mkdir my-telegram-bot
|
|
23
|
-
cd my-telegram-bot
|
|
24
|
-
npm init -y
|
|
22
|
+
mkdir my-telegram-bot
|
|
23
|
+
cd my-telegram-bot
|
|
24
|
+
npm init -y
|
|
25
25
|
npm install chz-telegram-bot
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
### 2. Create a token file
|
|
29
29
|
|
|
30
|
-
Create a file named
|
|
30
|
+
Create a file named `token.txt` in your project and paste your Telegram Bot token obtained from BotFather.
|
|
31
31
|
|
|
32
32
|
### 3. Create a basic bot
|
|
33
33
|
|
|
34
|
-
Create an
|
|
34
|
+
Create an `index.ts` file with the following content:
|
|
35
35
|
|
|
36
36
|
```typescript
|
|
37
|
-
import {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
|
|
37
|
+
import {
|
|
38
|
+
startBot,
|
|
39
|
+
stopBots,
|
|
40
|
+
CommandActionBuilder,
|
|
41
|
+
Seconds
|
|
42
|
+
} from 'chz-telegram-bot';
|
|
43
|
+
|
|
44
|
+
// Define your command actions
|
|
45
|
+
const commands = [
|
|
46
|
+
new CommandActionBuilder('HelloWorld')
|
|
47
|
+
.on('/hello')
|
|
48
|
+
.do(async (ctx) => {
|
|
49
|
+
ctx.replyWithText('Hello, world!');
|
|
50
|
+
})
|
|
51
|
+
.build()
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
// Define scheduled actions (if needed)
|
|
55
|
+
const scheduled = [];
|
|
56
|
+
|
|
57
|
+
async function main() {
|
|
58
|
+
// Start the bot
|
|
59
|
+
startBot({
|
|
60
|
+
name: 'MyFirstBot',
|
|
61
|
+
tokenFilePath: './token.txt',
|
|
62
|
+
commands: commands,
|
|
63
|
+
scheduled: scheduled,
|
|
64
|
+
chats: {
|
|
65
|
+
MyChat: -1001234567890 // Replace with your actual chat ID,
|
|
66
|
+
},
|
|
67
|
+
scheduledPeriod: (60 * 5) as Seconds
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Set up graceful shutdown
|
|
71
|
+
process.on('SIGINT', () => stopBots('SIGINT'));
|
|
72
|
+
process.on('SIGTERM', () => stopBots('SIGTERM'));
|
|
73
|
+
}
|
|
74
|
+
|
|
70
75
|
main().catch(console.error);
|
|
71
76
|
```
|
|
72
77
|
|
|
@@ -83,25 +88,27 @@ bun index.ts
|
|
|
83
88
|
Command actions are triggered by user messages that match specific patterns:
|
|
84
89
|
|
|
85
90
|
```typescript
|
|
86
|
-
import { CommandActionBuilder } from 'chz-telegram-bot';
|
|
87
|
-
|
|
88
|
-
const myCommand = new CommandActionBuilder('StartCommand')
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
import { CommandActionBuilder } from 'chz-telegram-bot';
|
|
92
|
+
|
|
93
|
+
const myCommand = new CommandActionBuilder('StartCommand')
|
|
94
|
+
.on('/start')
|
|
95
|
+
.do(async (ctx) => {
|
|
96
|
+
ctx.replyWithText('Welcome to my bot!');
|
|
97
|
+
})
|
|
98
|
+
.build();
|
|
94
99
|
```
|
|
100
|
+
|
|
95
101
|
Message types are also can trigger commands:
|
|
102
|
+
|
|
96
103
|
```typescript
|
|
97
|
-
import { CommandActionBuilder, MessageType } from 'chz-telegram-bot';
|
|
98
|
-
|
|
99
|
-
const myCommand = new CommandActionBuilder('WelcomeMessage')
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
import { CommandActionBuilder, MessageType } from 'chz-telegram-bot';
|
|
105
|
+
|
|
106
|
+
const myCommand = new CommandActionBuilder('WelcomeMessage')
|
|
107
|
+
.on(MessageType.NewChatMember)
|
|
108
|
+
.do(async (ctx) => {
|
|
109
|
+
ctx.replyWithText('Welcome to my group chat!');
|
|
110
|
+
})
|
|
111
|
+
.build();
|
|
105
112
|
```
|
|
106
113
|
|
|
107
114
|
### Scheduled Actions
|
|
@@ -109,63 +116,64 @@ const myCommand = new CommandActionBuilder('WelcomeMessage')
|
|
|
109
116
|
Scheduled actions run periodically without user interaction:
|
|
110
117
|
|
|
111
118
|
```typescript
|
|
112
|
-
import { ScheduledActionBuilder, Hours } from 'chz-telegram-bot';
|
|
113
|
-
|
|
114
|
-
const dailyNotification = new ScheduledActionBuilder('GM')
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
import { ScheduledActionBuilder, Hours } from 'chz-telegram-bot';
|
|
120
|
+
|
|
121
|
+
const dailyNotification = new ScheduledActionBuilder('GM')
|
|
122
|
+
.runAt(9 as Hours) // Run at 9 AM
|
|
123
|
+
.do(async (ctx) => {
|
|
124
|
+
ctx.sendTextToChat('Good morning!');
|
|
125
|
+
})
|
|
126
|
+
.build();
|
|
120
127
|
```
|
|
121
128
|
|
|
122
129
|
### Replies and message sending
|
|
123
|
-
Depending on a type of action, you will have access to following interaction options:
|
|
124
|
-
|
|
125
|
-
| Method | Action type | Description
|
|
126
|
-
|----------|----------------|-------
|
|
127
|
-
|`sendTextToChat`|Both|Send text to chat as a standalone message
|
|
128
|
-
|`sendImageToChat`|Both|Send image to chat as a standalone message
|
|
129
|
-
|`sendVideoToChat`|Both|Send video/gif to chat as a standalone message
|
|
130
|
-
|`unpinMessage`|Both|Unpins message by its ID
|
|
131
|
-
|`delayNextResponse`|Both|Delays next reply action my given amount of ms
|
|
132
|
-
|`replyWithText`|Command|Replies with text to a message that triggered an action
|
|
133
|
-
|`replyWithImage`|Command|Replies with image to a message that triggered an action
|
|
134
|
-
|`replyWithVideo`|Command|Replies with video/gif to a message that triggered an action
|
|
135
|
-
|`react`|Command|Sets an emoji reaction to a message that triggered an action
|
|
136
130
|
|
|
131
|
+
Depending on a type of action, you will have access to following interaction options:
|
|
137
132
|
|
|
138
|
-
|
|
133
|
+
| Method | Action type | Description |
|
|
134
|
+
| ----------------- | ----------- | ------------------------------------------------------------ |
|
|
135
|
+
| `sendTextToChat` | Both | Send text to chat as a standalone message |
|
|
136
|
+
| `sendImageToChat` | Both | Send image to chat as a standalone message |
|
|
137
|
+
| `sendVideoToChat` | Both | Send video/gif to chat as a standalone message |
|
|
138
|
+
| `unpinMessage` | Both | Unpins message by its ID |
|
|
139
|
+
| `wait` | Both | Delays next replies from this action by given amount of ms |
|
|
140
|
+
| `replyWithText` | Command | Replies with text to a message that triggered an action |
|
|
141
|
+
| `replyWithImage` | Command | Replies with image to a message that triggered an action |
|
|
142
|
+
| `replyWithVideo` | Command | Replies with video/gif to a message that triggered an action |
|
|
143
|
+
| `react` | Command | Sets an emoji reaction to a message that triggered an action |
|
|
144
|
+
|
|
145
|
+
Keep in mind that reply sending is deferred until action execution finished and will be done in order of calling in action handler.
|
|
139
146
|
Ex:
|
|
147
|
+
|
|
140
148
|
```typescript
|
|
141
|
-
ctx.sendTextToChat('Message 1')
|
|
142
|
-
ctx.
|
|
143
|
-
ctx.sendTextToChat('Message 2')
|
|
149
|
+
ctx.sendTextToChat('Message 1');
|
|
150
|
+
ctx.wait(5000 as Millisecond);
|
|
151
|
+
ctx.sendTextToChat('Message 2');
|
|
144
152
|
```
|
|
153
|
+
|
|
145
154
|
This will result in `Message 1` text being send, followed by `Message 2` after 5 second delay.
|
|
146
155
|
|
|
147
156
|
## Configuration Options
|
|
148
157
|
|
|
149
158
|
When starting a bot, you can provide the following configuration:
|
|
150
159
|
|
|
151
|
-
| Option
|
|
152
|
-
|
|
153
|
-
| `name`
|
|
154
|
-
| `tokenFilePath`
|
|
155
|
-
| `commands`
|
|
156
|
-
| `scheduled`
|
|
157
|
-
| `chats`
|
|
158
|
-
| `storagePath`
|
|
159
|
-
| `scheduledPeriod
|
|
160
|
-
| `services`
|
|
160
|
+
| Option | Type | Required | Description |
|
|
161
|
+
| ----------------- | ------------------------ | --------------------------- | ----------------------------------------------------------------------------------------- |
|
|
162
|
+
| `name` | `string` | Yes | Bot name used in logging |
|
|
163
|
+
| `tokenFilePath` | `string` | Yes | Path to file containing Telegram Bot token |
|
|
164
|
+
| `commands` | `CommandAction[] ` | Yes (can be empty) | Collection of command actions |
|
|
165
|
+
| `scheduled` | `ScheduledAction[]` | Yes (can be empty) | Collection of scheduled actions |
|
|
166
|
+
| `chats` | `Record<string, number>` | Yes | Object containing chat name-id pairs. Used for logging and execution of scheduled action. |
|
|
167
|
+
| `storagePath` | `string` | No | Custom storage path for default JsonFileStorage client |
|
|
168
|
+
| `scheduledPeriod` | `Seconds` | No (will default to 1 hour) | Period between scheduled action executions |
|
|
169
|
+
| `services` | | No | Custom services to be used instead of default ones |
|
|
161
170
|
|
|
162
171
|
Services object should have following structure:
|
|
163
|
-
| Option
|
|
172
|
+
| Option | Type | Required | Description |
|
|
164
173
|
|------------------|--------------------------|----------|---------------------------------------------------------------|
|
|
165
|
-
| `storageClient`
|
|
166
|
-
| `logger`
|
|
167
|
-
| `scheduler`
|
|
168
|
-
|
|
174
|
+
| `storageClient` | `IStorageClient` | No (will default to `JsonFileStorage`) | Persistance state provide |
|
|
175
|
+
| `logger` | `ILogger` | No (will default to `JsonLogger`) | Logger service |
|
|
176
|
+
| `scheduler` | `IScheduler` | No (will default to `NodeTimeoutScheduler`) | Scheduler used to scheduled action|
|
|
169
177
|
|
|
170
178
|
## Advanced Usage
|
|
171
179
|
|
|
@@ -174,23 +182,24 @@ Services object should have following structure:
|
|
|
174
182
|
The framework allows you to create custom state for your actions:
|
|
175
183
|
|
|
176
184
|
```typescript
|
|
177
|
-
import { ActionStateBase } from 'chz-telegram-bot';
|
|
178
|
-
|
|
179
|
-
class MyCustomState extends ActionStateBase {
|
|
180
|
-
|
|
181
|
-
}
|
|
182
|
-
|
|
185
|
+
import { ActionStateBase } from 'chz-telegram-bot';
|
|
186
|
+
|
|
187
|
+
class MyCustomState extends ActionStateBase {
|
|
188
|
+
counter: number = 0;
|
|
189
|
+
}
|
|
190
|
+
|
|
183
191
|
const counterCommand = new CommandActionBuilderWithState<MyCustomState>(
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
'Counter',
|
|
193
|
+
() => new MyCustomState()
|
|
194
|
+
)
|
|
195
|
+
.on('/count')
|
|
196
|
+
.do(async (ctx, state) => {
|
|
197
|
+
state.counter++;
|
|
198
|
+
ctx.replyWithText(`Count: ${state.counter}`);
|
|
199
|
+
})
|
|
200
|
+
.build();
|
|
193
201
|
```
|
|
202
|
+
|
|
194
203
|
State is mutable and all changes to it will be saved after execution of action is finished.
|
|
195
204
|
|
|
196
205
|
## Stopping the Bot
|
|
@@ -198,8 +207,8 @@ State is mutable and all changes to it will be saved after execution of action i
|
|
|
198
207
|
To properly terminate your bot and clean up resources:
|
|
199
208
|
|
|
200
209
|
```typescript
|
|
201
|
-
import { stopBots } from 'chz-telegram-bot';
|
|
202
|
-
|
|
203
|
-
// Call when your application is shutting down
|
|
210
|
+
import { stopBots } from 'chz-telegram-bot';
|
|
211
|
+
|
|
212
|
+
// Call when your application is shutting down
|
|
204
213
|
await stopBots('SHUTDOWN');
|
|
205
214
|
```
|
|
@@ -6,6 +6,7 @@ import { TraceId } from '../../types/trace';
|
|
|
6
6
|
import { ChatInfo } from '../chatInfo';
|
|
7
7
|
export declare class DelayResponse implements IChatResponse {
|
|
8
8
|
readonly kind: "delay";
|
|
9
|
+
readonly createdAt: number;
|
|
9
10
|
readonly chatInfo: ChatInfo;
|
|
10
11
|
readonly traceId: TraceId;
|
|
11
12
|
readonly delay: Milliseconds;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../dtos/responses/delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;
|
|
1
|
+
{"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../dtos/responses/delay.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class DelayResponse {
|
|
6
6
|
constructor(delay, chatInfo, traceId, action) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.delay;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.chatInfo = chatInfo;
|
|
9
10
|
this.delay = delay;
|
|
10
11
|
this.traceId = traceId;
|
|
@@ -7,6 +7,7 @@ import { ChatInfo } from '../chatInfo';
|
|
|
7
7
|
import { TraceId } from '../../types/trace';
|
|
8
8
|
export declare class ImageMessage implements IReplyMessage<InputFile> {
|
|
9
9
|
readonly kind: "image";
|
|
10
|
+
readonly createdAt: number;
|
|
10
11
|
readonly content: InputFile;
|
|
11
12
|
readonly chatInfo: ChatInfo;
|
|
12
13
|
readonly replyId: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;
|
|
1
|
+
{"version":3,"file":"imageMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/imageMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class ImageMessage {
|
|
6
6
|
constructor(image, chatInfo, replyId, traceId, action, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.image;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.disableWebPreview = false;
|
|
9
10
|
this.content = image;
|
|
10
11
|
this.chatInfo = chatInfo;
|
|
@@ -6,6 +6,7 @@ import { ChatInfo } from '../chatInfo';
|
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
|
7
7
|
export declare class Reaction implements IChatResponse {
|
|
8
8
|
readonly kind: "react";
|
|
9
|
+
readonly createdAt: number;
|
|
9
10
|
readonly chatInfo: ChatInfo;
|
|
10
11
|
readonly messageId: number;
|
|
11
12
|
readonly traceId: TraceId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../dtos/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,QAAS,YAAW,aAAa;IAC1C,QAAQ,CAAC,IAAI,UAA0B;
|
|
1
|
+
{"version":3,"file":"reaction.d.ts","sourceRoot":"","sources":["../../../dtos/responses/reaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,QAAS,YAAW,aAAa;IAC1C,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAQ7C"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class Reaction {
|
|
6
6
|
constructor(traceId, chatInfo, messageId, emoji, action) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.react;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.chatInfo = chatInfo;
|
|
9
10
|
this.messageId = messageId;
|
|
10
11
|
this.emoji = emoji;
|
|
@@ -6,6 +6,7 @@ import { ChatInfo } from '../chatInfo';
|
|
|
6
6
|
import { TraceId } from '../../types/trace';
|
|
7
7
|
export declare class TextMessage implements IReplyMessage<string> {
|
|
8
8
|
readonly kind: "text";
|
|
9
|
+
readonly createdAt: number;
|
|
9
10
|
readonly content: string;
|
|
10
11
|
readonly chatInfo: ChatInfo;
|
|
11
12
|
readonly replyId: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,QAAQ,CAAC,IAAI,SAAyB;
|
|
1
|
+
{"version":3,"file":"textMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/textMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,WAAY,YAAW,aAAa,CAAC,MAAM,CAAC;IACrD,QAAQ,CAAC,IAAI,SAAyB;IACtC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,yBAAyB;CAU1C"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class TextMessage {
|
|
6
6
|
constructor(text, chatInfo, replyId, traceId, action, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.text;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.content = text;
|
|
9
10
|
this.chatInfo = chatInfo;
|
|
10
11
|
this.replyId = replyId;
|
|
@@ -5,6 +5,7 @@ import { ChatInfo } from '../chatInfo';
|
|
|
5
5
|
import { TraceId } from '../../types/trace';
|
|
6
6
|
export declare class UnpinResponse implements IChatResponse {
|
|
7
7
|
readonly kind: "unpin";
|
|
8
|
+
readonly createdAt: number;
|
|
8
9
|
readonly messageId: number;
|
|
9
10
|
readonly chatInfo: ChatInfo;
|
|
10
11
|
readonly traceId: TraceId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../dtos/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;
|
|
1
|
+
{"version":3,"file":"unpin.d.ts","sourceRoot":"","sources":["../../../dtos/responses/unpin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,aAAc,YAAW,aAAa;IAC/C,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC;CAO7C"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class UnpinResponse {
|
|
6
6
|
constructor(messageId, chatInfo, traceId, action) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.unpin;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.messageId = messageId;
|
|
9
10
|
this.chatInfo = chatInfo;
|
|
10
11
|
this.traceId = traceId;
|
|
@@ -7,6 +7,7 @@ import { ChatInfo } from '../chatInfo';
|
|
|
7
7
|
import { TraceId } from '../../types/trace';
|
|
8
8
|
export declare class VideoMessage implements IReplyMessage<InputFile> {
|
|
9
9
|
readonly kind: "video";
|
|
10
|
+
readonly createdAt: number;
|
|
10
11
|
readonly content: InputFile;
|
|
11
12
|
readonly chatInfo: ChatInfo;
|
|
12
13
|
readonly replyId: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;
|
|
1
|
+
{"version":3,"file":"videoMessage.d.ts","sourceRoot":"","sources":["../../../dtos/responses/videoMessage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAoB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,YAAa,YAAW,aAAa,CAAC,SAAS,CAAC;IACzD,QAAQ,CAAC,IAAI,UAA0B;IACvC,QAAQ,CAAC,SAAS,SAAc;IAEhC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,iBAAiB,SAAS;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;gBAG5C,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,OAAO,CAAC,EAAE,qBAAqB;CAStC"}
|
|
@@ -5,6 +5,7 @@ const response_1 = require("../../types/response");
|
|
|
5
5
|
class VideoMessage {
|
|
6
6
|
constructor(video, chatInfo, replyId, traceId, action, options) {
|
|
7
7
|
this.kind = response_1.BotResponseTypes.video;
|
|
8
|
+
this.createdAt = Date.now();
|
|
8
9
|
this.disableWebPreview = false;
|
|
9
10
|
this.content = video;
|
|
10
11
|
this.chatInfo = chatInfo;
|
|
@@ -97,7 +97,7 @@ class BotInstance {
|
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
|
|
100
|
+
this.api.flushResponses();
|
|
101
101
|
}
|
|
102
102
|
async processMessage(msg) {
|
|
103
103
|
const ctx = new messageContext_1.MessageContext(this.storage, this.logger, this.scheduler);
|
|
@@ -112,7 +112,7 @@ class BotInstance {
|
|
|
112
112
|
this.logger.errorWithTraceId(ctx.botName, ctx.traceId, ctx.chatInfo.name, error, ctx);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
this.api.flushResponses();
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
exports.BotInstance = BotInstance;
|
|
@@ -58,9 +58,9 @@ export declare class ChatContext<TActionState extends IActionState> {
|
|
|
58
58
|
*/
|
|
59
59
|
unpinMessage(messageId: number): void;
|
|
60
60
|
/**
|
|
61
|
-
* Delays next
|
|
61
|
+
* Delays next responses by specified amount of time.
|
|
62
62
|
* @param delay Delay in milliseconds.
|
|
63
63
|
*/
|
|
64
|
-
|
|
64
|
+
wait(delay: Milliseconds): void;
|
|
65
65
|
}
|
|
66
66
|
//# sourceMappingURL=chatContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBAAa,WAAW,CAAC,YAAY,SAAS,YAAY;IACtD,SAAS,CAAC,MAAM,EAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAElD,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAG,cAAc,CAAC;IAClC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAG,UAAU,CAAC;IAEhC,sCAAsC;IACtC,OAAO,EAAG,OAAO,CAAC;IAClB,+CAA+C;IAC/C,OAAO,EAAG,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAG,QAAQ,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,WAAW,EAAE,CAAM;IAE9B,aAAa,UAAS;gBAGlB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAOzB,qBAAqB,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;IAapB;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAahE;;;;;OAKG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;;;OAKG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,
|
|
1
|
+
{"version":3,"file":"chatContext.d.ts","sourceRoot":"","sources":["../../../entities/context/chatContext.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAKrD,OAAO,EACH,qBAAqB,EACrB,yBAAyB,EAC5B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;GAEG;AACH,qBAAa,WAAW,CAAC,YAAY,SAAS,YAAY;IACtD,SAAS,CAAC,MAAM,EAAG,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAElD,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAG,cAAc,CAAC;IAClC,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAG,OAAO,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,SAAS,EAAG,UAAU,CAAC;IAEhC,sCAAsC;IACtC,OAAO,EAAG,OAAO,CAAC;IAClB,+CAA+C;IAC/C,OAAO,EAAG,MAAM,CAAC;IACjB,wBAAwB;IACxB,QAAQ,EAAG,QAAQ,CAAC;IACpB,uDAAuD;IACvD,SAAS,EAAE,WAAW,EAAE,CAAM;IAE9B,aAAa,UAAS;gBAGlB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO,EACf,SAAS,EAAE,UAAU;IAOzB,qBAAqB,CACjB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,EACtC,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO;IAapB;;;;;OAKG;IACH,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB;IAahE;;;;;OAKG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;;;OAKG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAc7D;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM;IAW9B;;;OAGG;IACH,IAAI,CAAC,KAAK,EAAE,YAAY;CAK3B"}
|
|
@@ -66,10 +66,10 @@ class ChatContext {
|
|
|
66
66
|
this.responses.push(new unpin_1.UnpinResponse(messageId, this.chatInfo, this.traceId, this.action));
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Delays next
|
|
69
|
+
* Delays next responses by specified amount of time.
|
|
70
70
|
* @param delay Delay in milliseconds.
|
|
71
71
|
*/
|
|
72
|
-
|
|
72
|
+
wait(delay) {
|
|
73
73
|
this.responses.push(new delay_1.DelayResponse(delay, this.chatInfo, this.traceId, this.action));
|
|
74
74
|
}
|
|
75
75
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type QueueItem = {
|
|
2
|
+
priority: number;
|
|
3
|
+
callback: () => Promise<void>;
|
|
4
|
+
};
|
|
5
|
+
export declare class ResponseProcessingQueue {
|
|
6
|
+
items: QueueItem[];
|
|
7
|
+
isFlushing: boolean;
|
|
8
|
+
enqueue(item: QueueItem): void;
|
|
9
|
+
flushReadyItems(): Promise<void>;
|
|
10
|
+
private peek;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=responseProcessingQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"responseProcessingQueue.d.ts","sourceRoot":"","sources":["../../services/responseProcessingQueue.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAAC;AAIF,qBAAa,uBAAuB;IAChC,KAAK,EAAE,SAAS,EAAE,CAAM;IACxB,UAAU,UAAS;IAEnB,OAAO,CAAC,IAAI,EAAE,SAAS;IAmBjB,eAAe;IAoBrB,OAAO,CAAC,IAAI;CAGf"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ResponseProcessingQueue = void 0;
|
|
4
|
+
const promises_1 = require("timers/promises");
|
|
5
|
+
const TELEGRAM_RATELIMIT_DELAY = 35;
|
|
6
|
+
class ResponseProcessingQueue {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.items = [];
|
|
9
|
+
this.isFlushing = false;
|
|
10
|
+
}
|
|
11
|
+
enqueue(item) {
|
|
12
|
+
if (this.items.length === 0 ||
|
|
13
|
+
item.priority >= this.items[this.items.length - 1].priority) {
|
|
14
|
+
this.items.push(item);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
let insertIndex = this.items.length;
|
|
18
|
+
while (insertIndex > 0 &&
|
|
19
|
+
this.items[insertIndex - 1].priority > item.priority) {
|
|
20
|
+
insertIndex--;
|
|
21
|
+
}
|
|
22
|
+
this.items.splice(insertIndex, 0, item);
|
|
23
|
+
}
|
|
24
|
+
async flushReadyItems() {
|
|
25
|
+
if (this.isFlushing)
|
|
26
|
+
return;
|
|
27
|
+
this.isFlushing = true;
|
|
28
|
+
while (this.items.length) {
|
|
29
|
+
if (Date.now() >= this.peek().priority) {
|
|
30
|
+
const item = this.items.shift();
|
|
31
|
+
if (!item)
|
|
32
|
+
return;
|
|
33
|
+
await item.callback();
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
await (0, promises_1.setTimeout)(TELEGRAM_RATELIMIT_DELAY);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
this.isFlushing = false;
|
|
40
|
+
}
|
|
41
|
+
peek() {
|
|
42
|
+
return this.items[0];
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.ResponseProcessingQueue = ResponseProcessingQueue;
|
|
@@ -3,15 +3,14 @@ import { BotResponse } from '../types/response';
|
|
|
3
3
|
import { Telegram } from 'telegraf/typings/telegram';
|
|
4
4
|
import { ILogger } from '../types/logger';
|
|
5
5
|
export declare class TelegramApiService {
|
|
6
|
+
private readonly queue;
|
|
6
7
|
private readonly telegram;
|
|
7
8
|
private readonly storage;
|
|
8
9
|
private readonly logger;
|
|
9
10
|
private readonly botName;
|
|
10
|
-
private readonly messageQueue;
|
|
11
|
-
isFlushing: boolean;
|
|
12
11
|
constructor(botName: string, telegram: Telegram, storage: IStorageClient, logger: ILogger);
|
|
13
12
|
enqueueBatchedResponses(responses: BotResponse[]): void;
|
|
14
|
-
flushResponses():
|
|
13
|
+
flushResponses(): void;
|
|
15
14
|
private pinIfShould;
|
|
16
15
|
private processResponse;
|
|
17
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,qBAAa,kBAAkB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAiC;IACvD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAW;IACpC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAU;IAEjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAG7B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,EACvB,MAAM,EAAE,OAAO;IAQnB,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE;IA4BhD,cAAc;YAIA,WAAW;YAqBX,eAAe;CA4EhC"}
|
|
@@ -1,39 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TelegramApiService = void 0;
|
|
4
|
-
const
|
|
5
|
-
const TELEGRAM_RATELIMIT_DELAY = 35;
|
|
4
|
+
const responseProcessingQueue_1 = require("./responseProcessingQueue");
|
|
6
5
|
class TelegramApiService {
|
|
7
6
|
constructor(botName, telegram, storage, logger) {
|
|
8
|
-
this.
|
|
9
|
-
this.isFlushing = false;
|
|
7
|
+
this.queue = new responseProcessingQueue_1.ResponseProcessingQueue();
|
|
10
8
|
this.telegram = telegram;
|
|
11
9
|
this.botName = botName;
|
|
12
10
|
this.storage = storage;
|
|
13
11
|
this.logger = logger;
|
|
14
12
|
}
|
|
15
13
|
enqueueBatchedResponses(responses) {
|
|
14
|
+
let offset = 0;
|
|
16
15
|
for (const response of responses) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
async flushResponses() {
|
|
21
|
-
if (this.isFlushing)
|
|
22
|
-
return;
|
|
23
|
-
this.isFlushing = true;
|
|
24
|
-
while (this.messageQueue.length) {
|
|
25
|
-
const message = this.messageQueue.shift();
|
|
26
|
-
if (!message)
|
|
27
|
-
break;
|
|
28
|
-
try {
|
|
29
|
-
await this.processResponse(message);
|
|
30
|
-
await (0, promises_1.setTimeout)(TELEGRAM_RATELIMIT_DELAY);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
this.logger.errorWithTraceId(this.botName, message.traceId, message.chatInfo.name, error, message);
|
|
16
|
+
if (response.kind == 'delay') {
|
|
17
|
+
offset += response.delay;
|
|
18
|
+
continue;
|
|
34
19
|
}
|
|
20
|
+
const queueItem = {
|
|
21
|
+
callback: async () => {
|
|
22
|
+
try {
|
|
23
|
+
await this.processResponse(response);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
this.logger.errorWithTraceId(this.botName, response.traceId, response.chatInfo.name, error, response);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
priority: response.createdAt + offset
|
|
30
|
+
};
|
|
31
|
+
this.queue.enqueue(queueItem);
|
|
35
32
|
}
|
|
36
|
-
|
|
33
|
+
}
|
|
34
|
+
flushResponses() {
|
|
35
|
+
this.queue.flushReadyItems();
|
|
37
36
|
}
|
|
38
37
|
async pinIfShould(response, sentMessage) {
|
|
39
38
|
if (response.shouldPin) {
|
|
@@ -84,9 +83,7 @@ class TelegramApiService {
|
|
|
84
83
|
});
|
|
85
84
|
break;
|
|
86
85
|
case 'delay':
|
|
87
|
-
|
|
88
|
-
await (0, promises_1.setTimeout)(response.delay - TELEGRAM_RATELIMIT_DELAY);
|
|
89
|
-
}
|
|
86
|
+
break;
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
89
|
}
|
package/dist/types/response.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface IChatResponse {
|
|
|
21
21
|
readonly kind: keyof typeof BotResponseTypes;
|
|
22
22
|
readonly chatInfo: ChatInfo;
|
|
23
23
|
readonly traceId: TraceId;
|
|
24
|
+
readonly createdAt: number;
|
|
24
25
|
readonly action: IActionWithState<IActionState>;
|
|
25
26
|
}
|
|
26
27
|
export interface IReplyMessage<TType> extends IChatResponse {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"response.d.ts","sourceRoot":"","sources":["../../types/response.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,eAAO,MAAM,gBAAgB;;;;;;;CAOnB,CAAC;AAEX,MAAM,MAAM,WAAW,GACjB,aAAa,GACb,QAAQ,GACR,WAAW,GACX,YAAY,GACZ,aAAa,GACb,YAAY,CAAC;AAEnB,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,gBAAgB,CAAC;IAC7C,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,YAAY,CAAC,CAAC;CACnD;AAED,MAAM,WAAW,aAAa,CAAC,KAAK,CAAE,SAAQ,aAAa;IACvD,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,iBAAiB,EAAE,OAAO,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC/B"}
|
package/dtos/responses/delay.ts
CHANGED
package/dtos/responses/unpin.ts
CHANGED
package/entities/botInstance.ts
CHANGED
|
@@ -212,7 +212,7 @@ export class BotInstance {
|
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
this.api.flushResponses();
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
private async processMessage(msg: IncomingMessage) {
|
|
@@ -240,6 +240,6 @@ export class BotInstance {
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
|
|
243
|
+
this.api.flushResponses();
|
|
244
244
|
}
|
|
245
245
|
}
|
|
@@ -145,10 +145,10 @@ export class ChatContext<TActionState extends IActionState> {
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* Delays next
|
|
148
|
+
* Delays next responses by specified amount of time.
|
|
149
149
|
* @param delay Delay in milliseconds.
|
|
150
150
|
*/
|
|
151
|
-
|
|
151
|
+
wait(delay: Milliseconds) {
|
|
152
152
|
this.responses.push(
|
|
153
153
|
new DelayResponse(delay, this.chatInfo, this.traceId, this.action)
|
|
154
154
|
);
|
package/package.json
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { setTimeout } from 'timers/promises';
|
|
2
|
+
import { Milliseconds } from '../types/timeValues';
|
|
3
|
+
|
|
4
|
+
export type QueueItem = {
|
|
5
|
+
priority: number;
|
|
6
|
+
callback: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const TELEGRAM_RATELIMIT_DELAY = 35 as Milliseconds;
|
|
10
|
+
|
|
11
|
+
export class ResponseProcessingQueue {
|
|
12
|
+
items: QueueItem[] = [];
|
|
13
|
+
isFlushing = false;
|
|
14
|
+
|
|
15
|
+
enqueue(item: QueueItem) {
|
|
16
|
+
if (
|
|
17
|
+
this.items.length === 0 ||
|
|
18
|
+
item.priority >= this.items[this.items.length - 1]!.priority
|
|
19
|
+
) {
|
|
20
|
+
this.items.push(item);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let insertIndex = this.items.length;
|
|
25
|
+
while (
|
|
26
|
+
insertIndex > 0 &&
|
|
27
|
+
this.items[insertIndex - 1]!.priority > item.priority
|
|
28
|
+
) {
|
|
29
|
+
insertIndex--;
|
|
30
|
+
}
|
|
31
|
+
this.items.splice(insertIndex, 0, item);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async flushReadyItems() {
|
|
35
|
+
if (this.isFlushing) return;
|
|
36
|
+
|
|
37
|
+
this.isFlushing = true;
|
|
38
|
+
|
|
39
|
+
while (this.items.length) {
|
|
40
|
+
if (Date.now() >= this.peek()!.priority) {
|
|
41
|
+
const item = this.items.shift();
|
|
42
|
+
|
|
43
|
+
if (!item) return;
|
|
44
|
+
|
|
45
|
+
await item.callback();
|
|
46
|
+
} else {
|
|
47
|
+
await setTimeout(TELEGRAM_RATELIMIT_DELAY);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
this.isFlushing = false;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private peek() {
|
|
55
|
+
return this.items[0];
|
|
56
|
+
}
|
|
57
|
+
}
|
package/services/telegramApi.ts
CHANGED
|
@@ -2,20 +2,16 @@ import { Message } from 'telegraf/types';
|
|
|
2
2
|
import { IStorageClient } from '../types/storage';
|
|
3
3
|
import { BotResponse, IReplyMessage } from '../types/response';
|
|
4
4
|
import { Telegram } from 'telegraf/typings/telegram';
|
|
5
|
-
import { setTimeout } from 'timers/promises';
|
|
6
|
-
import { Milliseconds } from '../types/timeValues';
|
|
7
5
|
import { ILogger } from '../types/logger';
|
|
8
|
-
|
|
9
|
-
const TELEGRAM_RATELIMIT_DELAY = 35 as Milliseconds;
|
|
6
|
+
import { QueueItem, ResponseProcessingQueue } from './responseProcessingQueue';
|
|
10
7
|
|
|
11
8
|
export class TelegramApiService {
|
|
9
|
+
private readonly queue = new ResponseProcessingQueue();
|
|
12
10
|
private readonly telegram: Telegram;
|
|
13
11
|
private readonly storage: IStorageClient;
|
|
14
12
|
private readonly logger: ILogger;
|
|
15
13
|
|
|
16
14
|
private readonly botName: string;
|
|
17
|
-
private readonly messageQueue: BotResponse[] = [];
|
|
18
|
-
isFlushing = false;
|
|
19
15
|
|
|
20
16
|
constructor(
|
|
21
17
|
botName: string,
|
|
@@ -30,36 +26,35 @@ export class TelegramApiService {
|
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
enqueueBatchedResponses(responses: BotResponse[]) {
|
|
29
|
+
let offset = 0;
|
|
33
30
|
for (const response of responses) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
async flushResponses() {
|
|
39
|
-
if (this.isFlushing) return;
|
|
40
|
-
|
|
41
|
-
this.isFlushing = true;
|
|
42
|
-
|
|
43
|
-
while (this.messageQueue.length) {
|
|
44
|
-
const message = this.messageQueue.shift();
|
|
45
|
-
|
|
46
|
-
if (!message) break;
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
await this.processResponse(message);
|
|
50
|
-
await setTimeout(TELEGRAM_RATELIMIT_DELAY);
|
|
51
|
-
} catch (error) {
|
|
52
|
-
this.logger.errorWithTraceId(
|
|
53
|
-
this.botName,
|
|
54
|
-
message.traceId,
|
|
55
|
-
message.chatInfo.name,
|
|
56
|
-
error,
|
|
57
|
-
message
|
|
58
|
-
);
|
|
31
|
+
if (response.kind == 'delay') {
|
|
32
|
+
offset += response.delay;
|
|
33
|
+
continue;
|
|
59
34
|
}
|
|
35
|
+
|
|
36
|
+
const queueItem: QueueItem = {
|
|
37
|
+
callback: async () => {
|
|
38
|
+
try {
|
|
39
|
+
await this.processResponse(response);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
this.logger.errorWithTraceId(
|
|
42
|
+
this.botName,
|
|
43
|
+
response.traceId,
|
|
44
|
+
response.chatInfo.name,
|
|
45
|
+
error,
|
|
46
|
+
response
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
priority: response.createdAt + offset
|
|
51
|
+
};
|
|
52
|
+
this.queue.enqueue(queueItem);
|
|
60
53
|
}
|
|
54
|
+
}
|
|
61
55
|
|
|
62
|
-
|
|
56
|
+
flushResponses() {
|
|
57
|
+
this.queue.flushReadyItems();
|
|
63
58
|
}
|
|
64
59
|
|
|
65
60
|
private async pinIfShould<T>(
|
|
@@ -156,9 +151,7 @@ export class TelegramApiService {
|
|
|
156
151
|
);
|
|
157
152
|
break;
|
|
158
153
|
case 'delay':
|
|
159
|
-
|
|
160
|
-
await setTimeout(response.delay - TELEGRAM_RATELIMIT_DELAY);
|
|
161
|
-
}
|
|
154
|
+
break;
|
|
162
155
|
}
|
|
163
156
|
}
|
|
164
157
|
}
|
package/types/response.ts
CHANGED