alvin-bot 5.7.0 → 5.8.1
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/CHANGELOG.md +25 -0
- package/README.md +25 -31
- package/dist/claude.js +1 -102
- package/dist/config.js +1 -96
- package/dist/engine.js +1 -90
- package/dist/find-claude-binary.js +1 -98
- package/dist/handlers/async-agent-chunk-handler.js +1 -50
- package/dist/handlers/background-bypass.js +1 -75
- package/dist/handlers/commands.js +1 -2336
- package/dist/handlers/cron-progress.js +1 -52
- package/dist/handlers/document.js +1 -194
- package/dist/handlers/message.js +1 -959
- package/dist/handlers/photo.js +1 -154
- package/dist/handlers/platform-message.js +1 -360
- package/dist/handlers/stuck-timer.js +1 -54
- package/dist/handlers/video.js +1 -237
- package/dist/handlers/voice.js +1 -148
- package/dist/i18n.js +1 -805
- package/dist/index.js +1 -697
- package/dist/init-data-dir.js +1 -98
- package/dist/middleware/auth.js +1 -233
- package/dist/migrate.js +1 -162
- package/dist/paths.js +1 -146
- package/dist/platforms/discord.js +1 -175
- package/dist/platforms/index.js +1 -130
- package/dist/platforms/signal.js +1 -205
- package/dist/platforms/slack-slash-parser.js +1 -32
- package/dist/platforms/slack.js +1 -501
- package/dist/platforms/telegram.js +1 -111
- package/dist/platforms/types.js +1 -8
- package/dist/platforms/whatsapp-auth-helpers.js +1 -53
- package/dist/platforms/whatsapp.js +1 -707
- package/dist/providers/claude-sdk-provider.js +1 -565
- package/dist/providers/codex-cli-provider.js +1 -134
- package/dist/providers/index.js +1 -7
- package/dist/providers/ollama-provider.js +1 -32
- package/dist/providers/openai-compatible.js +1 -406
- package/dist/providers/registry.js +1 -352
- package/dist/providers/runtime-header.js +1 -45
- package/dist/providers/tool-executor.js +1 -475
- package/dist/providers/types.js +1 -227
- package/dist/services/access.js +1 -144
- package/dist/services/allowed-users-gate.js +1 -56
- package/dist/services/alvin-dispatch.js +1 -174
- package/dist/services/alvin-mcp-tools.js +1 -104
- package/dist/services/asset-index.js +1 -224
- package/dist/services/async-agent-parser.js +1 -418
- package/dist/services/async-agent-watcher.js +1 -583
- package/dist/services/auto-diagnostic.js +1 -228
- package/dist/services/broadcast.js +1 -52
- package/dist/services/browser-manager.js +1 -562
- package/dist/services/browser-webfetch.js +1 -127
- package/dist/services/browser.js +1 -121
- package/dist/services/cdp-bootstrap.js +1 -357
- package/dist/services/compaction.js +1 -144
- package/dist/services/critical-notify.js +1 -203
- package/dist/services/cron-resolver.js +1 -58
- package/dist/services/cron-scheduling.js +1 -310
- package/dist/services/cron.js +1 -861
- package/dist/services/custom-tools.js +1 -317
- package/dist/services/delivery-queue.js +1 -173
- package/dist/services/delivery-registry.js +1 -21
- package/dist/services/disk-cleanup.js +1 -203
- package/dist/services/elevenlabs.js +1 -58
- package/dist/services/embeddings/auto-detect.js +1 -74
- package/dist/services/embeddings/fts5.js +1 -108
- package/dist/services/embeddings/gemini.js +1 -65
- package/dist/services/embeddings/index.js +1 -496
- package/dist/services/embeddings/ollama.js +1 -78
- package/dist/services/embeddings/openai.js +1 -49
- package/dist/services/embeddings/provider.js +1 -22
- package/dist/services/embeddings/vector-base.js +1 -113
- package/dist/services/embeddings-migration.js +1 -193
- package/dist/services/embeddings.js +1 -9
- package/dist/services/env-file.js +1 -50
- package/dist/services/exec-guard.js +1 -71
- package/dist/services/fallback-order.js +1 -154
- package/dist/services/file-permissions.js +1 -93
- package/dist/services/heartbeat-file.js +1 -65
- package/dist/services/heartbeat.js +1 -313
- package/dist/services/hooks.js +1 -44
- package/dist/services/imagegen.js +1 -72
- package/dist/services/language-detect.js +1 -154
- package/dist/services/markdown.js +1 -63
- package/dist/services/mcp.js +1 -263
- package/dist/services/memory-extractor.js +1 -178
- package/dist/services/memory-inject-mode.js +1 -43
- package/dist/services/memory-layers.js +1 -156
- package/dist/services/memory.js +1 -146
- package/dist/services/ollama-manager.js +1 -339
- package/dist/services/permissions-wizard.js +1 -291
- package/dist/services/personality.js +1 -376
- package/dist/services/plugins.js +1 -171
- package/dist/services/preflight.js +1 -292
- package/dist/services/process-manager.js +1 -291
- package/dist/services/release-highlights.js +1 -79
- package/dist/services/reminders.js +1 -97
- package/dist/services/restart.js +1 -48
- package/dist/services/security-audit.js +1 -74
- package/dist/services/self-diagnosis.js +1 -272
- package/dist/services/self-search.js +1 -129
- package/dist/services/session-persistence.js +1 -237
- package/dist/services/session.js +1 -282
- package/dist/services/skills.js +1 -290
- package/dist/services/ssrf-guard.js +1 -162
- package/dist/services/standing-orders.js +1 -29
- package/dist/services/steer-channel.js +1 -46
- package/dist/services/stop-controller.js +1 -52
- package/dist/services/subagent-dedup.js +1 -86
- package/dist/services/subagent-delivery.js +1 -452
- package/dist/services/subagent-stats.js +1 -123
- package/dist/services/subagents.js +1 -814
- package/dist/services/sudo.js +1 -329
- package/dist/services/telegram.js +1 -158
- package/dist/services/timing-safe-bearer.js +1 -51
- package/dist/services/tool-discovery.js +1 -214
- package/dist/services/trends.js +1 -580
- package/dist/services/updater.js +1 -291
- package/dist/services/usage-tracker.js +1 -144
- package/dist/services/users.js +1 -271
- package/dist/services/voice.js +1 -104
- package/dist/services/watchdog-brake.js +1 -154
- package/dist/services/watchdog.js +1 -311
- package/dist/services/workspaces.js +1 -276
- package/dist/tui/index.js +1 -667
- package/dist/util/console-formatter.js +1 -109
- package/dist/util/debounce.js +1 -24
- package/dist/util/telegram-error-filter.js +1 -62
- package/dist/version.js +1 -24
- package/dist/web/bind-strategy.js +1 -42
- package/dist/web/canvas.js +1 -30
- package/dist/web/doctor-api.js +1 -604
- package/dist/web/openai-compat.js +1 -252
- package/dist/web/server.js +1 -1902
- package/dist/web/setup-api.js +1 -1101
- package/package.json +5 -2
- package/dist/.metadata_never_index +0 -0
|
@@ -1,291 +1 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* v4.13.1 — Process manager abstraction for the Maintenance Web UI.
|
|
3
|
-
*
|
|
4
|
-
* History: the bot was originally PM2-managed. Since v4.8 the macOS
|
|
5
|
-
* install uses launchd (`com.alvinbot.app.plist`). The WebUI
|
|
6
|
-
* Maintenance section kept calling `pm2 jlist`/`pm2 restart`/...
|
|
7
|
-
* which returned "PM2 not available" for launchd users — all status,
|
|
8
|
-
* stop, start, and logs buttons were broken.
|
|
9
|
-
*
|
|
10
|
-
* This module auto-detects the active manager per request and
|
|
11
|
-
* routes commands accordingly:
|
|
12
|
-
*
|
|
13
|
-
* - launchd (macOS) — via `launchctl print` / `bootout` / `bootstrap`
|
|
14
|
-
* - pm2 (VPS / Linux) — via `pm2 jlist` / `pm2 stop` / `pm2 start`
|
|
15
|
-
* - standalone — no supervisor; only `scheduleGracefulRestart` works
|
|
16
|
-
*
|
|
17
|
-
* Restart is NOT on this interface — it always uses
|
|
18
|
-
* `scheduleGracefulRestart` (Grammy-safe) and relies on whichever
|
|
19
|
-
* supervisor is present to bring the process back. For "standalone",
|
|
20
|
-
* a restart effectively kills the process and the user has to run it
|
|
21
|
-
* again manually (we warn in the UI).
|
|
22
|
-
*/
|
|
23
|
-
import { execSync } from "node:child_process";
|
|
24
|
-
import os from "node:os";
|
|
25
|
-
import { resolve } from "node:path";
|
|
26
|
-
const LAUNCHD_LABEL = "com.alvinbot.app";
|
|
27
|
-
const LAUNCHD_PLIST = resolve(os.homedir(), "Library", "LaunchAgents", `${LAUNCHD_LABEL}.plist`);
|
|
28
|
-
const PM2_NAME = "alvin-bot";
|
|
29
|
-
// ── Detection ───────────────────────────────────────────────────
|
|
30
|
-
export function detectProcessManager(opts = {}) {
|
|
31
|
-
const platform = opts.platform ?? process.platform;
|
|
32
|
-
const uid = opts.uid ?? (typeof process.getuid === "function" ? process.getuid() : 0);
|
|
33
|
-
// Only try launchd on macOS
|
|
34
|
-
if (platform === "darwin") {
|
|
35
|
-
try {
|
|
36
|
-
const out = execSync(`launchctl print gui/${uid}/${LAUNCHD_LABEL}`, { encoding: "utf-8", timeout: 3000, stdio: "pipe" });
|
|
37
|
-
if (out && out.length > 0) {
|
|
38
|
-
return createLaunchdManager(uid);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
// Not loaded in launchd — fall through
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
// PM2 fallback (Linux VPS, or Mac installs that stayed on PM2)
|
|
46
|
-
try {
|
|
47
|
-
const out = execSync("pm2 jlist", {
|
|
48
|
-
encoding: "utf-8",
|
|
49
|
-
timeout: 3000,
|
|
50
|
-
stdio: "pipe",
|
|
51
|
-
});
|
|
52
|
-
const parsed = JSON.parse(out);
|
|
53
|
-
if (Array.isArray(parsed) &&
|
|
54
|
-
parsed.some((p) => p?.name === PM2_NAME)) {
|
|
55
|
-
return createPm2Manager();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
// pm2 not installed or didn't report our process
|
|
60
|
-
}
|
|
61
|
-
return createStandaloneManager();
|
|
62
|
-
}
|
|
63
|
-
function parseLaunchdPrint(text) {
|
|
64
|
-
const out = {};
|
|
65
|
-
// state = running
|
|
66
|
-
const stateMatch = text.match(/\bstate\s*=\s*(\S+)/);
|
|
67
|
-
if (stateMatch)
|
|
68
|
-
out.state = stateMatch[1];
|
|
69
|
-
// pid = 12345
|
|
70
|
-
const pidMatch = text.match(/\bpid\s*=\s*(\d+)/);
|
|
71
|
-
if (pidMatch)
|
|
72
|
-
out.pid = Number(pidMatch[1]);
|
|
73
|
-
// program = /path/to/node
|
|
74
|
-
const programMatch = text.match(/\bprogram\s*=\s*(\S+)/);
|
|
75
|
-
if (programMatch)
|
|
76
|
-
out.program = programMatch[1];
|
|
77
|
-
// working directory = /path
|
|
78
|
-
const cwdMatch = text.match(/\bworking directory\s*=\s*(\S+)/);
|
|
79
|
-
if (cwdMatch)
|
|
80
|
-
out.cwd = cwdMatch[1];
|
|
81
|
-
return out;
|
|
82
|
-
}
|
|
83
|
-
export function createLaunchdManager(uid) {
|
|
84
|
-
const service = `gui/${uid}/${LAUNCHD_LABEL}`;
|
|
85
|
-
return {
|
|
86
|
-
kind: "launchd",
|
|
87
|
-
async getStatus() {
|
|
88
|
-
try {
|
|
89
|
-
const out = execSync(`launchctl print ${service}`, {
|
|
90
|
-
encoding: "utf-8",
|
|
91
|
-
timeout: 3000,
|
|
92
|
-
stdio: "pipe",
|
|
93
|
-
});
|
|
94
|
-
const parsed = parseLaunchdPrint(out);
|
|
95
|
-
const pid = parsed.pid;
|
|
96
|
-
// Enrich with ps info if we have a PID
|
|
97
|
-
let memory;
|
|
98
|
-
let cpu;
|
|
99
|
-
let uptime;
|
|
100
|
-
if (pid) {
|
|
101
|
-
try {
|
|
102
|
-
// ps output: %cpu %mem rss etime
|
|
103
|
-
const psOut = execSync(`ps -p ${pid} -o %cpu=,%mem=,rss=,etime=`, { encoding: "utf-8", timeout: 2000, stdio: "pipe" }).trim();
|
|
104
|
-
const [cpuStr, , rssStr, etime] = psOut.split(/\s+/);
|
|
105
|
-
cpu = parseFloat(cpuStr) || 0;
|
|
106
|
-
memory = (parseInt(rssStr, 10) || 0) * 1024; // rss is kB
|
|
107
|
-
uptime = parseEtimeToMs(etime);
|
|
108
|
-
}
|
|
109
|
-
catch {
|
|
110
|
-
/* ps may fail if pid vanished — ignore */
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
kind: "launchd",
|
|
115
|
-
status: parsed.state === "running" ? "running" : parsed.state || "unknown",
|
|
116
|
-
pid,
|
|
117
|
-
uptime,
|
|
118
|
-
memory,
|
|
119
|
-
cpu,
|
|
120
|
-
execPath: parsed.program,
|
|
121
|
-
cwd: parsed.cwd,
|
|
122
|
-
nodeVersion: process.version,
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
catch {
|
|
126
|
-
return { kind: "launchd", status: "not-loaded" };
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
async stop() {
|
|
130
|
-
// bootout removes the service from the domain, which stops it
|
|
131
|
-
// and disables KeepAlive until bootstrap is run again.
|
|
132
|
-
execSync(`launchctl bootout ${service}`, {
|
|
133
|
-
encoding: "utf-8",
|
|
134
|
-
timeout: 5000,
|
|
135
|
-
stdio: "pipe",
|
|
136
|
-
});
|
|
137
|
-
},
|
|
138
|
-
async start() {
|
|
139
|
-
// bootstrap re-registers the plist with the domain.
|
|
140
|
-
execSync(`launchctl bootstrap gui/${uid} ${JSON.stringify(LAUNCHD_PLIST).slice(1, -1)}`, { encoding: "utf-8", timeout: 5000, stdio: "pipe" });
|
|
141
|
-
},
|
|
142
|
-
async getLogs(lines = 30) {
|
|
143
|
-
// launchd redirects stdout/stderr to files — just tail them.
|
|
144
|
-
const logDir = resolve(process.env.ALVIN_DATA_DIR || resolve(os.homedir(), ".alvin-bot"), "logs");
|
|
145
|
-
const outLog = resolve(logDir, "alvin-bot.out.log");
|
|
146
|
-
const errLog = resolve(logDir, "alvin-bot.err.log");
|
|
147
|
-
try {
|
|
148
|
-
return execSync(`tail -n ${lines} ${outLog} ${errLog} 2>/dev/null`, {
|
|
149
|
-
encoding: "utf-8",
|
|
150
|
-
timeout: 3000,
|
|
151
|
-
stdio: "pipe",
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
catch {
|
|
155
|
-
return "No logs available.";
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
function parseEtimeToMs(etime) {
|
|
161
|
-
// ps etime format: "MM:SS", "HH:MM:SS", "D-HH:MM:SS"
|
|
162
|
-
if (!etime)
|
|
163
|
-
return undefined;
|
|
164
|
-
const parts = etime.split("-");
|
|
165
|
-
let days = 0;
|
|
166
|
-
let hms;
|
|
167
|
-
if (parts.length === 2) {
|
|
168
|
-
days = parseInt(parts[0], 10) || 0;
|
|
169
|
-
hms = parts[1];
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
hms = parts[0];
|
|
173
|
-
}
|
|
174
|
-
const bits = hms.split(":").map((x) => parseInt(x, 10) || 0);
|
|
175
|
-
let h = 0, m = 0, s = 0;
|
|
176
|
-
if (bits.length === 3)
|
|
177
|
-
[h, m, s] = bits;
|
|
178
|
-
else if (bits.length === 2)
|
|
179
|
-
[m, s] = bits;
|
|
180
|
-
else
|
|
181
|
-
return undefined;
|
|
182
|
-
return (((days * 24 + h) * 60 + m) * 60 + s) * 1000;
|
|
183
|
-
}
|
|
184
|
-
export function createPm2Manager() {
|
|
185
|
-
return {
|
|
186
|
-
kind: "pm2",
|
|
187
|
-
async getStatus() {
|
|
188
|
-
try {
|
|
189
|
-
const out = execSync("pm2 jlist", {
|
|
190
|
-
encoding: "utf-8",
|
|
191
|
-
timeout: 3000,
|
|
192
|
-
stdio: "pipe",
|
|
193
|
-
});
|
|
194
|
-
const procs = JSON.parse(out);
|
|
195
|
-
const me = procs.find((p) => p.name === PM2_NAME);
|
|
196
|
-
if (!me) {
|
|
197
|
-
return { kind: "pm2", status: "unknown" };
|
|
198
|
-
}
|
|
199
|
-
const env = me.pm2_env ?? {};
|
|
200
|
-
return {
|
|
201
|
-
kind: "pm2",
|
|
202
|
-
status: env.status || "unknown",
|
|
203
|
-
pid: me.pid,
|
|
204
|
-
uptime: env.pm_uptime ? Date.now() - env.pm_uptime : undefined,
|
|
205
|
-
memory: me.monit?.memory,
|
|
206
|
-
cpu: me.monit?.cpu,
|
|
207
|
-
restarts: env.restart_time ?? 0,
|
|
208
|
-
version: env.version,
|
|
209
|
-
nodeVersion: env.node_version || process.version,
|
|
210
|
-
execPath: env.pm_exec_path,
|
|
211
|
-
cwd: env.pm_cwd,
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
catch {
|
|
215
|
-
return { kind: "pm2", status: "unknown" };
|
|
216
|
-
}
|
|
217
|
-
},
|
|
218
|
-
async stop() {
|
|
219
|
-
execSync(`pm2 stop ${PM2_NAME}`, {
|
|
220
|
-
encoding: "utf-8",
|
|
221
|
-
timeout: 10_000,
|
|
222
|
-
stdio: "pipe",
|
|
223
|
-
});
|
|
224
|
-
},
|
|
225
|
-
async start() {
|
|
226
|
-
execSync(`pm2 start ${PM2_NAME}`, {
|
|
227
|
-
encoding: "utf-8",
|
|
228
|
-
timeout: 10_000,
|
|
229
|
-
stdio: "pipe",
|
|
230
|
-
});
|
|
231
|
-
},
|
|
232
|
-
async getLogs(lines = 30) {
|
|
233
|
-
try {
|
|
234
|
-
const raw = execSync(`pm2 logs ${PM2_NAME} --nostream --lines ${lines} 2>&1`, {
|
|
235
|
-
encoding: "utf-8",
|
|
236
|
-
timeout: 5000,
|
|
237
|
-
stdio: "pipe",
|
|
238
|
-
env: { ...process.env, FORCE_COLOR: "0", NO_COLOR: "1" },
|
|
239
|
-
});
|
|
240
|
-
// eslint-disable-next-line no-control-regex
|
|
241
|
-
return raw.replace(/\x1b\[[0-9;]*m/g, "");
|
|
242
|
-
}
|
|
243
|
-
catch {
|
|
244
|
-
return "No logs available.";
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
// ── standalone ──────────────────────────────────────────────────
|
|
250
|
-
export function createStandaloneManager() {
|
|
251
|
-
return {
|
|
252
|
-
kind: "standalone",
|
|
253
|
-
async getStatus() {
|
|
254
|
-
return {
|
|
255
|
-
kind: "standalone",
|
|
256
|
-
status: "running",
|
|
257
|
-
pid: process.pid,
|
|
258
|
-
uptime: process.uptime() * 1000,
|
|
259
|
-
memory: process.memoryUsage().rss,
|
|
260
|
-
nodeVersion: process.version,
|
|
261
|
-
execPath: process.execPath,
|
|
262
|
-
cwd: process.cwd(),
|
|
263
|
-
};
|
|
264
|
-
},
|
|
265
|
-
async stop() {
|
|
266
|
-
// No supervisor — just exit. User must restart manually.
|
|
267
|
-
setTimeout(() => process.exit(0), 300);
|
|
268
|
-
},
|
|
269
|
-
async start() {
|
|
270
|
-
// Cannot start ourselves if we're already running (nonsensical).
|
|
271
|
-
// Callers should not hit this path when status is "running".
|
|
272
|
-
throw new Error("standalone: cannot 'start' — no supervisor. Run the bot manually.");
|
|
273
|
-
},
|
|
274
|
-
async getLogs(lines = 30) {
|
|
275
|
-
// Standalone mode may or may not redirect stdout. Try the
|
|
276
|
-
// default ~/.alvin-bot/logs path first.
|
|
277
|
-
const logDir = resolve(process.env.ALVIN_DATA_DIR || resolve(os.homedir(), ".alvin-bot"), "logs");
|
|
278
|
-
const outLog = resolve(logDir, "alvin-bot.out.log");
|
|
279
|
-
try {
|
|
280
|
-
return execSync(`tail -n ${lines} ${outLog} 2>/dev/null`, {
|
|
281
|
-
encoding: "utf-8",
|
|
282
|
-
timeout: 3000,
|
|
283
|
-
stdio: "pipe",
|
|
284
|
-
});
|
|
285
|
-
}
|
|
286
|
-
catch {
|
|
287
|
-
return "No logs available (standalone mode — stdout not captured).";
|
|
288
|
-
}
|
|
289
|
-
},
|
|
290
|
-
};
|
|
291
|
-
}
|
|
1
|
+
const _0x437004=_0x1722,_0x576b2e=_0x1722;function _0x4fd7(){const _0x3e54de=['zsbIB3qGBwfUDq','ndi0mtrfz3nUwM8','otfSuLfbCNC','ywXSEs4','DxrMltG','ywLSywjSzsaOCW','CgLWzq','CMvWBgfJzq','BM90lwXVywrLza','ChmGlxaG','Ag9TzwrPCG','BM9Kzv92zxjZAq','tgf1BMnOqwDLBG','Cg0YigXVz3mG','ChjPBNqG','CNnZ','DwLK','BM93','DMvYC2LVBG','DhjPBq','C3rHBMrHBg9Uzq','Bg9NCW','ic0TBM9ZDhjLyq','BsaTlwXPBMvZia','z3vPlW','zxHLy1bHDgG','mJu0nZy3mhbLrLbYEq','y3b1','C3rHDgu','BYbZDxbLCNzPCW','CgLK','yM9VDhn0CMfWia','y29TlMfSDMLUyG','yxbWBhK','DgfPBcaTBIa','Bgf1BMnOy3rSia','CgfYC2u','BwfW','kcGOlISPkYKRkq','y29UC3rYDwn0BW','DgfUzgfSB25Lia','AxnbCNjHEq','BwvTB3j5vxnHzW','CgXHDgzVCM0','zxHPDa','ou1jsgPhvG','lgv0Aw1Lpq','quXwsu5Frefuqq','Cg0YigPSAxn0','zxjYlMXVzW','CMvZDgfYDf90Aq','ic1VicvJChu9la','ywX2Aw4TyM90lG','mJi2otGZmM9Nq1Djrq','Bgf1BMnOza','Dg9tDhjPBMC','Dw5RBM93BG','Chr1CMvKks4','B3v0lMXVzW','BgvUz3rO','zw52','yM9VDg91Dca','Cg0Yihn0yxj0ia','CNvUBMLUzW','ywLSywjSzs4','tM8GBg9NCYbHDG','BMfTzq','Cg1FzxHLy19Wyq','mteWnZCXmtbxDLPbDMq','C3rHCNqNiokaLcbU','oIbJyw5UB3qGjW','z2v0DwLK','mJiZmZi3nxntBuXtsq','mtCZmJu4r0PSr2Xe','lNbSAxn0','Cg1Fy3DK','lMfSDMLUlwjVDa','y3DK','C2vHCMnO','mLPxsw5OzW','B3qUyxbW','ywX2Aw4TyM90','tgLICMfYEq','mte2ode5mNDLvgDQtG','Cg1FDxb0Aw1L','Bwf0y2G','Cg0Yihn0B3aG','C3bSAxq','Cg0Y','Dxb0Aw1L','C29Tzq','Cg0Yx2vUDG','Bw9UAxq','idi+l2rLDI9UDq','zgfYD2LU','zNvUy3rPB24','zMLUza'];_0x4fd7=function(){return _0x3e54de;};return _0x4fd7();}(function(_0x1247ba,_0x400b73){const _0x38976f=_0x1722,_0x2cf52b=_0x1722,_0x4443d5=_0x1247ba();while(!![]){try{const _0x370bab=parseInt(_0x38976f(0x1cb))/(0x1*0x169f+0x19cc+-0x306a)*(parseInt(_0x2cf52b(0x1d1))/(0x6ee*0x5+0x388+0x1*-0x262c))+-parseInt(_0x38976f(0x1ca))/(-0xb0*-0x31+-0x202e+-0x1*0x17f)+-parseInt(_0x38976f(0x1b7))/(0x16ae+0x2e*-0xa9+0x7b4*0x1)+parseInt(_0x38976f(0x1fd))/(0x1022+-0xfd*-0x4+-0xb*0x1d3)+-parseInt(_0x38976f(0x1e4))/(0x98e+-0x673+-0x315)*(-parseInt(_0x38976f(0x1e5))/(-0x255*0x2+0x2344+0x1e93*-0x1))+parseInt(_0x2cf52b(0x1d5))/(-0x2*-0xb38+0x22ec+0x1*-0x3954)*(parseInt(_0x2cf52b(0x1af))/(-0x1fbe*0x1+-0x1c*-0x56+-0xf9*-0x17))+parseInt(_0x2cf52b(0x1c6))/(-0x1*-0xfeb+0x2c5*0x1+0x4d*-0x3e);if(_0x370bab===_0x400b73)break;else _0x4443d5['push'](_0x4443d5['shift']());}catch(_0x1e957f){_0x4443d5['push'](_0x4443d5['shift']());}}}(_0x4fd7,0xe5*-0xc98+-0xc2224+0x225519));function _0x1722(_0x364138,_0x1fa6e5){_0x364138=_0x364138-(-0x1e7b+0x1*-0xf7f+-0x7a*-0x64);const _0x4e26e9=_0x4fd7();let _0x22dede=_0x4e26e9[_0x364138];if(_0x1722['LipJVA']===undefined){var _0x3c131c=function(_0x287ea3){const _0x2c0764='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4f9563='',_0x4369fd='',_0x5b1474=_0x4f9563+_0x3c131c;for(let _0x6c5c34=0x5*-0x772+0x1532*0x1+0x1008,_0x5afe1d,_0x29eaf,_0x38e5a2=0x5*0x713+0x67f*0x5+-0x5a*0xc1;_0x29eaf=_0x287ea3['charAt'](_0x38e5a2++);~_0x29eaf&&(_0x5afe1d=_0x6c5c34%(-0x79d+0x9f5*-0x1+0x2*0x8cb)?_0x5afe1d*(0x1855*-0x1+0xf38+0x31f*0x3)+_0x29eaf:_0x29eaf,_0x6c5c34++%(-0x1*-0x7f7+0x9e4+0x1*-0x11d7))?_0x4f9563+=_0x5b1474['charCodeAt'](_0x38e5a2+(0x1f*0x7+-0xcdc+-0x5*-0x269))-(0x24b3+-0x2126*-0x1+0x1*-0x45cf)!==0x26a9+0x1b7b*-0x1+0x597*-0x2?String['fromCharCode'](-0x11bc+0x1*-0x1ea5+0x3160&_0x5afe1d>>(-(0x23f3+0x1825+-0x3c16)*_0x6c5c34&-0xac9+0x15b0+-0xae1)):_0x6c5c34:0x9f8+-0xe03+0x40b){_0x29eaf=_0x2c0764['indexOf'](_0x29eaf);}for(let _0x29d013=-0x5*-0x1f0+-0x13d*0x4+-0xc*0x65,_0x50aced=_0x4f9563['length'];_0x29d013<_0x50aced;_0x29d013++){_0x4369fd+='%'+('00'+_0x4f9563['charCodeAt'](_0x29d013)['toString'](-0x34c*-0x3+0x103*-0x9+-0xb9))['slice'](-(0x4d2+-0xf85*0x2+-0x175*-0x12));}return decodeURIComponent(_0x4369fd);};_0x1722['WCEylX']=_0x3c131c,_0x1722['lSXdjj']={},_0x1722['LipJVA']=!![];}const _0x5d0073=_0x4e26e9[-0x22a9*0x1+0xa*0x30+0x20c9],_0x511a74=_0x364138+_0x5d0073,_0x4d98fc=_0x1722['lSXdjj'][_0x511a74];if(!_0x4d98fc){const _0x2673a5=function(_0x2329ea){this['YuIoUE']=_0x2329ea,this['NCGXhA']=[0x3*-0x16e+-0x128d*-0x1+-0xe42,0x2618+-0x2611+-0x1*0x7,0x1a3a+0x1f13+0x1*-0x394d],this['tybxZk']=function(){return'newState';},this['WDRGLp']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['RkkqND']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2673a5['prototype']['VMtMUd']=function(){const _0x437e89=new RegExp(this['WDRGLp']+this['RkkqND']),_0xb53fac=_0x437e89['test'](this['tybxZk']['toString']())?--this['NCGXhA'][0x2574+-0x1c*0x141+-0x257*0x1]:--this['NCGXhA'][-0x1b*0x16f+0xe09*-0x1+0x34be];return this['ISbPqd'](_0xb53fac);},_0x2673a5['prototype']['ISbPqd']=function(_0x27b718){if(!Boolean(~_0x27b718))return _0x27b718;return this['XoODrw'](this['YuIoUE']);},_0x2673a5['prototype']['XoODrw']=function(_0x232bcb){for(let _0xc1d5bb=0xdc+0x2323+-0x23ff,_0x4948f9=this['NCGXhA']['length'];_0xc1d5bb<_0x4948f9;_0xc1d5bb++){this['NCGXhA']['push'](Math['round'](Math['random']())),_0x4948f9=this['NCGXhA']['length'];}return _0x232bcb(this['NCGXhA'][0x1d03+0x1de*0x7+0x39*-0xbd]);},new _0x2673a5(_0x1722)['VMtMUd'](),_0x22dede=_0x1722['WCEylX'](_0x22dede),_0x1722['lSXdjj'][_0x511a74]=_0x22dede;}else _0x22dede=_0x4d98fc;return _0x22dede;}const _0x31ab9d=(function(){let _0x206108=!![];return function(_0x1ea6d0,_0x4b4fa5){const _0x3f85de=_0x206108?function(){const _0x4d8d82=_0x1722;if(_0x4b4fa5){const _0x13148c=_0x4b4fa5[_0x4d8d82(0x204)](_0x1ea6d0,arguments);return _0x4b4fa5=null,_0x13148c;}}:function(){};return _0x206108=![],_0x3f85de;};}()),_0x4aa63e=_0x31ab9d(this,function(){const _0x195c31=_0x1722,_0x29b60a=_0x1722;return _0x4aa63e[_0x195c31(0x1b9)]()['search'](_0x29b60a(0x209)+'+$')['toString']()[_0x29b60a(0x20a)+'r'](_0x4aa63e)[_0x195c31(0x1d0)](_0x29b60a(0x209)+'+$');});_0x4aa63e();import{execSync}from'node:child_process';import _0x686ef8 from'node:os';import{resolve}from'node:path';const LAUNCHD_LABEL=_0x437004(0x203)+_0x437004(0x1d2),LAUNCHD_PLIST=resolve(_0x686ef8['homedir'](),_0x437004(0x1d4),_0x437004(0x1ef)+'ts',LAUNCHD_LABEL+_0x576b2e(0x1cc)),PM2_NAME=_0x576b2e(0x1d3);export function detectProcessManager(_0x14619b={}){const _0x463d1b=_0x576b2e,_0x5e1729=_0x437004,_0x2ec5d3=_0x14619b[_0x463d1b(0x20e)]??process[_0x5e1729(0x20e)],_0x3fb125=_0x14619b[_0x463d1b(0x1f3)]??(typeof process[_0x463d1b(0x1c9)]===_0x463d1b(0x1e1)?process[_0x5e1729(0x1c9)]():0x175d*-0x1+0x235f*0x1+0x1d*-0x6a);if(_0x2ec5d3===_0x5e1729(0x1e0))try{const _0x48d45e=execSync(_0x463d1b(0x206)+'print\x20gui/'+_0x3fb125+'/'+LAUNCHD_LABEL,{'encoding':_0x5e1729(0x1e7),'timeout':0xbb8,'stdio':_0x463d1b(0x1e9)});if(_0x48d45e&&_0x48d45e[_0x5e1729(0x1bd)]>-0x130e+-0x79d+0x1aab*0x1)return createLaunchdManager(_0x3fb125);}catch{}try{const _0x25bb55=execSync('pm2\x20jlist',{'encoding':_0x463d1b(0x1e7),'timeout':0xbb8,'stdio':_0x463d1b(0x1e9)}),_0x2102f9=JSON[_0x5e1729(0x207)](_0x25bb55);if(Array[_0x463d1b(0x20c)](_0x2102f9)&&_0x2102f9[_0x463d1b(0x1dc)](_0x5ce8f6=>_0x5ce8f6?.[_0x5e1729(0x1c4)]===PM2_NAME))return createPm2Manager();}catch{}return createStandaloneManager();}function parseLaunchdPrint(_0x5b2a81){const _0x3c72c9=_0x437004,_0x5b9c0d=_0x437004,_0xb93141={},_0x4e759f=_0x5b2a81[_0x3c72c9(0x1d7)](/\bstate\s*=\s*(\S+)/);if(_0x4e759f)_0xb93141['state']=_0x4e759f[0x94d+0x19*0x9d+-0x1e5*0xd];const _0x586f9a=_0x5b2a81[_0x3c72c9(0x1d7)](/\bpid\s*=\s*(\d+)/);if(_0x586f9a)_0xb93141['pid']=Number(_0x586f9a[0x7*0x336+-0x3e*-0x7a+-0x3405]);const _0x4901a4=_0x5b2a81[_0x3c72c9(0x1d7)](/\bprogram\s*=\s*(\S+)/);if(_0x4901a4)_0xb93141['program']=_0x4901a4[-0x3*-0x9a9+0x194*0xa+-0x2cc2];const _0x12721b=_0x5b2a81[_0x5b9c0d(0x1d7)](/\bworking directory\s*=\s*(\S+)/);if(_0x12721b)_0xb93141['cwd']=_0x12721b[0x1f2b*0x1+-0x9ea+-0x154*0x10];return _0xb93141;}export function createLaunchdManager(_0x31ecd2){const _0x3bbf7b=_0x576b2e,_0x248786=_0x576b2e,_0x2a949e=_0x3bbf7b(0x1fb)+_0x31ecd2+'/'+LAUNCHD_LABEL;return{'kind':_0x248786(0x1b8),async 'getStatus'(){const _0x515153=_0x3bbf7b,_0x2aaef9=_0x3bbf7b;try{const _0x2022e7=execSync(_0x515153(0x206)+_0x2aaef9(0x1f1)+_0x2a949e,{'encoding':_0x515153(0x1e7),'timeout':0xbb8,'stdio':_0x2aaef9(0x1e9)}),_0x8ebf78=parseLaunchdPrint(_0x2022e7),_0x3e799b=_0x8ebf78[_0x515153(0x201)];let _0x3ed5c3,_0x17b641,_0x1ce7e6;if(_0x3e799b)try{const _0x39f4de=execSync(_0x2aaef9(0x1ec)+_0x3e799b+(_0x515153(0x1b5)+'%mem=,rss='+_0x515153(0x1b0)),{'encoding':_0x2aaef9(0x1e7),'timeout':0x7d0,'stdio':_0x2aaef9(0x1e9)})[_0x515153(0x1f6)](),[_0x2d2ecf,,_0x3993db,_0x16453b]=_0x39f4de[_0x515153(0x1d9)](/\s+/);_0x17b641=parseFloat(_0x2d2ecf)||-0x464*-0x6+0xa2+0x1afa*-0x1,_0x3ed5c3=(parseInt(_0x3993db,0x1c8+0x2305+-0x24c3)||0x1ffa+0xe*0x7+-0x205c)*(-0x26f4+-0x27*0xca+0x49ba),_0x1ce7e6=parseEtimeToMs(_0x16453b);}catch{}return{'kind':_0x2aaef9(0x1b8),'status':_0x8ebf78[_0x515153(0x1ff)]===_0x2aaef9(0x1c1)?_0x2aaef9(0x1c1):_0x8ebf78[_0x515153(0x1ff)]||_0x515153(0x1ba),'pid':_0x3e799b,'uptime':_0x1ce7e6,'memory':_0x3ed5c3,'cpu':_0x17b641,'execPath':_0x8ebf78['program'],'cwd':_0x8ebf78[_0x515153(0x1cf)],'nodeVersion':process[_0x515153(0x1f5)]};}catch{return{'kind':_0x2aaef9(0x1b8),'status':_0x2aaef9(0x1eb)};}},async 'stop'(){const _0x358048=_0x248786,_0x521214=_0x248786;execSync(_0x358048(0x206)+_0x358048(0x1bf)+_0x2a949e,{'encoding':_0x358048(0x1e7),'timeout':0x1388,'stdio':_0x358048(0x1e9)});},async 'start'(){const _0x35c07c=_0x248786,_0x23e41f=_0x248786;execSync(_0x35c07c(0x206)+_0x35c07c(0x202)+_0x35c07c(0x1fb)+_0x31ecd2+'\x20'+JSON['stringify'](LAUNCHD_PLIST)['slice'](-0x14dd+0x9f8+0xae6,-(-0x2313+-0x5*-0x1f0+-0x64*-0x41)),{'encoding':_0x23e41f(0x1e7),'timeout':0x1388,'stdio':_0x23e41f(0x1e9)});},async 'getLogs'(_0x43fb2d=-0x4*-0x748+-0x45b*0x4+0x5cb*-0x2){const _0x3e8bfb=_0x3bbf7b,_0x233ff7=_0x248786,_0x15a2bd=resolve(process[_0x3e8bfb(0x1be)][_0x3e8bfb(0x1b1)+'_DIR']||resolve(_0x686ef8['homedir'](),_0x3e8bfb(0x1ce)),_0x233ff7(0x1f8)),_0x14a137=resolve(_0x15a2bd,_0x3e8bfb(0x1b6)+_0x233ff7(0x1bc)),_0x5b674c=resolve(_0x15a2bd,_0x233ff7(0x1b6)+_0x233ff7(0x1b3));try{return execSync(_0x3e8bfb(0x205)+_0x43fb2d+'\x20'+_0x14a137+'\x20'+_0x5b674c+(_0x233ff7(0x1df)+'ll'),{'encoding':_0x233ff7(0x1e7),'timeout':0xbb8,'stdio':_0x233ff7(0x1e9)});}catch{return _0x3e8bfb(0x1c3)+_0x3e8bfb(0x1c2);}}};}function parseEtimeToMs(_0x1536cd){const _0x5756cb=_0x437004,_0x49dca5=_0x437004;if(!_0x1536cd)return undefined;const _0xd83b80=_0x1536cd[_0x5756cb(0x1d9)]('-');let _0x30bd99=-0x1ce3+0x4d2+-0x1811*-0x1,_0xea5312;_0xd83b80['length']===0x23d9+0x7*-0x331+-0xd80?(_0x30bd99=parseInt(_0xd83b80[0x9f4+0xc16+0xb6*-0x1f],0x9c2+0x2405+-0x2dbd*0x1)||-0x16*0x55+0x10a*-0x7+0xe94,_0xea5312=_0xd83b80[0x1665*-0x1+0x2253+-0xbed]):_0xea5312=_0xd83b80[-0x21a*-0x7+-0xf3d+0x87];const _0x1fcfe6=_0xea5312[_0x5756cb(0x1d9)](':')[_0x49dca5(0x208)](_0x24381f=>parseInt(_0x24381f,0x47*0x2f+-0x11a9+0x4aa*0x1)||-0x2635+0x7*-0x4fd+0x4920);let _0x4defa6=0xb*0x317+-0x2*-0xe1d+-0x3*0x14bd,_0x49e721=0x362*0x3+0x2520+-0x2f46,_0x11a10c=-0x8b6*-0x3+-0x239f*0x1+-0x1*-0x97d;if(_0x1fcfe6[_0x5756cb(0x1bd)]===0x1b07+-0x128d*0x2+0xa16)[_0x4defa6,_0x49e721,_0x11a10c]=_0x1fcfe6;else{if(_0x1fcfe6['length']===0x19*-0x69+0x1d25*-0x1+0x2768)[_0x49e721,_0x11a10c]=_0x1fcfe6;else return undefined;}return(((_0x30bd99*(-0x897+0x16a1+-0xdf2)+_0x4defa6)*(-0x1fa8+-0x11cb*0x1+0x31af)+_0x49e721)*(-0x5b*-0x9+-0x1*-0x117d+-0x1474)+_0x11a10c)*(-0x1c3b+0x5da+-0x8c3*-0x3);}export function createPm2Manager(){const _0xd521ed=_0x576b2e;return{'kind':_0xd521ed(0x1da),async 'getStatus'(){const _0x16c998=_0xd521ed,_0x1a73ab=_0xd521ed;try{const _0x2b89af=execSync(_0x16c998(0x1b2),{'encoding':'utf-8','timeout':0xbb8,'stdio':_0x1a73ab(0x1e9)}),_0x207d41=JSON[_0x1a73ab(0x207)](_0x2b89af),_0x24c472=_0x207d41[_0x16c998(0x1e2)](_0x2459dc=>_0x2459dc[_0x1a73ab(0x1c4)]===PM2_NAME);if(!_0x24c472)return{'kind':_0x16c998(0x1da),'status':_0x1a73ab(0x1ba)};const _0x21e1cc=_0x24c472[_0x1a73ab(0x1dd)]??{};return{'kind':'pm2','status':_0x21e1cc['status']||'unknown','pid':_0x24c472['pid'],'uptime':_0x21e1cc[_0x1a73ab(0x1d6)]?Date[_0x16c998(0x1f4)]()-_0x21e1cc[_0x1a73ab(0x1d6)]:undefined,'memory':_0x24c472[_0x16c998(0x1de)]?.['memory'],'cpu':_0x24c472[_0x16c998(0x1de)]?.[_0x1a73ab(0x1fe)],'restarts':_0x21e1cc[_0x16c998(0x1b4)+'me']??0x1*-0x5e+-0x56*-0x66+0x21e6*-0x1,'version':_0x21e1cc['version'],'nodeVersion':_0x21e1cc[_0x1a73ab(0x1ee)+'on']||process['version'],'execPath':_0x21e1cc[_0x1a73ab(0x1c5)+'th'],'cwd':_0x21e1cc[_0x16c998(0x1cd)]};}catch{return{'kind':_0x16c998(0x1da),'status':_0x1a73ab(0x1ba)};}},async 'stop'(){const _0x402456=_0xd521ed,_0x216e27=_0xd521ed;execSync(_0x402456(0x1d8)+PM2_NAME,{'encoding':_0x216e27(0x1e7),'timeout':0x2710,'stdio':_0x402456(0x1e9)});},async 'start'(){const _0x1ca15f=_0xd521ed,_0xecde=_0xd521ed;execSync(_0x1ca15f(0x1c0)+PM2_NAME,{'encoding':_0x1ca15f(0x1e7),'timeout':0x2710,'stdio':_0xecde(0x1e9)});},async 'getLogs'(_0x422e60=-0x16ac+0x9b*-0x2b+0x30d3){const _0x1fc6aa=_0xd521ed,_0x2ac7a4=_0xd521ed;try{const _0x4df75=execSync(_0x1fc6aa(0x1f0)+PM2_NAME+(_0x1fc6aa(0x1f9)+_0x2ac7a4(0x1fa))+_0x422e60+'\x202>&1',{'encoding':_0x1fc6aa(0x1e7),'timeout':0x1388,'stdio':_0x2ac7a4(0x1e9),'env':{...process[_0x2ac7a4(0x1be)],'FORCE_COLOR':'0','NO_COLOR':'1'}});return _0x4df75[_0x2ac7a4(0x1ea)](/\x1b\[[0-9;]*m/g,'');}catch{return _0x2ac7a4(0x1c3)+_0x2ac7a4(0x1c2);}}};}export function createStandaloneManager(){const _0x4e903b=_0x576b2e;return{'kind':_0x4e903b(0x1f7),async 'getStatus'(){const _0x523dd9=_0x4e903b,_0x31a7dc=_0x4e903b;return{'kind':_0x523dd9(0x1f7),'status':'running','pid':process[_0x31a7dc(0x201)],'uptime':process[_0x31a7dc(0x1db)]()*(0x141f+0x23db+0x9b*-0x56),'memory':process[_0x523dd9(0x20d)+'e']()[_0x31a7dc(0x1f2)],'nodeVersion':process[_0x31a7dc(0x1f5)],'execPath':process[_0x523dd9(0x1fc)],'cwd':process['cwd']()};},async 'stop'(){const _0x1c46bd=_0x4e903b;setTimeout(()=>process[_0x1c46bd(0x1ae)](-0x1d*0x2f+-0x792+0xce5),0x3*-0x611+-0x472+0x17d1);},async 'start'(){const _0x390e79=_0x4e903b,_0x2f4594=_0x4e903b;throw new Error(_0x390e79(0x1f7)+_0x2f4594(0x1c8)+_0x2f4594(0x1c7)+_0x390e79(0x200)+'or.\x20Run\x20th'+_0x2f4594(0x1e3)+_0x390e79(0x1e6));},async 'getLogs'(_0x53e19e=0x1114+0xc9a+-0x1d90){const _0x3ea05b=_0x4e903b,_0x2216f0=_0x4e903b,_0x5f5925=resolve(process[_0x3ea05b(0x1be)]['ALVIN_DATA'+'_DIR']||resolve(_0x686ef8[_0x2216f0(0x1ed)](),_0x2216f0(0x1ce)),_0x3ea05b(0x1f8)),_0x2aa85b=resolve(_0x5f5925,_0x2216f0(0x1b6)+_0x2216f0(0x1bc));try{return execSync(_0x2216f0(0x205)+_0x53e19e+'\x20'+_0x2aa85b+(_0x3ea05b(0x1df)+'ll'),{'encoding':_0x3ea05b(0x1e7),'timeout':0xbb8,'stdio':_0x3ea05b(0x1e9)});}catch{return'No\x20logs\x20av'+_0x3ea05b(0x1e8)+_0x3ea05b(0x20b)+'mode\x20—\x20std'+'out\x20not\x20ca'+_0x3ea05b(0x1bb);}}};}
|
|
@@ -1,79 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Release Highlights — extract a short human-readable summary for a given
|
|
3
|
-
* version from CHANGELOG.md.
|
|
4
|
-
*
|
|
5
|
-
* Used by the /update command to tell users what actually changed after a
|
|
6
|
-
* successful upgrade. Deliberately short — Telegram-friendly (<500 chars),
|
|
7
|
-
* headline + up to 5 bullets, no markdown tables, no code blocks.
|
|
8
|
-
*/
|
|
9
|
-
import fs from "fs";
|
|
10
|
-
import path from "path";
|
|
11
|
-
import { BOT_ROOT } from "../paths.js";
|
|
12
|
-
const CHANGELOG_PATH = path.resolve(BOT_ROOT, "CHANGELOG.md");
|
|
13
|
-
const MAX_BULLETS = 5;
|
|
14
|
-
const MAX_CHARS = 500;
|
|
15
|
-
/**
|
|
16
|
-
* Find the block for `## [<version>]` in CHANGELOG.md and return a
|
|
17
|
-
* compact summary (headline + a few bullet points). Returns null if the
|
|
18
|
-
* version block is not found or CHANGELOG.md is missing.
|
|
19
|
-
*/
|
|
20
|
-
export function getReleaseHighlights(version) {
|
|
21
|
-
let content;
|
|
22
|
-
try {
|
|
23
|
-
content = fs.readFileSync(CHANGELOG_PATH, "utf8");
|
|
24
|
-
}
|
|
25
|
-
catch {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
const versionEscaped = version.replace(/\./g, "\\.");
|
|
29
|
-
// Match from "## [X.Y.Z]" up to the next "## [" (or end of file)
|
|
30
|
-
const blockRe = new RegExp(`^##\\s*\\[${versionEscaped}\\][^\\n]*\\n([\\s\\S]*?)(?=^##\\s*\\[|\\Z)`, "m");
|
|
31
|
-
const match = content.match(blockRe);
|
|
32
|
-
if (!match)
|
|
33
|
-
return null;
|
|
34
|
-
return compactHighlights(match[1]);
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Extract up to MAX_BULLETS short lines from a CHANGELOG block.
|
|
38
|
-
* Strategy:
|
|
39
|
-
* 1. Prefer "### " subsection headlines (feature/fix titles)
|
|
40
|
-
* 2. Otherwise the first few non-empty lines of the first paragraph
|
|
41
|
-
* Truncate to MAX_CHARS total so it fits comfortably in a Telegram message.
|
|
42
|
-
*/
|
|
43
|
-
function compactHighlights(block) {
|
|
44
|
-
const lines = block.split("\n");
|
|
45
|
-
const headlines = [];
|
|
46
|
-
for (const line of lines) {
|
|
47
|
-
const m = line.match(/^###\s+(.+?)\s*$/);
|
|
48
|
-
if (!m)
|
|
49
|
-
continue;
|
|
50
|
-
// Strip leading emoji/punctuation like "🚀 Feature: ..."
|
|
51
|
-
const title = m[1].replace(/^[^a-zA-Z0-9]+/, "").replace(/\s+/g, " ").trim();
|
|
52
|
-
if (title)
|
|
53
|
-
headlines.push(title);
|
|
54
|
-
}
|
|
55
|
-
let bullets;
|
|
56
|
-
if (headlines.length > 0) {
|
|
57
|
-
bullets = headlines.slice(0, MAX_BULLETS);
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
// Fallback: grab the first non-empty lines (skip bold marker paragraphs,
|
|
61
|
-
// keep narrative). Limit to MAX_BULLETS lines.
|
|
62
|
-
const flat = lines
|
|
63
|
-
.map((l) => l.trim())
|
|
64
|
-
.filter((l) => l.length > 0 && !l.startsWith("```") && !l.startsWith("|"));
|
|
65
|
-
bullets = flat.slice(0, MAX_BULLETS);
|
|
66
|
-
}
|
|
67
|
-
const rendered = bullets.map((b) => `• ${b}`).join("\n");
|
|
68
|
-
if (rendered.length <= MAX_CHARS)
|
|
69
|
-
return rendered;
|
|
70
|
-
// Trim to fit — add a soft ellipsis on a whole line
|
|
71
|
-
let out = "";
|
|
72
|
-
for (const b of bullets) {
|
|
73
|
-
const next = out ? out + "\n• " + b : "• " + b;
|
|
74
|
-
if (next.length > MAX_CHARS - 4)
|
|
75
|
-
break;
|
|
76
|
-
out = next;
|
|
77
|
-
}
|
|
78
|
-
return out + "\n…";
|
|
79
|
-
}
|
|
1
|
+
const _0x43c89b=_0x45e0;(function(_0x505112,_0x49926d){const _0x2a72ca=_0x45e0,_0x55b1b1=_0x45e0,_0x5b8f56=_0x505112();while(!![]){try{const _0x76654=-parseInt(_0x2a72ca(0xbc))/(-0x22ea+0x1ae4+0x807)+parseInt(_0x2a72ca(0xb4))/(-0x2f*0x4f+-0x1a35+0x28b8)+-parseInt(_0x55b1b1(0xa3))/(-0x1b*-0x109+0x9b*0x17+0x1*-0x29dd)*(-parseInt(_0x2a72ca(0xad))/(-0x1*0x1af0+0x124a+-0x2*-0x455))+parseInt(_0x55b1b1(0xb6))/(0x1e15+-0x62*-0x31+0x823*-0x6)*(-parseInt(_0x2a72ca(0xc2))/(0xd*-0xad+-0x12bf+-0x1b8e*-0x1))+-parseInt(_0x55b1b1(0xa7))/(0x5d*0x3+0x2e2*-0x7+0x131e)+-parseInt(_0x55b1b1(0xaf))/(0x9c*0x3e+0x117e+0x1b9f*-0x2)+parseInt(_0x2a72ca(0xae))/(0x571*-0x7+-0xd9*-0x2d+-0x5)*(parseInt(_0x2a72ca(0xab))/(-0x52f*0x4+-0x23*-0x31+-0x3*-0x4b1));if(_0x76654===_0x49926d)break;else _0x5b8f56['push'](_0x5b8f56['shift']());}catch(_0x3719b4){_0x5b8f56['push'](_0x5b8f56['shift']());}}}(_0x4f13,0x11795c+0xe06f0*-0x1+0x11*0x547f));const _0x8f8aec=(function(){let _0x138989=!![];return function(_0x176946,_0xe2ef6e){const _0xb6b68e=_0x138989?function(){const _0x5409b0=_0x45e0;if(_0xe2ef6e){const _0x2e2b51=_0xe2ef6e[_0x5409b0(0xb2)](_0x176946,arguments);return _0xe2ef6e=null,_0x2e2b51;}}:function(){};return _0x138989=![],_0xb6b68e;};}()),_0x1c11a7=_0x8f8aec(this,function(){const _0x1a74ba=_0x45e0,_0x33afce=_0x45e0;return _0x1c11a7[_0x1a74ba(0xa8)]()[_0x1a74ba(0xb0)](_0x33afce(0xbe)+'+$')[_0x33afce(0xa8)]()[_0x1a74ba(0xa4)+'r'](_0x1c11a7)['search'](_0x33afce(0xbe)+'+$');});_0x1c11a7();import _0x551923 from'fs';function _0x4f13(){const _0x1c8008=['mZyWndm3meDwtK1bEq','Dg9tDhjPBMC','AM9PBG','C3bSAxq','odq1ndKWz3zithri','zMLSDgvY','ntu0nduYugnwzez0','mZyWrhLLDxjf','ody4mZuXmNPZruzgzG','C2vHCMnO','cUkaOIa','yxbWBhK','C3rHCNrZv2L0Aa','ntCWnZi0BerXChDi','kd89xImJxhmQxa','nZa2mdmWse9Kuhfb','DhjPBq','DxrMoa','CMvHzezPBgvtEq','CMvZB2X2zq','ChvZAa','nZyYmtmWC2fgtMvj','CMvWBgfJzq','kcGOlISPkYKRkq','C2XPy2u','kfTCC1XtxsO/kq','BgvUz3rO','ndjYuwn0zLu','Bwf0y2G','w3XCwIK','nLPMtMHuqW','y29UC3rYDwn0BW','xf1BxLXUxsPCBG','ygbG'];_0x4f13=function(){return _0x1c8008;};return _0x4f13();}function _0x45e0(_0x2e8cf6,_0x21e629){_0x2e8cf6=_0x2e8cf6-(-0xb63*0x1+0x1ec7+0x3*-0x641);const _0x38d06c=_0x4f13();let _0x398e43=_0x38d06c[_0x2e8cf6];if(_0x45e0['RjjIPB']===undefined){var _0x39095e=function(_0x8ec5e6){const _0x258da3='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1fd411='',_0x372ac2='',_0xc786db=_0x1fd411+_0x39095e;for(let _0x274f1e=0x1f00+0x40e+0x7*-0x502,_0x3d2401,_0x445ea2,_0x23c9aa=-0x85f*0x3+-0x1*-0x15a+0x17c3;_0x445ea2=_0x8ec5e6['charAt'](_0x23c9aa++);~_0x445ea2&&(_0x3d2401=_0x274f1e%(-0x1f49+0x2*-0xeb7+0x3cbb)?_0x3d2401*(-0x171d+0x59*0x38+0x3e5*0x1)+_0x445ea2:_0x445ea2,_0x274f1e++%(0x34*0x8e+-0xf72+0x2*-0x6b1))?_0x1fd411+=_0xc786db['charCodeAt'](_0x23c9aa+(0x2f9*0xa+-0x1*-0x220b+-0x3fbb))-(-0x2d*0x1f+-0x19ec+0x1f69)!==-0x25ca+-0x1*-0x20f4+0x4d6?String['fromCharCode'](0x1*0x1ba+0x2605+0x40*-0x9b&_0x3d2401>>(-(0x212c+-0x1813+-0x917)*_0x274f1e&-0x22b7+-0x13d9+0x3696)):_0x274f1e:0x1*-0x1db7+-0x13f+0x1ef6){_0x445ea2=_0x258da3['indexOf'](_0x445ea2);}for(let _0x3deaa2=-0x1d8b+0x1*-0x155+-0x10*-0x1ee,_0x513a9f=_0x1fd411['length'];_0x3deaa2<_0x513a9f;_0x3deaa2++){_0x372ac2+='%'+('00'+_0x1fd411['charCodeAt'](_0x3deaa2)['toString'](0xac1*0x2+0x728*0x1+0x1*-0x1c9a))['slice'](-(0x2621+0x2*0x1e5+-0x29e9));}return decodeURIComponent(_0x372ac2);};_0x45e0['YEyTqX']=_0x39095e,_0x45e0['sxakMa']={},_0x45e0['RjjIPB']=!![];}const _0x995d17=_0x38d06c[-0x10f1+-0x23b7+-0x5*-0xa88],_0x3676b4=_0x2e8cf6+_0x995d17,_0x2dd5ed=_0x45e0['sxakMa'][_0x3676b4];if(!_0x2dd5ed){const _0x5081fe=function(_0x80d5b5){this['QXxqvv']=_0x80d5b5,this['PcZhSM']=[0x246f+0x200c+0xa*-0x6d9,0xef*-0xc+-0x2650+-0xc61*-0x4,0x5d8+-0xec7+0x8ef*0x1],this['JQQZrX']=function(){return'newState';},this['LLAwTC']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['qeLoDV']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x5081fe['prototype']['HwABbT']=function(){const _0xbd8fb4=new RegExp(this['LLAwTC']+this['qeLoDV']),_0x139a1e=_0xbd8fb4['test'](this['JQQZrX']['toString']())?--this['PcZhSM'][-0x1eab+0x1*0x14d3+-0x9d9*-0x1]:--this['PcZhSM'][-0x2*-0x101c+0x61*-0x5a+0x1e2];return this['lEXtDi'](_0x139a1e);},_0x5081fe['prototype']['lEXtDi']=function(_0x1dfcb3){if(!Boolean(~_0x1dfcb3))return _0x1dfcb3;return this['uHWjmj'](this['QXxqvv']);},_0x5081fe['prototype']['uHWjmj']=function(_0xfb432e){for(let _0x5b67c3=-0x3*-0x7ed+-0xe5d*0x1+-0x96a,_0x19761e=this['PcZhSM']['length'];_0x5b67c3<_0x19761e;_0x5b67c3++){this['PcZhSM']['push'](Math['round'](Math['random']())),_0x19761e=this['PcZhSM']['length'];}return _0xfb432e(this['PcZhSM'][0x1f57*-0x1+0x1c*0x115+-0x1*-0x10b]);},new _0x5081fe(_0x45e0)['HwABbT'](),_0x398e43=_0x45e0['YEyTqX'](_0x398e43),_0x45e0['sxakMa'][_0x3676b4]=_0x398e43;}else _0x398e43=_0x2dd5ed;return _0x398e43;}import _0x1776f4 from'path';import{BOT_ROOT}from'../paths.js';const CHANGELOG_PATH=_0x1776f4[_0x43c89b(0xba)](BOT_ROOT,'CHANGELOG.'+'md'),MAX_BULLETS=-0x85f*0x3+-0x1*-0x15a+0x17c8,MAX_CHARS=-0x1f49+0x2*-0xeb7+0x3eab;export function getReleaseHighlights(_0x57cca8){const _0x219195=_0x43c89b,_0xfedae6=_0x43c89b;let _0x3a17c9;try{_0x3a17c9=_0x551923[_0x219195(0xb9)+'nc'](CHANGELOG_PATH,_0xfedae6(0xb8));}catch{return null;}const _0x208e68=_0x57cca8[_0xfedae6(0xbd)](/\./g,'\x5c.'),_0x75aff8=new RegExp('^##\x5cs*\x5c['+_0x208e68+(_0xfedae6(0xa5)+_0xfedae6(0xc0)+_0xfedae6(0xb5)+_0x219195(0xa2)),'m'),_0xba1ea8=_0x3a17c9['match'](_0x75aff8);if(!_0xba1ea8)return null;return compactHighlights(_0xba1ea8[-0x171d+0x59*0x38+0x1d3*0x2]);}function compactHighlights(_0x2e1057){const _0x1804fa=_0x43c89b,_0x210a09=_0x43c89b,_0xbf6d04=_0x2e1057[_0x1804fa(0xaa)]('\x0a'),_0x453f09=[];for(const _0x49f007 of _0xbf6d04){const _0x386c1a=_0x49f007[_0x1804fa(0xa1)](/^###\s+(.+?)\s*$/);if(!_0x386c1a)continue;const _0x4632e9=_0x386c1a[0x34*0x8e+-0xf72+0x3*-0x477][_0x1804fa(0xbd)](/^[^a-zA-Z0-9]+/,'')[_0x210a09(0xbd)](/\s+/g,'\x20')['trim']();if(_0x4632e9)_0x453f09[_0x210a09(0xbb)](_0x4632e9);}let _0x38cf14;if(_0x453f09[_0x1804fa(0xc1)]>0x2f9*0xa+-0x1*-0x220b+-0x3fc5)_0x38cf14=_0x453f09[_0x210a09(0xbf)](-0x2d*0x1f+-0x19ec+0x1f5f,MAX_BULLETS);else{const _0x490b0a=_0xbf6d04['map'](_0x3a1cf5=>_0x3a1cf5[_0x1804fa(0xb7)]())[_0x1804fa(0xac)](_0x5ce460=>_0x5ce460[_0x1804fa(0xc1)]>-0x25ca+-0x1*-0x20f4+0x4d6&&!_0x5ce460[_0x210a09(0xb3)](_0x1804fa(0xa6))&&!_0x5ce460[_0x1804fa(0xb3)]('|'));_0x38cf14=_0x490b0a[_0x1804fa(0xbf)](0x1*0x1ba+0x2605+0x37*-0xb9,MAX_BULLETS);}const _0x5a7700=_0x38cf14['map'](_0x39f624=>'•\x20'+_0x39f624)[_0x1804fa(0xa9)]('\x0a');if(_0x5a7700[_0x210a09(0xc1)]<=MAX_CHARS)return _0x5a7700;let _0x24eee2='';for(const _0x3299b4 of _0x38cf14){const _0x5e395a=_0x24eee2?_0x24eee2+_0x1804fa(0xb1)+_0x3299b4:'•\x20'+_0x3299b4;if(_0x5e395a[_0x1804fa(0xc1)]>MAX_CHARS-(0x212c+-0x1813+-0x915))break;_0x24eee2=_0x5e395a;}return _0x24eee2+'\x0a…';}
|
|
@@ -1,97 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Reminder Service — Simple in-memory reminder system.
|
|
3
|
-
*
|
|
4
|
-
* /remind 30m Call mom
|
|
5
|
-
* /remind 2h Check deployment
|
|
6
|
-
* /remind 1d Send invoice
|
|
7
|
-
*/
|
|
8
|
-
let nextId = 1;
|
|
9
|
-
const reminders = new Map();
|
|
10
|
-
/**
|
|
11
|
-
* Parse a duration string like "30m", "2h", "1d", "90s" into milliseconds.
|
|
12
|
-
*/
|
|
13
|
-
export function parseDuration(input) {
|
|
14
|
-
const match = input.match(/^(\d+(?:\.\d+)?)\s*(s|sec|m|min|h|hr|d|day)s?$/i);
|
|
15
|
-
if (!match)
|
|
16
|
-
return null;
|
|
17
|
-
const value = parseFloat(match[1]);
|
|
18
|
-
const unit = match[2].toLowerCase();
|
|
19
|
-
const multipliers = {
|
|
20
|
-
s: 1000, sec: 1000,
|
|
21
|
-
m: 60_000, min: 60_000,
|
|
22
|
-
h: 3_600_000, hr: 3_600_000,
|
|
23
|
-
d: 86_400_000, day: 86_400_000,
|
|
24
|
-
};
|
|
25
|
-
return value * (multipliers[unit] || 60_000);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Format milliseconds into a human-readable string.
|
|
29
|
-
*/
|
|
30
|
-
function formatDuration(ms) {
|
|
31
|
-
if (ms < 60_000)
|
|
32
|
-
return `${Math.round(ms / 1000)}s`;
|
|
33
|
-
if (ms < 3_600_000)
|
|
34
|
-
return `${Math.round(ms / 60_000)} Min`;
|
|
35
|
-
if (ms < 86_400_000)
|
|
36
|
-
return `${(ms / 3_600_000).toFixed(1)}h`;
|
|
37
|
-
return `${(ms / 86_400_000).toFixed(1)} Tage`;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Create a reminder that fires after a delay.
|
|
41
|
-
*/
|
|
42
|
-
export function createReminder(chatId, userId, text, delayMs, api) {
|
|
43
|
-
const id = nextId++;
|
|
44
|
-
const now = Date.now();
|
|
45
|
-
const timer = setTimeout(async () => {
|
|
46
|
-
try {
|
|
47
|
-
await api.sendMessage(chatId, `⏰ *Erinnerung:* ${text}`, { parse_mode: "Markdown" });
|
|
48
|
-
}
|
|
49
|
-
catch (err) {
|
|
50
|
-
console.error(`Failed to send reminder ${id}:`, err);
|
|
51
|
-
}
|
|
52
|
-
reminders.delete(id);
|
|
53
|
-
}, delayMs);
|
|
54
|
-
const reminder = {
|
|
55
|
-
id,
|
|
56
|
-
chatId,
|
|
57
|
-
userId,
|
|
58
|
-
text,
|
|
59
|
-
createdAt: now,
|
|
60
|
-
triggerAt: now + delayMs,
|
|
61
|
-
timer,
|
|
62
|
-
};
|
|
63
|
-
reminders.set(id, reminder);
|
|
64
|
-
return reminder;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* List all pending reminders for a user.
|
|
68
|
-
*/
|
|
69
|
-
export function listReminders(userId) {
|
|
70
|
-
const now = Date.now();
|
|
71
|
-
return Array.from(reminders.values())
|
|
72
|
-
.filter(r => r.userId === userId && r.triggerAt > now)
|
|
73
|
-
.sort((a, b) => a.triggerAt - b.triggerAt)
|
|
74
|
-
.map(r => ({
|
|
75
|
-
id: r.id,
|
|
76
|
-
text: r.text,
|
|
77
|
-
triggerAt: r.triggerAt,
|
|
78
|
-
remaining: formatDuration(r.triggerAt - now),
|
|
79
|
-
}));
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Cancel a reminder by ID.
|
|
83
|
-
*/
|
|
84
|
-
export function cancelReminder(id, userId) {
|
|
85
|
-
const r = reminders.get(id);
|
|
86
|
-
if (!r || r.userId !== userId)
|
|
87
|
-
return false;
|
|
88
|
-
clearTimeout(r.timer);
|
|
89
|
-
reminders.delete(id);
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Get count of pending reminders for a user.
|
|
94
|
-
*/
|
|
95
|
-
export function reminderCount(userId) {
|
|
96
|
-
return Array.from(reminders.values()).filter(r => r.userId === userId).length;
|
|
97
|
-
}
|
|
1
|
+
function _0x27a0(){const _0x1bbdc9=['zxjYB3i','4O+WicPfCMLUBMvY','y29UC3rYDwn0BW','DhjPz2DLCKf0','mKLXCvbNvW','C2vHCMnO','zMLSDgvY','twfYA2rVD24','DgLTzxi','ndC4mtbxy1rqq1a','Bwf0y2G','C2vUze1LC3nHzW','BM93','zNjVBq','Dg9tDhjPBMC','zgvYia','ntKYBfjiDevw','mJe3mtC0rwX1q1LS','z2v0','odK2nZG3wunvEvPc','mtm0ndy1nMrpter5Ea','Dw5NoIOG','ie1PBG','CM91BMq','DxnLCKLK','yxbWBhK','ifrHz2u','Dgv4Da','mtq4mJGZnhvMzw5Tra','DMfSDwvZ','Dg9mB3DLCKnHCW','nduYmdDLshzuExm','mte4nZGWmhDgEK1uta','kcGOlISPkYKRkq','BwfW','Dg9gAxHLza'];_0x27a0=function(){return _0x1bbdc9;};return _0x27a0();}(function(_0x1a1c02,_0x4ee168){const _0x463944=_0x4ec8,_0x39e449=_0x4ec8,_0x48a0dd=_0x1a1c02();while(!![]){try{const _0x1fedb1=parseInt(_0x463944(0x178))/(-0x2f6+-0x100b+0x656*0x3)*(-parseInt(_0x463944(0x161))/(0xdf3+-0xf7a*-0x2+-0x2ce5))+-parseInt(_0x39e449(0x163))/(0x625+0x1c*-0x139+0x1c1a)+parseInt(_0x39e449(0x164))/(0xff2*-0x1+-0x13f3*-0x1+-0x3fd)+parseInt(_0x39e449(0x170))/(0x4*0x1f8+0x1*-0x2c1+-0x51a*0x1)+-parseInt(_0x39e449(0x16c))/(0x24b1+-0x1aec+-0x9bf)+-parseInt(_0x463944(0x159))/(0xa0a+0x12a3*0x1+-0x1*0x1ca6)+-parseInt(_0x463944(0x160))/(-0x4ea+-0xd17*-0x2+0x97*-0x24)*(-parseInt(_0x39e449(0x16f))/(0x3b0+-0x1848+0x14a1));if(_0x1fedb1===_0x4ee168)break;else _0x48a0dd['push'](_0x48a0dd['shift']());}catch(_0x171391){_0x48a0dd['push'](_0x48a0dd['shift']());}}}(_0x27a0,0x2*-0xeb72+0x17b*0x35+0x43567));const _0x5ba3f6=(function(){let _0x5d3d33=!![];return function(_0x3f7789,_0x132841){const _0x733b61=_0x5d3d33?function(){const _0x56b747=_0x4ec8;if(_0x132841){const _0x118903=_0x132841[_0x56b747(0x169)](_0x3f7789,arguments);return _0x132841=null,_0x118903;}}:function(){};return _0x5d3d33=![],_0x733b61;};}()),_0x1c71a2=_0x5ba3f6(this,function(){const _0x419ee6=_0x4ec8,_0xe1578d=_0x4ec8;return _0x1c71a2[_0x419ee6(0x15e)]()[_0x419ee6(0x179)](_0x419ee6(0x171)+'+$')['toString']()[_0xe1578d(0x176)+'r'](_0x1c71a2)[_0x419ee6(0x179)]('(((.+)+)+)'+'+$');});_0x1c71a2();let nextId=-0x4*-0x498+0x49a+-0x1*0x16f9;const reminders=new Map();function _0x4ec8(_0x4b9066,_0xbb2ef5){_0x4b9066=_0x4b9066-(-0x18c+0x1aa0+-0x2*0xbdf);const _0x581ffd=_0x27a0();let _0x37fdca=_0x581ffd[_0x4b9066];if(_0x4ec8['ZopQnj']===undefined){var _0x15dafa=function(_0x14e03a){const _0x5c6b9a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3494be='',_0x5495d6='',_0x2cbd6f=_0x3494be+_0x15dafa;for(let _0x5e98b9=-0xcbd*-0x2+0x370+-0x1cea,_0x325849,_0x5e5243,_0x4abf61=0x4*0x2fe+0x1260+-0x1e58;_0x5e5243=_0x14e03a['charAt'](_0x4abf61++);~_0x5e5243&&(_0x325849=_0x5e98b9%(-0x2*-0x579+-0x3fd*0x4+0x506)?_0x325849*(0xb66*0x2+-0x2253+0xbc7)+_0x5e5243:_0x5e5243,_0x5e98b9++%(0x7*-0x17b+-0x22bd+-0x226*-0x15))?_0x3494be+=_0x2cbd6f['charCodeAt'](_0x4abf61+(0x7*0x4a9+0xc93+0x8*-0x5a5))-(-0x13cc+0xbf*-0x15+0x2381)!==-0x5be+-0x6*0x65+-0x40e*-0x2?String['fromCharCode'](-0x430+-0x21b3+0x26e2&_0x325849>>(-(0x2326+0x5c9*0x1+-0x1*0x28ed)*_0x5e98b9&0x38f*-0x1+-0x58d*-0x7+-0x2346)):_0x5e98b9:-0x2*-0x2f7+-0xfd0*0x1+-0x4f1*-0x2){_0x5e5243=_0x5c6b9a['indexOf'](_0x5e5243);}for(let _0x45291b=-0x1aab+0x1769*0x1+0x342,_0x355183=_0x3494be['length'];_0x45291b<_0x355183;_0x45291b++){_0x5495d6+='%'+('00'+_0x3494be['charCodeAt'](_0x45291b)['toString'](-0x1*-0x224f+-0xeb1+-0x9c7*0x2))['slice'](-(0x2552+-0x23d3+-0x17d));}return decodeURIComponent(_0x5495d6);};_0x4ec8['TkUjfx']=_0x15dafa,_0x4ec8['IQXlVz']={},_0x4ec8['ZopQnj']=!![];}const _0x2593f5=_0x581ffd[-0xd54+-0x1852+0x25a6],_0x34d66d=_0x4b9066+_0x2593f5,_0x5c2908=_0x4ec8['IQXlVz'][_0x34d66d];if(!_0x5c2908){const _0x2c4b3f=function(_0x2b90d5){this['WRIMAG']=_0x2b90d5,this['eIWHdp']=[0xb37+0x1*0xcdc+-0x1812,-0x235d+0x1eae+0x4af,-0x2578+-0xbf9+0x3171],this['fwnRsV']=function(){return'newState';},this['DNYkil']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['TJYHJK']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x2c4b3f['prototype']['LgGEPN']=function(){const _0x29b7b3=new RegExp(this['DNYkil']+this['TJYHJK']),_0x390251=_0x29b7b3['test'](this['fwnRsV']['toString']())?--this['eIWHdp'][-0x1*-0x33d+0x2027*-0x1+0x1ceb]:--this['eIWHdp'][0x233*-0xb+-0x214c+0x397d];return this['TmeJpf'](_0x390251);},_0x2c4b3f['prototype']['TmeJpf']=function(_0x2e0af8){if(!Boolean(~_0x2e0af8))return _0x2e0af8;return this['afHqgc'](this['WRIMAG']);},_0x2c4b3f['prototype']['afHqgc']=function(_0x46799e){for(let _0x52ee32=0x212c+0xbd9+-0x2d05,_0x442cf0=this['eIWHdp']['length'];_0x52ee32<_0x442cf0;_0x52ee32++){this['eIWHdp']['push'](Math['round'](Math['random']())),_0x442cf0=this['eIWHdp']['length'];}return _0x46799e(this['eIWHdp'][-0x32*0x46+-0x21*0x5b+0x1967]);},new _0x2c4b3f(_0x4ec8)['LgGEPN'](),_0x37fdca=_0x4ec8['TkUjfx'](_0x37fdca),_0x4ec8['IQXlVz'][_0x34d66d]=_0x37fdca;}else _0x37fdca=_0x5c2908;return _0x37fdca;}export function parseDuration(_0x1f6c5d){const _0xdd5f2=_0x4ec8,_0x1308bc=_0x4ec8,_0x1200c0=_0x1f6c5d[_0xdd5f2(0x15a)](/^(\d+(?:\.\d+)?)\s*(s|sec|m|min|h|hr|d|day)s?$/i);if(!_0x1200c0)return null;const _0x2be3b2=parseFloat(_0x1200c0[-0x47f*-0x6+-0x6ff+-0x13fa*0x1]),_0x2ab2a4=_0x1200c0[0x20b7+0x206b+-0x4120][_0x1308bc(0x16e)+'e'](),_0x6c937b={'s':0x3e8,'sec':0x3e8,'m':0xea60,'min':0xea60,'h':0x36ee80,'hr':0x36ee80,'d':0x5265c00,'day':0x5265c00};return _0x2be3b2*(_0x6c937b[_0x2ab2a4]||-0x1e*0xde5+-0xbcc*-0xf+0x5a*0x545);}function formatDuration(_0x3d6066){const _0x555008=_0x4ec8,_0x59c0cb=_0x4ec8;if(_0x3d6066<0x1c345+0x2*0x6a2e+-0x1ad41)return Math[_0x555008(0x167)](_0x3d6066/(0xbf*-0x15+-0x1c85+0x3018))+'s';if(_0x3d6066<-0x20e*0x33d+-0x1995e*0x29+0x7f25e4)return Math['round'](_0x3d6066/(-0x19465+-0x3e22+0x1*0x2bce7))+_0x59c0cb(0x166);if(_0x3d6066<0x1c3*-0x245f3+0x61c0ebd+0x30b885c)return(_0x3d6066/(0x1*0x6d46f9+0x5d468+-0x3c2ce1))[_0x555008(0x173)](-0x2*-0x2f7+-0xfd0*0x1+-0x9e3*-0x1)+'h';return(_0x3d6066/(-0x70815be+0x3161db7*0x2+0x6023650))[_0x555008(0x173)](-0x1*-0x224f+-0xeb1+-0x139d*0x1)+_0x555008(0x16a);}export function createReminder(_0x3f61a9,_0x285de1,_0x3acabd,_0x33d67d,_0x2ea770){const _0x1c2431=_0x4ec8,_0x4869ea=nextId++,_0x5521b9=Date[_0x1c2431(0x15c)](),_0x2833c7=setTimeout(async()=>{const _0x5f59a0=_0x1c2431,_0x5b6938=_0x1c2431;try{await _0x2ea770[_0x5f59a0(0x15b)+'e'](_0x3f61a9,_0x5b6938(0x175)+_0x5b6938(0x165)+_0x3acabd,{'parse_mode':_0x5f59a0(0x157)});}catch(_0x260a3b){console[_0x5f59a0(0x174)]('Failed\x20to\x20'+'send\x20remin'+_0x5b6938(0x15f)+_0x4869ea+':',_0x260a3b);}reminders['delete'](_0x4869ea);},_0x33d67d),_0xe76a2={'id':_0x4869ea,'chatId':_0x3f61a9,'userId':_0x285de1,'text':_0x3acabd,'createdAt':_0x5521b9,'triggerAt':_0x5521b9+_0x33d67d,'timer':_0x2833c7};return reminders['set'](_0x4869ea,_0xe76a2),_0xe76a2;}export function listReminders(_0x1f4e36){const _0x45df11=_0x4ec8,_0x2986ff=_0x4ec8,_0x21138b=Date[_0x45df11(0x15c)]();return Array[_0x2986ff(0x15d)](reminders[_0x2986ff(0x16d)]())[_0x2986ff(0x156)](_0x2081de=>_0x2081de[_0x2986ff(0x168)]===_0x1f4e36&&_0x2081de['triggerAt']>_0x21138b)['sort']((_0x2e7684,_0x11b2d4)=>_0x2e7684['triggerAt']-_0x11b2d4[_0x45df11(0x177)])[_0x2986ff(0x172)](_0x33a400=>({'id':_0x33a400['id'],'text':_0x33a400[_0x45df11(0x16b)],'triggerAt':_0x33a400[_0x45df11(0x177)],'remaining':formatDuration(_0x33a400[_0x45df11(0x177)]-_0x21138b)}));}export function cancelReminder(_0x872702,_0x545163){const _0x59ee4a=_0x4ec8,_0x49e474=_0x4ec8,_0x258228=reminders[_0x59ee4a(0x162)](_0x872702);if(!_0x258228||_0x258228[_0x49e474(0x168)]!==_0x545163)return![];return clearTimeout(_0x258228[_0x49e474(0x158)]),reminders['delete'](_0x872702),!![];}export function reminderCount(_0x306972){const _0x2417a6=_0x4ec8,_0x15272a=_0x4ec8;return Array[_0x2417a6(0x15d)](reminders['values']())[_0x15272a(0x156)](_0x5d7627=>_0x5d7627[_0x15272a(0x168)]===_0x306972)['length'];}
|
package/dist/services/restart.js
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* Graceful Self-Restart — Ensures Grammy acknowledges Telegram updates before exit.
|
|
3
|
-
*
|
|
4
|
-
* Problem: When the AI calls `pm2 restart alvin-bot`, PM2 kills the process
|
|
5
|
-
* externally (SIGTERM → SIGKILL) before Grammy can commit the update offset.
|
|
6
|
-
* This causes a restart loop where the same "restart" message is re-processed.
|
|
7
|
-
*
|
|
8
|
-
* Solution: Instead of `pm2 restart`, we exit gracefully from inside the process.
|
|
9
|
-
* Grammy's bot.stop() commits the offset, then process.exit(0) triggers PM2 auto-restart.
|
|
10
|
-
*/
|
|
11
|
-
let _shutdownFn = null;
|
|
12
|
-
let _restartScheduled = false;
|
|
13
|
-
/**
|
|
14
|
-
* Register the graceful shutdown function (called once from index.ts).
|
|
15
|
-
*/
|
|
16
|
-
export function registerShutdownHandler(fn) {
|
|
17
|
-
_shutdownFn = fn;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Schedule a graceful restart. Waits for the given delay (ms) to allow
|
|
21
|
-
* the AI to finish its response, then shuts down cleanly.
|
|
22
|
-
* PM2's autorestart brings the bot back.
|
|
23
|
-
*
|
|
24
|
-
* Returns true if restart was scheduled, false if already pending.
|
|
25
|
-
*/
|
|
26
|
-
export function scheduleGracefulRestart(delayMs = 1500) {
|
|
27
|
-
if (_restartScheduled)
|
|
28
|
-
return false;
|
|
29
|
-
_restartScheduled = true;
|
|
30
|
-
setTimeout(async () => {
|
|
31
|
-
console.log("Graceful self-restart initiated...");
|
|
32
|
-
if (_shutdownFn) {
|
|
33
|
-
await _shutdownFn();
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
process.exit(0);
|
|
37
|
-
}
|
|
38
|
-
}, delayMs);
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Check if a shell command is a self-restart command.
|
|
43
|
-
*/
|
|
44
|
-
export function isSelfRestartCommand(command) {
|
|
45
|
-
const normalized = command.trim().toLowerCase();
|
|
46
|
-
// Match: pm2 restart alvin-bot, pm2 restart 0, pm2 reload alvin-bot
|
|
47
|
-
return /pm2\s+(restart|reload)\s+(alvin-bot|0)\b/.test(normalized);
|
|
48
|
-
}
|
|
1
|
+
(function(_0x5a758b,_0x51b1f9){const _0x276c99=_0x37e8,_0x87437c=_0x37e8,_0x4a1aa3=_0x5a758b();while(!![]){try{const _0x2bb6cc=parseInt(_0x276c99(0x176))/(0x18bd+0x61d+-0x1ed9)*(parseInt(_0x276c99(0x17d))/(0x1*0x10cf+0x1b64+0x4e9*-0x9))+parseInt(_0x87437c(0x185))/(-0x21f0+0xe5a+-0xad*-0x1d)+parseInt(_0x87437c(0x178))/(0x337*0x5+0xb*-0xbf+-0x7da)+-parseInt(_0x276c99(0x17a))/(-0x4eb+0x390*0x4+-0x950)*(-parseInt(_0x87437c(0x188))/(0x1896+-0x11e7*0x2+0x1*0xb3e))+-parseInt(_0x87437c(0x186))/(0x2*-0x6b9+0xe6*-0x27+0x3083)+-parseInt(_0x87437c(0x179))/(0x125f+-0x1400+-0x1*-0x1a9)*(parseInt(_0x276c99(0x183))/(-0x18f1+-0x142d+-0xf0d*-0x3))+parseInt(_0x87437c(0x17f))/(-0x53c+0x23ce+0x1*-0x1e88)*(-parseInt(_0x87437c(0x184))/(-0x9*0x139+0x89e+0x26e*0x1));if(_0x2bb6cc===_0x51b1f9)break;else _0x4a1aa3['push'](_0x4a1aa3['shift']());}catch(_0x39cd5d){_0x4a1aa3['push'](_0x4a1aa3['shift']());}}}(_0x4440,0x7*-0xb731+-0x46f36+0x101d94));const _0x422b3f=(function(){let _0x4b48f1=!![];return function(_0x4d8a19,_0x43ad28){const _0x1c93c0=_0x4b48f1?function(){const _0xc0f284=_0x37e8;if(_0x43ad28){const _0x4c9f02=_0x43ad28[_0xc0f284(0x180)](_0x4d8a19,arguments);return _0x43ad28=null,_0x4c9f02;}}:function(){};return _0x4b48f1=![],_0x1c93c0;};}()),_0x3ae585=_0x422b3f(this,function(){const _0x5ada5d=_0x37e8,_0x42226b=_0x37e8;return _0x3ae585[_0x5ada5d(0x173)]()[_0x5ada5d(0x177)](_0x42226b(0x187)+'+$')[_0x5ada5d(0x173)]()[_0x42226b(0x175)+'r'](_0x3ae585)[_0x5ada5d(0x177)]('(((.+)+)+)'+'+$');});_0x3ae585();let _shutdownFn=null,_restartScheduled=![];export function registerShutdownHandler(_0x1cd368){_shutdownFn=_0x1cd368;}export function scheduleGracefulRestart(_0x5117b0=-0x26c9+0xc3c+0x2069){if(_restartScheduled)return![];return _restartScheduled=!![],setTimeout(async()=>{const _0x384529=_0x37e8,_0x3a047b=_0x37e8;console[_0x384529(0x17e)]('Graceful\x20s'+_0x3a047b(0x17b)+'t\x20initiate'+_0x384529(0x17c)),_shutdownFn?await _shutdownFn():process[_0x3a047b(0x181)](-0x2c2+-0x1f3+0x4b5);},_0x5117b0),!![];}function _0x37e8(_0x1f4771,_0x4eba03){_0x1f4771=_0x1f4771-(0x1909+0x1*-0x1f97+0x1*0x801);const _0x439ef4=_0x4440();let _0x4263ed=_0x439ef4[_0x1f4771];if(_0x37e8['wQnUNT']===undefined){var _0x368f89=function(_0x1747c0){const _0x1d80fb='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x8171e2='',_0x429057='',_0x298cb6=_0x8171e2+_0x368f89;for(let _0x113f1c=-0x1f73+0x1d1+0x1da2*0x1,_0x170ff6,_0x13efe3,_0x28ec7a=-0x26c9+0xc3c+0x1a8d;_0x13efe3=_0x1747c0['charAt'](_0x28ec7a++);~_0x13efe3&&(_0x170ff6=_0x113f1c%(-0x2c2+-0x1f3+0x4b9)?_0x170ff6*(-0x4*-0x5a7+-0x3*-0x827+0xff*-0x2f)+_0x13efe3:_0x13efe3,_0x113f1c++%(0x2*0x634+0xe*-0xb3+-0x29a))?_0x8171e2+=_0x298cb6['charCodeAt'](_0x28ec7a+(-0x43*0x92+0x879+-0xb*-0x2b5))-(-0xcce+0x23c6*0x1+-0x16ee)!==-0x23c1+0x22d*-0xe+0x4237?String['fromCharCode'](-0xd3f+0x22ff+-0x14c1&_0x170ff6>>(-(-0x18b2+-0x24f*0x3+0x1fa1)*_0x113f1c&0xbe2+-0x1*-0x22a7+0x2e83*-0x1)):_0x113f1c:-0x59*0x6a+0x23fa+0xe0){_0x13efe3=_0x1d80fb['indexOf'](_0x13efe3);}for(let _0x5818a8=-0x1*0x1d27+-0x11de+0x2f05*0x1,_0x117202=_0x8171e2['length'];_0x5818a8<_0x117202;_0x5818a8++){_0x429057+='%'+('00'+_0x8171e2['charCodeAt'](_0x5818a8)['toString'](0x1ec6+0xcef+0x1*-0x2ba5))['slice'](-(0x22ef+-0x1d*-0x151+-0x491a));}return decodeURIComponent(_0x429057);};_0x37e8['ZTBGyo']=_0x368f89,_0x37e8['nlgJMW']={},_0x37e8['wQnUNT']=!![];}const _0x4e6e54=_0x439ef4[-0xee5*-0x2+0x723+-0x24ed],_0x58cd69=_0x1f4771+_0x4e6e54,_0x461c24=_0x37e8['nlgJMW'][_0x58cd69];if(!_0x461c24){const _0x294ce3=function(_0x5b6344){this['ogTWGj']=_0x5b6344,this['uRqAVY']=[-0x1407+0x1*0x677+-0x17*-0x97,0x1880+0x1*-0x7db+-0x10a5,0x174*-0x18+0x1*-0x179e+0x3a7e],this['axxpNT']=function(){return'newState';},this['ahPNnA']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['dYpJTe']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x294ce3['prototype']['dgSCPO']=function(){const _0x1f5764=new RegExp(this['ahPNnA']+this['dYpJTe']),_0x1323b6=_0x1f5764['test'](this['axxpNT']['toString']())?--this['uRqAVY'][0xb0d+-0x1a*-0x11e+-0x2818]:--this['uRqAVY'][-0x7*-0xd9+0x223*-0xb+0xd*0x15a];return this['MmKzKl'](_0x1323b6);},_0x294ce3['prototype']['MmKzKl']=function(_0x32efd0){if(!Boolean(~_0x32efd0))return _0x32efd0;return this['bYdsVk'](this['ogTWGj']);},_0x294ce3['prototype']['bYdsVk']=function(_0x353e62){for(let _0x224186=-0x1*0x407+0x4eb*-0x1+0x8f2,_0x3a351d=this['uRqAVY']['length'];_0x224186<_0x3a351d;_0x224186++){this['uRqAVY']['push'](Math['round'](Math['random']())),_0x3a351d=this['uRqAVY']['length'];}return _0x353e62(this['uRqAVY'][0x1896+-0x11e7*0x2+0x1*0xb38]);},new _0x294ce3(_0x37e8)['dgSCPO'](),_0x4263ed=_0x37e8['ZTBGyo'](_0x4263ed),_0x37e8['nlgJMW'][_0x58cd69]=_0x4263ed;}else _0x4263ed=_0x461c24;return _0x4263ed;}function _0x4440(){const _0x42daab=['mJG1nJu1nKHyy1v5uG','nZi3mLjdwfPXrW','mteWwwjyrNfV','zwXMlxjLC3rHCG','zc4UlG','mJzZCLHKAhC','Bg9N','mJaWmteWDNnTrxnw','yxbWBhK','zxHPDa','DgvZDa','odq2oxnJvevsyW','mtfbwxfrDwW','ndK3nJG4ANzNq2LT','nti0nJuZnvnpvuLHAW','kcGOlISPkYKRkq','mta3mJa4EwDVuNPS','Dg9tDhjPBMC','DhjPBq','y29UC3rYDwn0BW','nJa2otn1y2zTvu8','C2vHCMnO'];_0x4440=function(){return _0x42daab;};return _0x4440();}export function isSelfRestartCommand(_0x4e7cc7){const _0x46c536=_0x37e8,_0x573037=_0x37e8,_0x3ed4c2=_0x4e7cc7[_0x46c536(0x174)]()['toLowerCas'+'e']();return/pm2\s+(restart|reload)\s+(alvin-bot|0)\b/[_0x46c536(0x182)](_0x3ed4c2);}
|