@inetafrica/open-claudia 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/setup.js +42 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inetafrica/open-claudia",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Your always-on AI coding assistant — Claude Code via Telegram",
5
5
  "main": "bot.js",
6
6
  "bin": {
package/setup.js CHANGED
@@ -89,8 +89,17 @@ function getUpdatesForChatId(token) {
89
89
  try {
90
90
  const json = JSON.parse(data);
91
91
  if (json.ok && json.result.length > 0) {
92
- const chatId = json.result[json.result.length - 1].message?.chat?.id;
93
- resolve(chatId ? String(chatId) : null);
92
+ const msg = json.result[json.result.length - 1].message;
93
+ if (msg?.chat?.id) {
94
+ resolve({
95
+ chatId: String(msg.chat.id),
96
+ firstName: msg.from?.first_name || "",
97
+ lastName: msg.from?.last_name || "",
98
+ username: msg.from?.username || "",
99
+ });
100
+ } else {
101
+ resolve(null);
102
+ }
94
103
  } else {
95
104
  resolve(null);
96
105
  }
@@ -230,6 +239,23 @@ async function main() {
230
239
  }
231
240
  console.log(` Claude CLI: ${claudePath}`);
232
241
 
242
+ // Check if Claude is authenticated
243
+ try {
244
+ const authCheck = execSync(`"${claudePath}" -p "say ok" --max-budget-usd 0.01 --output-format text 2>&1`, {
245
+ encoding: "utf-8", timeout: 30000,
246
+ });
247
+ console.log(" Claude auth: OK");
248
+ } catch (e) {
249
+ const errMsg = (e.stderr || e.stdout || e.message || "").toLowerCase();
250
+ if (errMsg.includes("auth") || errMsg.includes("login") || errMsg.includes("api key") || errMsg.includes("unauthorized")) {
251
+ console.log(" Claude auth: NOT LOGGED IN");
252
+ console.log(" Run 'claude auth' or 'claude login' to authenticate first.");
253
+ process.exit(1);
254
+ }
255
+ // Other errors (like budget exceeded) mean auth is fine
256
+ console.log(" Claude auth: OK");
257
+ }
258
+
233
259
  const platform = detectPlatform();
234
260
  console.log(` Platform: ${platform}`);
235
261
 
@@ -254,19 +280,29 @@ async function main() {
254
280
 
255
281
  console.log(" Now send any message to your bot in Telegram...");
256
282
  let chatId = null;
283
+ let userInfo = null;
257
284
  for (let i = 0; i < 30; i++) {
258
- chatId = await getUpdatesForChatId(token);
259
- if (chatId) break;
285
+ userInfo = await getUpdatesForChatId(token);
286
+ if (userInfo) break;
260
287
  process.stdout.write(".");
261
288
  await new Promise((r) => setTimeout(r, 2000));
262
289
  }
263
290
  console.log("");
264
291
 
265
- if (!chatId) {
292
+ if (!userInfo) {
266
293
  console.log(" Didn't receive a message. Enter chat ID manually:");
267
294
  chatId = await ask(" Chat ID: ");
268
295
  } else {
269
- console.log(` Chat ID detected: ${chatId}`);
296
+ const name = [userInfo.firstName, userInfo.lastName].filter(Boolean).join(" ");
297
+ const handle = userInfo.username ? ` (@${userInfo.username})` : "";
298
+ console.log(` Message received from: ${name}${handle}`);
299
+ console.log(` Chat ID: ${userInfo.chatId}`);
300
+ const approve = await ask(`\n Authorize this user? (y/n) [y]: `);
301
+ if (approve.toLowerCase() === "n") {
302
+ console.log(" Declined. Send a message from the correct account and run setup again.");
303
+ process.exit(1);
304
+ }
305
+ chatId = userInfo.chatId;
270
306
  }
271
307
 
272
308
  // Test sending