claude-telegram-bot 0.3.8 → 0.3.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.mjs +29 -1
- package/package.json +1 -1
package/bot.mjs
CHANGED
|
@@ -315,7 +315,10 @@ function checkLocalLock() {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
// ── npm 최신 버전 확인
|
|
318
|
+
// ── npm 최신 버전 확인 ────────────────────────────────────────────────────
|
|
319
|
+
// /status 호출 및 시작 시 24h 주기 업데이트 감지에 사용.
|
|
320
|
+
const VERSION_CHECK_INTERVAL = 24 * 60 * 60 * 1000; // 24h
|
|
321
|
+
|
|
319
322
|
async function fetchLatestVersion() {
|
|
320
323
|
try {
|
|
321
324
|
const r = await fetch("https://registry.npmjs.org/claude-telegram-bot/latest", {
|
|
@@ -328,6 +331,30 @@ async function fetchLatestVersion() {
|
|
|
328
331
|
}
|
|
329
332
|
}
|
|
330
333
|
|
|
334
|
+
// 버전 비교: "1.2.3" > "1.2.2" 형태의 semver 대소 비교 (major.minor.patch).
|
|
335
|
+
function isNewer(latest, current) {
|
|
336
|
+
const p = (v) => String(v).split(".").map(Number);
|
|
337
|
+
const [lM, lm, lp] = p(latest);
|
|
338
|
+
const [cM, cm, cp] = p(current);
|
|
339
|
+
return lM !== cM ? lM > cM : lm !== cm ? lm > cm : lp > cp;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
async function checkForUpdate() {
|
|
343
|
+
if (!cfg.allowedChatId) return;
|
|
344
|
+
const now = Date.now();
|
|
345
|
+
if (state.lastVersionCheck && now - state.lastVersionCheck < VERSION_CHECK_INTERVAL) return;
|
|
346
|
+
const latest = await fetchLatestVersion();
|
|
347
|
+
state.lastVersionCheck = now;
|
|
348
|
+
saveState(state);
|
|
349
|
+
if (!latest || !isNewer(latest, VERSION)) return;
|
|
350
|
+
if (state.notifiedVersion === latest) return; // 이미 알린 버전
|
|
351
|
+
state.notifiedVersion = latest;
|
|
352
|
+
saveState(state);
|
|
353
|
+
await send(cfg.allowedChatId,
|
|
354
|
+
`✨ 업데이트가 있습니다: ${VERSION} → ${latest}\n\`npm i -g claude-telegram-bot\` 후 /restart`
|
|
355
|
+
).catch(() => {});
|
|
356
|
+
}
|
|
357
|
+
|
|
331
358
|
// ── 퍼시스턴트 메모리 ─────────────────────────────────────────────────────
|
|
332
359
|
// /new 로 세션을 초기화해도 유지되는 메모리. runClaude 시 시스템 프롬프트에 주입.
|
|
333
360
|
function loadMemory() {
|
|
@@ -995,6 +1022,7 @@ async function main() {
|
|
|
995
1022
|
} catch {}
|
|
996
1023
|
|
|
997
1024
|
startScheduler();
|
|
1025
|
+
checkForUpdate().catch(() => {});
|
|
998
1026
|
|
|
999
1027
|
while (true) {
|
|
1000
1028
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claude-telegram-bot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.9",
|
|
4
4
|
"description": "Drive Claude Code from Telegram — messages run headless `claude -p` in a project dir and replies come back to the chat. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|