claude-telegram-bot 0.3.5 → 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.
Files changed (2) hide show
  1. package/bot.mjs +16 -4
  2. package/package.json +1 -1
package/bot.mjs CHANGED
@@ -454,6 +454,20 @@ async function send(chatId, text) {
454
454
  }
455
455
  }
456
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
+
457
471
  // ── Claude 실행 ───────────────────────────────────────────────────────────
458
472
  function runClaude(prompt, sessionId, opts = {}) {
459
473
  return new Promise((resolve) => {
@@ -511,10 +525,8 @@ function runClaude(prompt, sessionId, opts = {}) {
511
525
  cost: j.total_cost_usd,
512
526
  });
513
527
  } catch {
514
- resolve({
515
- ok: false,
516
- text: `Execution error (exit ${code}):\n${(err || out || "no output").slice(0, 3500)}`,
517
- });
528
+ const raw = (err || out || "no output").slice(0, 3500);
529
+ resolve({ ok: false, text: classifyClaudeError(raw, code) });
518
530
  }
519
531
  });
520
532
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-telegram-bot",
3
- "version": "0.3.5",
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": {