@iletai/nzb 1.2.4 → 1.2.6
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/dist/telegram/bot.js +11 -1
- package/package.json +2 -1
package/dist/telegram/bot.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { autoRetry } from "@grammyjs/auto-retry";
|
|
1
2
|
import { Bot, InlineKeyboard } from "grammy";
|
|
2
3
|
import { Agent as HttpsAgent } from "https";
|
|
3
4
|
import { config, persistEnvVar, persistModel } from "../config.js";
|
|
@@ -42,6 +43,8 @@ export function createBot() {
|
|
|
42
43
|
});
|
|
43
44
|
console.log("[nzb] Telegram bot using direct HTTPS agent (proxy bypass)");
|
|
44
45
|
initLogChannel(bot);
|
|
46
|
+
// Auto-retry on rate limit (429) and server errors (500+)
|
|
47
|
+
bot.api.config.use(autoRetry({ maxRetryAttempts: 3, maxDelaySeconds: 10 }));
|
|
45
48
|
// Auth middleware — only allow the authorized user
|
|
46
49
|
bot.use(async (ctx, next) => {
|
|
47
50
|
if (config.authorizedUserId !== undefined && ctx.from?.id !== config.authorizedUserId) {
|
|
@@ -375,7 +378,14 @@ export function createBot() {
|
|
|
375
378
|
const onUsage = (usage) => {
|
|
376
379
|
usageInfo = usage;
|
|
377
380
|
};
|
|
378
|
-
|
|
381
|
+
// If user replies to a message, include that message's text as context
|
|
382
|
+
let userPrompt = ctx.message.text;
|
|
383
|
+
const replyMsg = ctx.message.reply_to_message;
|
|
384
|
+
if (replyMsg && "text" in replyMsg && replyMsg.text) {
|
|
385
|
+
const quoted = replyMsg.text.length > 500 ? replyMsg.text.slice(0, 500) + "…" : replyMsg.text;
|
|
386
|
+
userPrompt = `[Replying to: "${quoted}"]\n\n${userPrompt}`;
|
|
387
|
+
}
|
|
388
|
+
sendToOrchestrator(userPrompt, { type: "telegram", chatId, messageId: userMessageId }, (text, done) => {
|
|
379
389
|
if (done) {
|
|
380
390
|
finalized = true;
|
|
381
391
|
stopTyping();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iletai/nzb",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "NZB — a personal AI assistant for developers, built on the GitHub Copilot SDK",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nzb": "dist/cli.js"
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"type": "module",
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@github/copilot-sdk": "^0.1.26",
|
|
50
|
+
"@grammyjs/auto-retry": "^2.0.2",
|
|
50
51
|
"better-sqlite3": "^12.6.2",
|
|
51
52
|
"dotenv": "^17.3.1",
|
|
52
53
|
"express": "^5.2.1",
|