claude-telegram-bot 0.3.2 → 0.3.3

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/ctb.mjs +14 -4
  2. package/package.json +1 -1
package/ctb.mjs CHANGED
@@ -13,7 +13,7 @@
13
13
  // While Claude runs, .claude-bot/local.lock (PID) is created so the bot defers
14
14
  // incoming Telegram messages until the local session ends.
15
15
 
16
- import { mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
16
+ import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
17
17
  import { basename, dirname, join } from "node:path";
18
18
  import { fileURLToPath } from "node:url";
19
19
  import { spawn } from "node:child_process";
@@ -38,12 +38,22 @@ function runBot(botArgs) {
38
38
  }
39
39
 
40
40
  function resolveConfig(arg) {
41
- if (!arg) return process.env.BOT_CONFIG || join(HERE, "config.json");
41
+ if (!arg) {
42
+ if (process.env.BOT_CONFIG) return process.env.BOT_CONFIG;
43
+ // cwd 우선(프로젝트 폴더에서 ctb 실행) → 전역 설치 경로 폴백
44
+ for (const base of [process.cwd(), HERE]) {
45
+ for (const name of ["mybot.json", "config.json"]) {
46
+ const p = join(base, name);
47
+ if (existsSync(p)) return p;
48
+ }
49
+ }
50
+ return join(process.cwd(), "mybot.json"); // 최종 폴백
51
+ }
42
52
  // Absolute or explicitly relative path → use as-is
43
53
  if (arg.startsWith("/") || arg.startsWith("./") || arg.startsWith("../"))
44
54
  return arg;
45
- // Bare name (e.g. "planner.json") → relative to package dir
46
- return join(HERE, arg);
55
+ // Bare name (e.g. "planner.json") → relative to cwd first, then package dir
56
+ return existsSync(join(process.cwd(), arg)) ? join(process.cwd(), arg) : join(HERE, arg);
47
57
  }
48
58
 
49
59
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-telegram-bot",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
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": {