@thxmxx/telegram-mcp 1.3.1 → 1.3.2
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/package.json +1 -1
- package/src/setup.js +40 -58
package/package.json
CHANGED
package/src/setup.js
CHANGED
|
@@ -17,21 +17,17 @@ import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
|
|
17
17
|
import { join } from "node:path";
|
|
18
18
|
import { homedir } from "node:os";
|
|
19
19
|
|
|
20
|
-
const rl
|
|
20
|
+
const rl = createInterface({ input, output });
|
|
21
21
|
const ask = (q) => rl.question(q);
|
|
22
22
|
|
|
23
|
-
const BOLD
|
|
23
|
+
const BOLD = "\x1b[1m";
|
|
24
24
|
const GREEN = "\x1b[32m";
|
|
25
|
-
const CYAN
|
|
26
|
-
const DIM
|
|
25
|
+
const CYAN = "\x1b[36m";
|
|
26
|
+
const DIM = "\x1b[2m";
|
|
27
27
|
const RESET = "\x1b[0m";
|
|
28
28
|
|
|
29
|
-
const ok
|
|
30
|
-
const die = (msg) => {
|
|
31
|
-
console.error(`\x1b[31m✘${RESET} ${msg}`);
|
|
32
|
-
rl.close();
|
|
33
|
-
exit(1);
|
|
34
|
-
};
|
|
29
|
+
const ok = (msg) => console.log(`${GREEN}✔${RESET} ${msg}`);
|
|
30
|
+
const die = (msg) => { console.error(`\x1b[31m✘${RESET} ${msg}`); rl.close(); exit(1); };
|
|
35
31
|
|
|
36
32
|
// ── Pre-flight ────────────────────────────────────────────────────────────────
|
|
37
33
|
|
|
@@ -42,9 +38,7 @@ if (major < 18) die(`Node.js 18+ required (you have ${process.versions.node})`);
|
|
|
42
38
|
ok(`Node.js ${process.versions.node}`);
|
|
43
39
|
|
|
44
40
|
try {
|
|
45
|
-
const ver = execFileSync("claude", ["--version"], {
|
|
46
|
-
encoding: "utf8",
|
|
47
|
-
}).trim();
|
|
41
|
+
const ver = execFileSync("claude", ["--version"], { encoding: "utf8" }).trim();
|
|
48
42
|
ok(`Claude Code: ${ver}`);
|
|
49
43
|
} catch {
|
|
50
44
|
die("`claude` not found. Install: https://docs.claude.ai/claude-code");
|
|
@@ -76,52 +70,43 @@ console.log(`\n${BOLD}Registering MCP server globally…${RESET}`);
|
|
|
76
70
|
|
|
77
71
|
const serverPath = new URL("./index.js", import.meta.url).pathname;
|
|
78
72
|
|
|
73
|
+
// Remove existing registration first so token updates take effect
|
|
79
74
|
try {
|
|
80
|
-
execFileSync(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
);
|
|
75
|
+
execFileSync("claude", ["mcp", "remove", "telegram-mcp", "--scope", "user"], { stdio: "ignore" });
|
|
76
|
+
} catch {
|
|
77
|
+
try {
|
|
78
|
+
execFileSync("claude", ["mcp", "remove", "telegram-mcp"], { stdio: "ignore" });
|
|
79
|
+
} catch {
|
|
80
|
+
// Not registered yet — that's fine
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
execFileSync("claude", [
|
|
86
|
+
"mcp", "add", "--scope", "user",
|
|
87
|
+
"telegram-mcp",
|
|
88
|
+
"-e", `TELEGRAM_BOT_TOKEN=${token}`,
|
|
89
|
+
"-e", `TELEGRAM_CHAT_ID=${chatId}`,
|
|
90
|
+
"--", "node", serverPath,
|
|
91
|
+
], { stdio: "inherit" });
|
|
98
92
|
} catch {
|
|
99
93
|
// Fallback: older Claude Code versions without --scope flag
|
|
100
94
|
try {
|
|
101
|
-
execFileSync(
|
|
102
|
-
"
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
`TELEGRAM_BOT_TOKEN=${token}`,
|
|
109
|
-
"-e",
|
|
110
|
-
`TELEGRAM_CHAT_ID=${chatId}`,
|
|
111
|
-
"--",
|
|
112
|
-
"node",
|
|
113
|
-
serverPath,
|
|
114
|
-
],
|
|
115
|
-
{ stdio: "inherit" },
|
|
116
|
-
);
|
|
95
|
+
execFileSync("claude", [
|
|
96
|
+
"mcp", "add",
|
|
97
|
+
"telegram-mcp",
|
|
98
|
+
"-e", `TELEGRAM_BOT_TOKEN=${token}`,
|
|
99
|
+
"-e", `TELEGRAM_CHAT_ID=${chatId}`,
|
|
100
|
+
"--", "node", serverPath,
|
|
101
|
+
], { stdio: "inherit" });
|
|
117
102
|
} catch {
|
|
118
103
|
die(
|
|
119
104
|
"`claude mcp add` failed.\n" +
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
105
|
+
" Update Claude Code: https://docs.claude.ai/claude-code\n\n" +
|
|
106
|
+
" Manual config:\n" +
|
|
107
|
+
` TELEGRAM_BOT_TOKEN=${token}\n` +
|
|
108
|
+
` TELEGRAM_CHAT_ID=${chatId}\n` +
|
|
109
|
+
` command: node ${serverPath}`
|
|
125
110
|
);
|
|
126
111
|
}
|
|
127
112
|
}
|
|
@@ -134,9 +119,7 @@ const commandsDir = join(homedir(), ".claude", "commands");
|
|
|
134
119
|
mkdirSync(commandsDir, { recursive: true });
|
|
135
120
|
|
|
136
121
|
const commandPath = join(commandsDir, "use-telegram.md");
|
|
137
|
-
writeFileSync(
|
|
138
|
-
commandPath,
|
|
139
|
-
`# use-telegram
|
|
122
|
+
writeFileSync(commandPath, `# use-telegram
|
|
140
123
|
|
|
141
124
|
Activate Telegram integration for this Claude Code session.
|
|
142
125
|
|
|
@@ -182,8 +165,7 @@ After completing any task, ALWAYS call telegram_listen (no arguments).
|
|
|
182
165
|
- This keeps the session alive indefinitely until timeout (1 hour of inactivity)
|
|
183
166
|
|
|
184
167
|
Never exit or stop after a task — always loop back to telegram_listen.
|
|
185
|
-
|
|
186
|
-
);
|
|
168
|
+
`);
|
|
187
169
|
|
|
188
170
|
ok(`Slash command installed → ${commandPath}`);
|
|
189
171
|
|
|
@@ -207,4 +189,4 @@ ${GREEN}${BOLD}All done!${RESET}
|
|
|
207
189
|
|
|
208
190
|
Each session auto-identifies itself as ${BOLD}[folder#id]${RESET} in Telegram.
|
|
209
191
|
${DIM}No need to run init again unless you change your bot token.${RESET}
|
|
210
|
-
`);
|
|
192
|
+
`);
|