claude-telegram-bot 0.3.4 → 0.3.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/bot.mjs +34 -5
- package/package.json +1 -1
package/bot.mjs
CHANGED
|
@@ -315,6 +315,19 @@ function checkLocalLock() {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
+
// ── npm 최신 버전 확인 (/status 에서 사용) ────────────────────────────────
|
|
319
|
+
async function fetchLatestVersion() {
|
|
320
|
+
try {
|
|
321
|
+
const r = await fetch("https://registry.npmjs.org/claude-telegram-bot/latest", {
|
|
322
|
+
signal: AbortSignal.timeout(5000),
|
|
323
|
+
});
|
|
324
|
+
if (!r.ok) return null;
|
|
325
|
+
return (await r.json()).version || null;
|
|
326
|
+
} catch {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
318
331
|
// ── 퍼시스턴트 메모리 ─────────────────────────────────────────────────────
|
|
319
332
|
// /new 로 세션을 초기화해도 유지되는 메모리. runClaude 시 시스템 프롬프트에 주입.
|
|
320
333
|
function loadMemory() {
|
|
@@ -441,6 +454,20 @@ async function send(chatId, text) {
|
|
|
441
454
|
}
|
|
442
455
|
}
|
|
443
456
|
|
|
457
|
+
// ── Claude 에러 분류 ──────────────────────────────────────────────────────
|
|
458
|
+
function classifyClaudeError(raw, code) {
|
|
459
|
+
const t = raw.toLowerCase();
|
|
460
|
+
if (t.includes("credit") || t.includes("balance") || t.includes("billing") || t.includes("payment"))
|
|
461
|
+
return "💳 API 크레딧이 부족합니다. console.anthropic.com 에서 충전해주세요.";
|
|
462
|
+
if (t.includes("rate_limit") || t.includes("rate limit") || t.includes("too many requests") || code === 429)
|
|
463
|
+
return "⏱️ 요청이 너무 많습니다. 잠시 후 다시 시도해주세요.";
|
|
464
|
+
if (t.includes("overloaded") || code === 529)
|
|
465
|
+
return "🔄 Claude 서버가 일시적으로 과부하 상태입니다. 잠시 후 다시 시도해주세요.";
|
|
466
|
+
if (t.includes("context") && (t.includes("length") || t.includes("limit") || t.includes("window")))
|
|
467
|
+
return "📏 대화 맥락이 너무 길어졌습니다. `/new` 로 새 세션을 시작해주세요.";
|
|
468
|
+
return `Execution error (exit ${code}):\n${raw}`;
|
|
469
|
+
}
|
|
470
|
+
|
|
444
471
|
// ── Claude 실행 ───────────────────────────────────────────────────────────
|
|
445
472
|
function runClaude(prompt, sessionId, opts = {}) {
|
|
446
473
|
return new Promise((resolve) => {
|
|
@@ -498,10 +525,8 @@ function runClaude(prompt, sessionId, opts = {}) {
|
|
|
498
525
|
cost: j.total_cost_usd,
|
|
499
526
|
});
|
|
500
527
|
} catch {
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
text: `Execution error (exit ${code}):\n${(err || out || "no output").slice(0, 3500)}`,
|
|
504
|
-
});
|
|
528
|
+
const raw = (err || out || "no output").slice(0, 3500);
|
|
529
|
+
resolve({ ok: false, text: classifyClaudeError(raw, code) });
|
|
505
530
|
}
|
|
506
531
|
});
|
|
507
532
|
});
|
|
@@ -777,10 +802,14 @@ async function handle(msg) {
|
|
|
777
802
|
return;
|
|
778
803
|
}
|
|
779
804
|
if (text === "/status") {
|
|
805
|
+
const latest = await fetchLatestVersion();
|
|
806
|
+
const versionStr = !latest || latest === VERSION
|
|
807
|
+
? VERSION
|
|
808
|
+
: `${VERSION} → ${latest} ✨`;
|
|
780
809
|
await send(
|
|
781
810
|
chatId,
|
|
782
811
|
t(l, "status", {
|
|
783
|
-
version:
|
|
812
|
+
version: versionStr,
|
|
784
813
|
name: cfg.name || "claude-telegram-bot",
|
|
785
814
|
model: state.model || cfg.model || (l === "ko" ? "(기본값)" : "(default)"),
|
|
786
815
|
hasSession: Boolean(state.sessionId),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-telegram-bot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.6",
|
|
4
4
|
"description": "Drive Claude Code from Telegram — messages run headless `claude -p` in a project dir and replies come back to the chat. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|