@inetafrica/open-claudia 1.2.1 → 1.2.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.
- package/bot.js +10 -6
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -144,7 +144,7 @@ function checkForUpdates() {
|
|
|
144
144
|
const latest = JSON.parse(data).version;
|
|
145
145
|
if (latest && latest !== CURRENT_VERSION && latest !== lastNotifiedVersion) {
|
|
146
146
|
lastNotifiedVersion = latest;
|
|
147
|
-
bot.sendMessage(CHAT_ID, `
|
|
147
|
+
bot.sendMessage(CHAT_ID, `Hey! A new version is available (v${latest}). You're on v${CURRENT_VERSION}.\n\nSend /upgrade to update — I'll be back in a few seconds.`);
|
|
148
148
|
}
|
|
149
149
|
} catch (e) {}
|
|
150
150
|
});
|
|
@@ -829,29 +829,30 @@ bot.onText(/\/version$/, (msg) => {
|
|
|
829
829
|
|
|
830
830
|
bot.onText(/\/restart$/, async (msg) => {
|
|
831
831
|
if (!isOwner(msg)) return;
|
|
832
|
-
await send("
|
|
832
|
+
await send("Going offline for a quick restart — back in a moment.");
|
|
833
833
|
releaseLock();
|
|
834
834
|
setTimeout(() => process.exit(0), 500);
|
|
835
835
|
});
|
|
836
836
|
|
|
837
837
|
bot.onText(/\/upgrade$/, async (msg) => {
|
|
838
838
|
if (!isOwner(msg)) return;
|
|
839
|
-
await send("Upgrading...");
|
|
839
|
+
await send("Upgrading — I'll be unreachable for a few seconds...");
|
|
840
840
|
try {
|
|
841
841
|
execSync("npm install -g @inetafrica/open-claudia@latest 2>&1", {
|
|
842
|
-
encoding: "utf-8", timeout:
|
|
842
|
+
encoding: "utf-8", timeout: 120000,
|
|
843
843
|
env: { ...process.env, PATH: FULL_PATH },
|
|
844
844
|
});
|
|
845
845
|
// Read version from newly installed package
|
|
846
846
|
const root = execSync("npm root -g", { encoding: "utf-8", env: { ...process.env, PATH: FULL_PATH } }).trim();
|
|
847
847
|
const newPkg = JSON.parse(fs.readFileSync(path.join(root, "@inetafrica", "open-claudia", "package.json"), "utf-8"));
|
|
848
|
-
await send(`Upgraded
|
|
848
|
+
await send(`Upgraded to v${newPkg.version}. Coming back online now...`);
|
|
849
849
|
} catch (e) {
|
|
850
850
|
await send(`Upgrade failed: ${e.message}`);
|
|
851
851
|
return;
|
|
852
852
|
}
|
|
853
853
|
releaseLock();
|
|
854
|
-
|
|
854
|
+
// Give Telegram time to deliver the message, then exit for launchd to restart
|
|
855
|
+
setTimeout(() => process.exit(0), 2000);
|
|
855
856
|
});
|
|
856
857
|
|
|
857
858
|
bot.onText(/\/projects$/, (msg) => { if (isAuthorized(msg)) send("Pick:", { keyboard: projectKeyboard() }); });
|
|
@@ -1248,3 +1249,6 @@ console.log(`Workspace: ${WORKSPACE}`);
|
|
|
1248
1249
|
console.log(`Soul: ${SOUL_FILE}`);
|
|
1249
1250
|
console.log(`Vault: ${VAULT_FILE} (${vault.exists() ? "exists" : "not created"})`);
|
|
1250
1251
|
console.log(`Onboarded: ${isOnboarded()}`);
|
|
1252
|
+
|
|
1253
|
+
// Notify owner that bot is back online
|
|
1254
|
+
bot.sendMessage(CHAT_ID, `I'm back online! Running v${CURRENT_VERSION}.`).catch(() => {});
|