chz-telegram-bot 0.0.48 → 0.0.49
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAiB,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,qCAAqC,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAIlE,qBAAa,kBAAkB;IAC3B,UAAU,UAAS;IACnB,YAAY,EAAE,WAAW,EAAE,CAAM;IAEjC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,QAAQ,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,OAAO,EAAE,cAAc,CAAC;gBAGpB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,cAAc,EACvB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;IAQjC,uBAAuB,CAAC,SAAS,EAAE,WAAW,EAAE;IAM1C,cAAc;
|
|
1
|
+
{"version":3,"file":"telegramApi.d.ts","sourceRoot":"","sources":["../../services/telegramApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;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|
|
24
24
|
return;
|
|
25
25
|
this.isFlushing = true;
|
|
26
|
+
console.log(`Flushing ${this.messageQueue.length} messages for ${this.botName}`);
|
|
26
27
|
while (this.messageQueue.length) {
|
|
27
28
|
const message = this.messageQueue.pop();
|
|
28
29
|
if (!message)
|
|
29
30
|
break;
|
|
30
31
|
try {
|
|
32
|
+
console.log(`Sending message ${message.kind} to ${message.chatId} for ${this.botName}`);
|
|
31
33
|
await this.processResponse(message);
|
|
32
34
|
await (0, promises_1.setTimeout)(TELEGRAM_RATELIMIT_DELAY);
|
|
33
35
|
}
|
|
@@ -85,6 +87,10 @@ class TelegramApiService {
|
|
|
85
87
|
state.pinnedMessages = state.pinnedMessages.filter((x) => x != response.messageId);
|
|
86
88
|
});
|
|
87
89
|
break;
|
|
90
|
+
case 'delay':
|
|
91
|
+
if (response.delay > TELEGRAM_RATELIMIT_DELAY) {
|
|
92
|
+
await (0, promises_1.setTimeout)(response.delay - TELEGRAM_RATELIMIT_DELAY);
|
|
93
|
+
}
|
|
88
94
|
}
|
|
89
95
|
}
|
|
90
96
|
initializeContextForMessage(ctx, incomingMessage, command) {
|
package/package.json
CHANGED
package/services/telegramApi.ts
CHANGED
|
@@ -47,12 +47,18 @@ export class TelegramApiService {
|
|
|
47
47
|
|
|
48
48
|
this.isFlushing = true;
|
|
49
49
|
|
|
50
|
+
console.log(
|
|
51
|
+
`Flushing ${this.messageQueue.length} messages for ${this.botName}`
|
|
52
|
+
);
|
|
50
53
|
while (this.messageQueue.length) {
|
|
51
54
|
const message = this.messageQueue.pop();
|
|
52
55
|
|
|
53
56
|
if (!message) break;
|
|
54
57
|
|
|
55
58
|
try {
|
|
59
|
+
console.log(
|
|
60
|
+
`Sending message ${message.kind} to ${message.chatId} for ${this.botName}`
|
|
61
|
+
);
|
|
56
62
|
await this.processResponse(message);
|
|
57
63
|
await setTimeout(TELEGRAM_RATELIMIT_DELAY);
|
|
58
64
|
} catch (error) {
|
|
@@ -162,6 +168,10 @@ export class TelegramApiService {
|
|
|
162
168
|
}
|
|
163
169
|
);
|
|
164
170
|
break;
|
|
171
|
+
case 'delay':
|
|
172
|
+
if (response.delay > TELEGRAM_RATELIMIT_DELAY) {
|
|
173
|
+
await setTimeout(response.delay - TELEGRAM_RATELIMIT_DELAY);
|
|
174
|
+
}
|
|
165
175
|
}
|
|
166
176
|
}
|
|
167
177
|
|