@inetafrica/open-claudia 1.1.8 → 1.1.9
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/bot.js +40 -7
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -831,13 +831,14 @@ bot.onText(/\/upgrade$/, async (msg) => {
|
|
|
831
831
|
if (!isOwner(msg)) return;
|
|
832
832
|
await send("Upgrading...");
|
|
833
833
|
try {
|
|
834
|
-
|
|
834
|
+
execSync("npm install -g @inetafrica/open-claudia@latest 2>&1", {
|
|
835
835
|
encoding: "utf-8", timeout: 60000,
|
|
836
836
|
env: { ...process.env, PATH: FULL_PATH },
|
|
837
837
|
});
|
|
838
|
-
|
|
839
|
-
const
|
|
840
|
-
|
|
838
|
+
// Read version from newly installed package
|
|
839
|
+
const root = execSync("npm root -g", { encoding: "utf-8", env: { ...process.env, PATH: FULL_PATH } }).trim();
|
|
840
|
+
const newPkg = JSON.parse(fs.readFileSync(path.join(root, "@inetafrica", "open-claudia", "package.json"), "utf-8"));
|
|
841
|
+
await send(`Upgraded: v${CURRENT_VERSION} → v${newPkg.version}. Restarting...`);
|
|
841
842
|
} catch (e) {
|
|
842
843
|
await send(`Upgrade failed: ${e.message}`);
|
|
843
844
|
return;
|
|
@@ -1193,9 +1194,41 @@ bot.on("message", async (msg) => {
|
|
|
1193
1194
|
if (!requireSession(msg)) return;
|
|
1194
1195
|
|
|
1195
1196
|
let prompt = msg.text;
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1197
|
+
const reply = msg.reply_to_message;
|
|
1198
|
+
if (reply) {
|
|
1199
|
+
let ctx = "";
|
|
1200
|
+
if (reply.text) {
|
|
1201
|
+
ctx = reply.text;
|
|
1202
|
+
}
|
|
1203
|
+
if (reply.caption) {
|
|
1204
|
+
ctx += (ctx ? "\n" : "") + reply.caption;
|
|
1205
|
+
}
|
|
1206
|
+
if (reply.document) {
|
|
1207
|
+
const fileName = reply.document.file_name || "unknown";
|
|
1208
|
+
const filePath = path.join(FILES_DIR, fileName);
|
|
1209
|
+
if (fs.existsSync(filePath)) {
|
|
1210
|
+
ctx += (ctx ? "\n" : "") + `[Attached file: ${fileName} at ${filePath}]`;
|
|
1211
|
+
} else {
|
|
1212
|
+
// Download the file from the replied message
|
|
1213
|
+
try {
|
|
1214
|
+
const file = await bot.getFile(reply.document.file_id);
|
|
1215
|
+
const fileUrl = `https://api.telegram.org/file/bot${TOKEN}/${file.file_path}`;
|
|
1216
|
+
await new Promise((resolve, reject) => {
|
|
1217
|
+
const out = fs.createWriteStream(filePath);
|
|
1218
|
+
https.get(fileUrl, (res) => { res.pipe(out); out.on("finish", () => { out.close(); resolve(); }); }).on("error", reject);
|
|
1219
|
+
});
|
|
1220
|
+
ctx += (ctx ? "\n" : "") + `[Attached file: ${fileName} at ${filePath}]`;
|
|
1221
|
+
} catch (e) {
|
|
1222
|
+
ctx += (ctx ? "\n" : "") + `[Attached file: ${fileName} — could not download]`;
|
|
1223
|
+
}
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
if (reply.photo) {
|
|
1227
|
+
ctx += (ctx ? "\n" : "") + "[Attached photo]";
|
|
1228
|
+
}
|
|
1229
|
+
if (ctx) {
|
|
1230
|
+
prompt = `Replying to message:\n---\n${ctx.length > 1000 ? ctx.slice(0, 1000) + "..." : ctx}\n---\n\n${msg.text}`;
|
|
1231
|
+
}
|
|
1199
1232
|
}
|
|
1200
1233
|
|
|
1201
1234
|
await runClaude(prompt, currentSession.dir, msg.message_id);
|