claude-telegram-bot 0.3.29 → 0.3.31

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 +3 -24
  2. package/package.json +1 -1
package/bot.mjs CHANGED
@@ -570,33 +570,11 @@ function classifyClaudeError(raw, code) {
570
570
  return `Execution error (exit ${code}):\n${raw}`;
571
571
  }
572
572
 
573
- // ── Claude CLI 버전 탐지 ──────────────────────────────────────────────────
574
- // --print=<value> 는 구버전 CLI에 없음. 시작 시 한 번 probe해서 폴백 결정.
575
- let claudePrintStyle = "new"; // "new" = --print=<val> | "old" = -p <val>
576
-
577
- function probeClaude() {
578
- return new Promise((resolve) => {
579
- const bin = cfg.claudeBin || "claude";
580
- const child = spawn(bin, ["--help"], { env: process.env });
581
- let out = "";
582
- child.stdout.on("data", (d) => (out += d));
583
- child.stderr.on("data", (d) => (out += d));
584
- child.on("close", () => {
585
- claudePrintStyle = out.includes("--print") ? "new" : "old";
586
- if (claudePrintStyle === "old")
587
- console.warn(`[warn] claude CLI does not support --print; falling back to -p (messages starting with '-' may fail)`);
588
- resolve();
589
- });
590
- child.on("error", () => resolve()); // 탐지 실패 시 기본값(new) 유지
591
- });
592
- }
593
-
594
573
  // ── Claude 실행 ───────────────────────────────────────────────────────────
595
574
  function runClaude(prompt, sessionId, opts = {}) {
596
575
  return new Promise((resolve) => {
597
- const printArgs = claudePrintStyle === "new" ? [`--print=${prompt}`] : ["-p", prompt];
598
576
  const args = [
599
- ...printArgs,
577
+ "-p",
600
578
  "--output-format",
601
579
  "json",
602
580
  "--permission-mode",
@@ -618,6 +596,8 @@ function runClaude(prompt, sessionId, opts = {}) {
618
596
  if (appendSys) args.push("--append-system-prompt", appendSys);
619
597
  if (model) args.push("--model", model);
620
598
  if (sessionId) args.push("--resume", sessionId);
599
+ // 프롬프트는 반드시 맨 끝에 `--` 뒤로 — `-`로 시작해도 옵션으로 오해 안 함
600
+ args.push("--", prompt);
621
601
 
622
602
  const child = spawn(cfg.claudeBin || "claude", args, {
623
603
  cwd: cfg.projectDir,
@@ -1285,7 +1265,6 @@ function dispatch(msg) {
1285
1265
  // ── 롱폴링 루프 ───────────────────────────────────────────────────────────
1286
1266
  async function main() {
1287
1267
  console.log("Bot started. Polling Telegram...");
1288
- await probeClaude();
1289
1268
  // /restart 로 재시작했으면 완료 알림 1회 (플래그는 즉시 비움)
1290
1269
  if (state.restartNotify) {
1291
1270
  const to = state.restartNotify;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-telegram-bot",
3
- "version": "0.3.29",
3
+ "version": "0.3.31",
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": {