@inetafrica/open-claudia 1.1.6 → 1.1.7
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 +24 -0
- package/package.json +1 -1
package/bot.js
CHANGED
|
@@ -130,6 +130,30 @@ bot.on("polling_error", (err) => {
|
|
|
130
130
|
}
|
|
131
131
|
});
|
|
132
132
|
|
|
133
|
+
// ── Update checker (every 5 mins) ──────────────────────────────────
|
|
134
|
+
const CURRENT_VERSION = require(path.join(__dirname, "package.json")).version;
|
|
135
|
+
let lastNotifiedVersion = null;
|
|
136
|
+
|
|
137
|
+
function checkForUpdates() {
|
|
138
|
+
https.get("https://registry.npmjs.org/@inetafrica/open-claudia/latest", (res) => {
|
|
139
|
+
let data = "";
|
|
140
|
+
res.on("data", (d) => { data += d; });
|
|
141
|
+
res.on("end", () => {
|
|
142
|
+
try {
|
|
143
|
+
const latest = JSON.parse(data).version;
|
|
144
|
+
if (latest && latest !== CURRENT_VERSION && latest !== lastNotifiedVersion) {
|
|
145
|
+
lastNotifiedVersion = latest;
|
|
146
|
+
bot.sendMessage(CHAT_ID, `Update available: v${CURRENT_VERSION} → v${latest}\n\nSend /upgrade to update.`);
|
|
147
|
+
}
|
|
148
|
+
} catch (e) {}
|
|
149
|
+
});
|
|
150
|
+
}).on("error", () => {});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// Check on startup (after 30s) and every 5 minutes
|
|
154
|
+
setTimeout(checkForUpdates, 30000);
|
|
155
|
+
setInterval(checkForUpdates, 5 * 60 * 1000);
|
|
156
|
+
|
|
133
157
|
// ── Commands Menu ───────────────────────────────────────────────────
|
|
134
158
|
bot.setMyCommands([
|
|
135
159
|
{ command: "session", description: "Pick a project to work on" },
|