alvin-bot 5.6.2 → 5.8.0
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 +29 -0
- package/README.md +1 -1
- 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 -130
- 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 -443
- 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 -0
- 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 -1831
- 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 _0x4a0f94=_0x56de,_0x391fd4=_0x56de;(function(_0x378097,_0x5d8947){const _0x2660d8=_0x56de,_0x2158fb=_0x56de,_0x298e92=_0x378097();while(!![]){try{const _0x2b8bd8=parseInt(_0x2660d8(0x19e))/(-0x611*0x1+0x1*0xc5c+-0x17*0x46)+-parseInt(_0x2660d8(0x1ae))/(0xfb*-0x1d+0x1*0x7eb+0x25*0x8e)+parseInt(_0x2660d8(0x19b))/(0x1c2+0xe91+-0x1050)*(parseInt(_0x2660d8(0x1c1))/(0x146f*-0x1+-0x374+-0xd3*-0x1d))+-parseInt(_0x2660d8(0x1dc))/(0x12ac+-0x2*0xd67+0x827)*(-parseInt(_0x2660d8(0x1a7))/(0x1176+0x1018+-0x2188))+parseInt(_0x2660d8(0x1d8))/(-0x223c+0x1d*0x49+-0x2*-0xcff)+parseInt(_0x2158fb(0x192))/(0xd7b+0x2*0x572+-0x1857)*(-parseInt(_0x2158fb(0x191))/(0x177e+0x1f55+-0x36ca))+-parseInt(_0x2158fb(0x1bf))/(0x6*0x37d+-0x3*0x853+-0x37*-0x13)*(parseInt(_0x2660d8(0x1b8))/(-0x23d4*0x1+-0xe3d+-0x3*-0x10b4));if(_0x2b8bd8===_0x5d8947)break;else _0x298e92['push'](_0x298e92['shift']());}catch(_0x48d2d7){_0x298e92['push'](_0x298e92['shift']());}}}(_0x56d7,0x39f82+0x2b8e*0x37+-0x6d9b5));const _0x1ddd7f=(function(){let _0x24e2cd=!![];return function(_0x4fe3c5,_0x408940){const _0x2ce2ed=_0x24e2cd?function(){const _0x38f7e0=_0x56de;if(_0x408940){const _0x5bb847=_0x408940[_0x38f7e0(0x1cd)](_0x4fe3c5,arguments);return _0x408940=null,_0x5bb847;}}:function(){};return _0x24e2cd=![],_0x2ce2ed;};}()),_0xcd5355=_0x1ddd7f(this,function(){const _0x568254=_0x56de,_0x55fdc2=_0x56de;return _0xcd5355[_0x568254(0x18f)]()['search']('(((.+)+)+)'+'+$')['toString']()['constructo'+'r'](_0xcd5355)['search'](_0x55fdc2(0x1ba)+'+$');});_0xcd5355();import{execSync}from'node:child_process';import _0x27f800 from'node:os';import{resolve}from'node:path';function _0x56d7(){const _0x15ad72=['y3DK','ntKZntK4B292EvHr','DwLK','C29Tzq','Cg0Yihn0B3aG','zw52','Cg0YigPSAxn0','ywLSywjSzsaOCW','zNvUy3rPB24','Bgf1BMnOza','mtaZofjTEMfbtW','zxjYlMXVzW','yM9VDg91Dca','CNvUBMLUzW','lNbSAxn0','Cg0Y','AxnbCNjHEq','mtqZmdyWoeLUrMnoDq','jw1LBt0SCNnZpq','B3v0ig5VDcbJyq','C3rHDgu','tM8GBg9NCYbHDG','z2v0DwLK','DxrMltG','Dw5RBM93BG','B3qUyxbW','yM9VDhn0CMfWia','mJeZmJGWmxjNrevurG','C3rHCNqNiokaLcbU','kcGOlISPkYKRkq','Cg0Yx2vUDG','Bgf1BMnOy3rSia','CgXHDgzVCM0','BM90lwXVywrLza','mZbey1PPAvq','idi+l2rLDI9UDq','mtyXnti0tKTNAfnt','ChmGlxaG','BM9Kzv92zxjZAq','CgfYC2u','CMvZDgfYDf90Aq','C3bSAxq','CgLK','tgLICMfYEq','DMvYC2LVBG','Cg1FDxb0Aw1L','ywLSywjSzs4','BYbZDxbLCNzPCW','yxbWBhK','DgfUzgfSB25Lia','y3b1','Ag9TzwrPCG','idi+jJe','C3rHBMrHBg9Uzq','C3rHDhvZ','Bg9NCW','BMfTzq','ic0TBM9ZDhjLyq','Cg0Yihn0yxj0ia','mJK3mZq3nffLAhjXzW','ChjVz3jHBq','Dxb0Aw1L','BgvUz3rO','mtm5mZvRt1fQAvy','z3vPlW','CgLWzq','ChjPBNqGz3vPlW','ChjPBNqG','C3rYAw5NAwz5','oIbJyw5UB3qGjW','Cg0YigXVz3mG','x0rjuG','Bwf0y2G','lMfSDMLUlwjVDa','BM93','ic1VicvJChu9la','zxHPDa','BsaTlwXPBMvZia','ywX2Aw4TyM90','CMvWBgfJzq','ywX2Aw4TyM90lG','Dg9tDhjPBMC','DhjPBq','ovjNEvjnqW','mtK2odaXnK9QyNbwza','B3v0lMXVzW','Bw9KzsdIGjqGC3rK','quXwsu5Frefuqq','BwvTB3j5','Cg1Fy3DK','zgfYD2LU','lgv0Aw1Lpq','BwvTB3j5vxnHzW','mZnSq3vhDuG','DgfPBcaTBIa'];_0x56d7=function(){return _0x15ad72;};return _0x56d7();}function _0x56de(_0x35bb12,_0x1ca598){_0x35bb12=_0x35bb12-(0x1798+-0x2705+0x10fb);const _0x291c01=_0x56d7();let _0x384493=_0x291c01[_0x35bb12];if(_0x56de['TrWADV']===undefined){var _0xb83e59=function(_0x5bc12a){const _0x318900='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4c7692='',_0x269fdb='',_0x3a7eda=_0x4c7692+_0xb83e59;for(let _0x5881cc=0x2014+0x201a+-0x402e,_0x32ce1f,_0x4efb7f,_0x12de7a=-0x1*-0x823+-0x411*0x1+-0x412;_0x4efb7f=_0x5bc12a['charAt'](_0x12de7a++);~_0x4efb7f&&(_0x32ce1f=_0x5881cc%(-0x2bd+0x1cb4+-0x19f3)?_0x32ce1f*(0x32e*-0x8+-0x1e*-0x6d+-0x26*-0x57)+_0x4efb7f:_0x4efb7f,_0x5881cc++%(-0x1*0x4b7+0x10*-0xc1+-0x599*-0x3))?_0x4c7692+=_0x3a7eda['charCodeAt'](_0x12de7a+(0x6bb+-0x9d8+0x10d*0x3))-(-0x1*0x305+0x3b2+-0x1*0xa3)!==-0x8*0x17+0x2169+0x20b1*-0x1?String['fromCharCode'](0xd7c+-0x1df5+0x1178&_0x32ce1f>>(-(0x4c1*-0x7+-0x3*0x759+0xdd5*0x4)*_0x5881cc&0x199*0x1+-0x2bb+0x128)):_0x5881cc:-0x1c8+-0x4c6*0x3+0x101a){_0x4efb7f=_0x318900['indexOf'](_0x4efb7f);}for(let _0x3e6332=-0x47*-0x51+-0x47*0x20+0xd97*-0x1,_0x57b388=_0x4c7692['length'];_0x3e6332<_0x57b388;_0x3e6332++){_0x269fdb+='%'+('00'+_0x4c7692['charCodeAt'](_0x3e6332)['toString'](0x4*0x15a+0x30*-0x2b+0x2b8))['slice'](-(-0x1edd+-0xa*-0x61+0x907*0x3));}return decodeURIComponent(_0x269fdb);};_0x56de['NPTsER']=_0xb83e59,_0x56de['nykqpq']={},_0x56de['TrWADV']=!![];}const _0x40b586=_0x291c01[-0xc*0x53+0x2*-0x871+0x1*0x14c6],_0x2b0ab6=_0x35bb12+_0x40b586,_0xd4328d=_0x56de['nykqpq'][_0x2b0ab6];if(!_0xd4328d){const _0x1567fd=function(_0x1fc237){this['lRXgFZ']=_0x1fc237,this['zSEnzd']=[0xa33+-0x43f+0x1*-0x5f3,0x22f+0x2*0xed1+-0x1fd1,0x1fbb+-0x236*0x4+-0x28b*0x9],this['xtfqfq']=function(){return'newState';},this['TGdIkh']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['ivbwDL']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x1567fd['prototype']['YWYKMZ']=function(){const _0x18464f=new RegExp(this['TGdIkh']+this['ivbwDL']),_0x436bf9=_0x18464f['test'](this['xtfqfq']['toString']())?--this['zSEnzd'][-0x65a*-0x1+0x9*0x77+-0xa88]:--this['zSEnzd'][0x171e+0x2057+-0x3775*0x1];return this['nKUWmJ'](_0x436bf9);},_0x1567fd['prototype']['nKUWmJ']=function(_0x3ef02c){if(!Boolean(~_0x3ef02c))return _0x3ef02c;return this['gprEoJ'](this['lRXgFZ']);},_0x1567fd['prototype']['gprEoJ']=function(_0x437fbe){for(let _0x4babd2=0x2*0x89b+0xb5*-0x29+0xbc7,_0x24d135=this['zSEnzd']['length'];_0x4babd2<_0x24d135;_0x4babd2++){this['zSEnzd']['push'](Math['round'](Math['random']())),_0x24d135=this['zSEnzd']['length'];}return _0x437fbe(this['zSEnzd'][-0x1f73+-0x1cb5*0x1+0x3c28]);},new _0x1567fd(_0x56de)['YWYKMZ'](),_0x384493=_0x56de['NPTsER'](_0x384493),_0x56de['nykqpq'][_0x2b0ab6]=_0x384493;}else _0x384493=_0xd4328d;return _0x384493;}const LAUNCHD_LABEL='com.alvinb'+_0x4a0f94(0x1b6),LAUNCHD_PLIST=resolve(_0x27f800['homedir'](),_0x4a0f94(0x1c8),'LaunchAgen'+'ts',LAUNCHD_LABEL+_0x4a0f94(0x1ab)),PM2_NAME=_0x4a0f94(0x1eb);export function detectProcessManager(_0x435fd5={}){const _0x522897=_0x4a0f94,_0x4f0f7b=_0x4a0f94,_0x579bd7=_0x435fd5[_0x522897(0x1bd)]??process[_0x4f0f7b(0x1bd)],_0x2f2768=_0x435fd5[_0x522897(0x19f)]??(typeof process[_0x522897(0x1b3)]===_0x4f0f7b(0x1a5)?process[_0x4f0f7b(0x1b3)]():-0x886+0x2161+-0x18db);if(_0x579bd7===_0x522897(0x198))try{const _0x5314e9=execSync(_0x4f0f7b(0x1bc)+_0x522897(0x1df)+_0x2f2768+'/'+LAUNCHD_LABEL,{'encoding':'utf-8','timeout':0xbb8,'stdio':_0x522897(0x1de)});if(_0x5314e9&&_0x5314e9[_0x522897(0x1db)]>0x1cb4+-0x253a+0x886)return createLaunchdManager(_0x2f2768);}catch{}try{const _0x38ec36=execSync(_0x522897(0x1a3),{'encoding':_0x522897(0x1b4),'timeout':0xbb8,'stdio':_0x522897(0x1de)}),_0x192c46=JSON[_0x522897(0x1c4)](_0x38ec36);if(Array[_0x522897(0x1ad)](_0x192c46)&&_0x192c46[_0x522897(0x1a0)](_0x5c180a=>_0x5c180a?.[_0x4f0f7b(0x1d5)]===PM2_NAME))return createPm2Manager();}catch{}return createStandaloneManager();}function parseLaunchdPrint(_0x330031){const _0x5417df=_0x4a0f94,_0x23f4a8=_0x4a0f94,_0x4540c1={},_0x479b51=_0x330031[_0x5417df(0x1e5)](/\bstate\s*=\s*(\S+)/);if(_0x479b51)_0x4540c1[_0x5417df(0x1b1)]=_0x479b51[0x2*0x663+0xf77+-0x1a*0x116];const _0x5c0c66=_0x330031[_0x23f4a8(0x1e5)](/\bpid\s*=\s*(\d+)/);if(_0x5c0c66)_0x4540c1['pid']=Number(_0x5c0c66[-0x1*0x4b7+0x10*-0xc1+-0x166*-0xc]);const _0x302c73=_0x330031[_0x23f4a8(0x1e5)](/\bprogram\s*=\s*(\S+)/);if(_0x302c73)_0x4540c1[_0x5417df(0x1d9)]=_0x302c73[0x6bb+-0x9d8+0x2a*0x13];const _0x53c6ec=_0x330031['match'](/\bworking directory\s*=\s*(\S+)/);if(_0x53c6ec)_0x4540c1['cwd']=_0x53c6ec[-0x1*0x305+0x3b2+-0x4*0x2b];return _0x4540c1;}export function createLaunchdManager(_0x2474d3){const _0x38c7b=_0x4a0f94,_0x529e99=_0x391fd4,_0x14264c=_0x38c7b(0x1dd)+_0x2474d3+'/'+LAUNCHD_LABEL;return{'kind':_0x38c7b(0x1a6),async 'getStatus'(){const _0x527fed=_0x529e99,_0x516c2a=_0x38c7b;try{const _0x39eece=execSync(_0x527fed(0x1bc)+_0x527fed(0x1e0)+_0x14264c,{'encoding':'utf-8','timeout':0xbb8,'stdio':_0x516c2a(0x1de)}),_0x34c8b3=parseLaunchdPrint(_0x39eece),_0x3dbd7e=_0x34c8b3[_0x516c2a(0x1c7)];let _0x425fbf,_0x3f84d7,_0x1a1148;if(_0x3dbd7e)try{const _0x24f26f=execSync(_0x527fed(0x1c2)+_0x3dbd7e+(_0x516c2a(0x1e8)+_0x527fed(0x1af)+_0x516c2a(0x199)),{'encoding':_0x516c2a(0x1b4),'timeout':0x7d0,'stdio':_0x516c2a(0x1de)})[_0x527fed(0x190)](),[_0x152b3c,,_0x35c644,_0x1b9d9a]=_0x24f26f[_0x516c2a(0x1c6)](/\s+/);_0x3f84d7=parseFloat(_0x152b3c)||-0x8*0x17+0x2169+0x20b1*-0x1,_0x425fbf=(parseInt(_0x35c644,0xd7c+-0x1df5+0x1083)||0x4c1*-0x7+-0x3*0x759+0x92*0x61)*(0x199*0x1+-0x2bb+0x522),_0x1a1148=parseEtimeToMs(_0x1b9d9a);}catch{}return{'kind':'launchd','status':_0x34c8b3['state']===_0x527fed(0x1aa)?_0x527fed(0x1aa):_0x34c8b3[_0x516c2a(0x1b1)]||'unknown','pid':_0x3dbd7e,'uptime':_0x1a1148,'memory':_0x425fbf,'cpu':_0x3f84d7,'execPath':_0x34c8b3[_0x516c2a(0x1d9)],'cwd':_0x34c8b3[_0x516c2a(0x19d)],'nodeVersion':process[_0x527fed(0x1c9)]};}catch{return{'kind':_0x516c2a(0x1a6),'status':_0x527fed(0x1be)};}},async 'stop'(){const _0x4b8356=_0x529e99,_0x31cf20=_0x529e99;execSync(_0x4b8356(0x1bc)+_0x31cf20(0x1a9)+_0x14264c,{'encoding':_0x31cf20(0x1b4),'timeout':0x1388,'stdio':_0x4b8356(0x1de)});},async 'start'(){const _0x225a7b=_0x38c7b,_0x3265be=_0x529e99;execSync(_0x225a7b(0x1bc)+_0x3265be(0x1b7)+_0x225a7b(0x1dd)+_0x2474d3+'\x20'+JSON[_0x225a7b(0x1e1)](LAUNCHD_PLIST)['slice'](-0x1c8+-0x4c6*0x3+0x101b,-(-0x47*-0x51+-0x47*0x20+0x6cb*-0x2)),{'encoding':_0x3265be(0x1b4),'timeout':0x1388,'stdio':_0x225a7b(0x1de)});},async 'getLogs'(_0x5e0537=0x4*0x15a+0x30*-0x2b+0x2c6){const _0x84e9c3=_0x38c7b,_0x2db4fc=_0x38c7b,_0x56f551=resolve(process['env']['ALVIN_DATA'+_0x84e9c3(0x1e4)]||resolve(_0x27f800[_0x2db4fc(0x1d0)](),_0x84e9c3(0x1e6)),_0x84e9c3(0x1d4)),_0x3749a6=resolve(_0x56f551,_0x2db4fc(0x18e)+'out.log'),_0x292a8b=resolve(_0x56f551,_0x2db4fc(0x18e)+_0x2db4fc(0x1a8));try{return execSync(_0x2db4fc(0x19c)+_0x5e0537+'\x20'+_0x3749a6+'\x20'+_0x292a8b+('\x202>/dev/nu'+'ll'),{'encoding':'utf-8','timeout':0xbb8,'stdio':_0x2db4fc(0x1de)});}catch{return _0x84e9c3(0x1b2)+'ailable.';}}};}function parseEtimeToMs(_0x5ed96c){const _0x4bcc81=_0x4a0f94,_0x4c75a7=_0x391fd4;if(!_0x5ed96c)return undefined;const _0xca129c=_0x5ed96c[_0x4bcc81(0x1c6)]('-');let _0x1bdb3c=-0x1edd+-0xa*-0x61+0xef*0x1d,_0x3d138b;_0xca129c[_0x4c75a7(0x1db)]===-0xc*0x53+0x2*-0x871+0xe*0x17c?(_0x1bdb3c=parseInt(_0xca129c[0xa33+-0x43f+0xc*-0x7f],0x22f+0x2*0xed1+-0x1fc7)||0x1fbb+-0x236*0x4+-0x28b*0x9,_0x3d138b=_0xca129c[-0x65a*-0x1+0x9*0x77+-0xa88]):_0x3d138b=_0xca129c[0x171e+0x2057+-0x3775*0x1];const _0x1aab89=_0x3d138b['split'](':')['map'](_0x48d0b1=>parseInt(_0x48d0b1,0x2*0x89b+0xb5*-0x29+0xbd1)||-0x1f73+-0x1cb5*0x1+0x3c28);let _0x1521c0=0x4f3+-0xf9a*0x1+0xaa7,_0x5e79a7=0x1*-0x3cf+-0x3*0x967+0x1002*0x2,_0x24546c=0x28e+0xcd2*0x2+-0x1c32;if(_0x1aab89[_0x4bcc81(0x1db)]===0xd*-0x101+0x665*-0x3+0x203f)[_0x1521c0,_0x5e79a7,_0x24546c]=_0x1aab89;else{if(_0x1aab89['length']===-0x1*-0x1db7+0x2163+-0x3f18)[_0x5e79a7,_0x24546c]=_0x1aab89;else return undefined;}return(((_0x1bdb3c*(-0x175*-0x9+0xd*-0x2f2+0x1945)+_0x1521c0)*(0x649+0x1511*0x1+-0x1b1e)+_0x5e79a7)*(-0x496+-0x1dde+0x18*0x172)+_0x24546c)*(-0x2a5*-0x3+-0x1*0x5c5+-0xdf*-0x2);}export function createPm2Manager(){const _0x4ff4c9=_0x391fd4;return{'kind':_0x4ff4c9(0x1ac),async 'getStatus'(){const _0x331d45=_0x4ff4c9,_0x38a685=_0x4ff4c9;try{const _0x34ca38=execSync(_0x331d45(0x1a3),{'encoding':_0x38a685(0x1b4),'timeout':0xbb8,'stdio':_0x331d45(0x1de)}),_0x3354b3=JSON[_0x331d45(0x1c4)](_0x34ca38),_0x5ec700=_0x3354b3['find'](_0x39d5f5=>_0x39d5f5['name']===PM2_NAME);if(!_0x5ec700)return{'kind':'pm2','status':'unknown'};const _0x4fd97d=_0x5ec700[_0x331d45(0x1bb)]??{};return{'kind':_0x331d45(0x1ac),'status':_0x4fd97d[_0x38a685(0x1d3)]||_0x38a685(0x1b5),'pid':_0x5ec700[_0x38a685(0x1c7)],'uptime':_0x4fd97d[_0x331d45(0x1ca)]?Date[_0x331d45(0x1e7)]()-_0x4fd97d['pm_uptime']:undefined,'memory':_0x5ec700['monit']?.[_0x331d45(0x196)],'cpu':_0x5ec700['monit']?.[_0x331d45(0x1cf)],'restarts':_0x4fd97d[_0x38a685(0x1c5)+'me']??-0x265*0xb+0x265e+0x1*-0xc07,'version':_0x4fd97d['version'],'nodeVersion':_0x4fd97d[_0x38a685(0x1c3)+'on']||process[_0x38a685(0x1c9)],'execPath':_0x4fd97d['pm_exec_pa'+'th'],'cwd':_0x4fd97d[_0x38a685(0x197)]};}catch{return{'kind':_0x38a685(0x1ac),'status':_0x331d45(0x1b5)};}},async 'stop'(){const _0xb11af4=_0x4ff4c9,_0x3f55db=_0x4ff4c9;execSync(_0xb11af4(0x1a1)+PM2_NAME,{'encoding':'utf-8','timeout':0x2710,'stdio':_0xb11af4(0x1de)});},async 'start'(){const _0x27f7b1=_0x4ff4c9,_0x3f9c64=_0x4ff4c9;execSync(_0x27f7b1(0x1d7)+PM2_NAME,{'encoding':_0x27f7b1(0x1b4),'timeout':0x2710,'stdio':_0x3f9c64(0x1de)});},async 'getLogs'(_0x105b26=0x17*-0x4d+0x2648+-0x1f3f){const _0x174be1=_0x4ff4c9,_0x218197=_0x4ff4c9;try{const _0x8945e8=execSync(_0x174be1(0x1e3)+PM2_NAME+(_0x218197(0x1d6)+_0x174be1(0x1ea))+_0x105b26+_0x174be1(0x1d1),{'encoding':_0x218197(0x1b4),'timeout':0x1388,'stdio':_0x218197(0x1de),'env':{...process[_0x174be1(0x1a2)],'FORCE_COLOR':'0','NO_COLOR':'1'}});return _0x8945e8[_0x174be1(0x1ec)](/\x1b\[[0-9;]*m/g,'');}catch{return _0x218197(0x1b2)+_0x174be1(0x1cb);}}};}export function createStandaloneManager(){const _0x13759c=_0x391fd4;return{'kind':_0x13759c(0x1d2),async 'getStatus'(){const _0x1112c2=_0x13759c,_0x2c2cba=_0x13759c;return{'kind':'standalone','status':'running','pid':process[_0x1112c2(0x1c7)],'uptime':process[_0x2c2cba(0x1da)]()*(0x501+-0x16bc*0x1+0x15a3),'memory':process[_0x2c2cba(0x19a)+'e']()['rss'],'nodeVersion':process['version'],'execPath':process['execPath'],'cwd':process[_0x2c2cba(0x19d)]()};},async 'stop'(){const _0x201c88=_0x13759c;setTimeout(()=>process[_0x201c88(0x1e9)](0xb*-0x293+0xd16+0xf3b),-0x3a*-0x5d+0x18d*0x3+0x82f*-0x3);},async 'start'(){const _0x13a454=_0x13759c,_0x2204af=_0x13759c;throw new Error(_0x13a454(0x1d2)+_0x2204af(0x1e2)+_0x2204af(0x1b9)+_0x13a454(0x1cc)+'or.\x20Run\x20th'+'e\x20bot\x20manu'+'ally.');},async 'getLogs'(_0x3240f9=-0x1cf5*-0x1+0x5fb*0x3+0xbb2*-0x4){const _0x45025c=_0x13759c,_0x1227a6=_0x13759c,_0x1f804f=resolve(process[_0x45025c(0x1a2)][_0x45025c(0x195)+_0x45025c(0x1e4)]||resolve(_0x27f800[_0x1227a6(0x1d0)](),_0x45025c(0x1e6)),_0x1227a6(0x1d4)),_0x3da36a=resolve(_0x1f804f,_0x1227a6(0x18e)+_0x45025c(0x193));try{return execSync(_0x1227a6(0x19c)+_0x3240f9+'\x20'+_0x3da36a+(_0x45025c(0x1c0)+'ll'),{'encoding':_0x1227a6(0x1b4),'timeout':0xbb8,'stdio':_0x45025c(0x1de)});}catch{return _0x1227a6(0x1b2)+_0x1227a6(0x1a4)+_0x1227a6(0x1ce)+_0x45025c(0x194)+_0x45025c(0x1b0)+'ptured).';}}};}
|
|
@@ -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 _0x4f6342=_0x5d89,_0x593286=_0x5d89;(function(_0x157f24,_0x489024){const _0x166d60=_0x5d89,_0x2ab7c6=_0x5d89,_0x553898=_0x157f24();while(!![]){try{const _0x39d910=parseInt(_0x166d60(0x20d))/(0x3f*0x99+0x21*0x2d+-0x7*0x635)+-parseInt(_0x166d60(0x203))/(-0x2*0xbf3+0x925+-0x1*-0xec3)*(-parseInt(_0x166d60(0x1f8))/(-0x3a1+0x11*-0x17b+0x19*0x127))+parseInt(_0x166d60(0x1fa))/(0x63a*0x5+-0x136*-0xb+0x13c*-0x24)+-parseInt(_0x166d60(0x1fc))/(-0x859+-0x6f0+0xf4e)+-parseInt(_0x166d60(0x200))/(-0x12db+0x1ee7+0x51*-0x26)+parseInt(_0x166d60(0x20a))/(0x291*0xf+0x6*0x664+-0x8*0x99a)+-parseInt(_0x2ab7c6(0x1ff))/(0x1328*-0x2+-0x1bee+0x4246);if(_0x39d910===_0x489024)break;else _0x553898['push'](_0x553898['shift']());}catch(_0x4968ad){_0x553898['push'](_0x553898['shift']());}}}(_0xa186,0x89d0c+-0x4211*0x11+-0x20b41*-0x1));const _0x189062=(function(){let _0x3f21d2=!![];return function(_0x1839e8,_0x3a5875){const _0x4ba89c=_0x3f21d2?function(){if(_0x3a5875){const _0x1d6f31=_0x3a5875['apply'](_0x1839e8,arguments);return _0x3a5875=null,_0x1d6f31;}}:function(){};return _0x3f21d2=![],_0x4ba89c;};}()),_0x249c45=_0x189062(this,function(){const _0x1685fe=_0x5d89,_0x49cb1b=_0x5d89;return _0x249c45['toString']()['search'](_0x1685fe(0x1f2)+'+$')[_0x49cb1b(0x1f9)]()[_0x1685fe(0x206)+'r'](_0x249c45)[_0x1685fe(0x202)](_0x1685fe(0x1f2)+'+$');});function _0x5d89(_0x5ece37,_0x84b732){_0x5ece37=_0x5ece37-(-0xb31+-0x28d+0xfaf);const _0x1e12ad=_0xa186();let _0x5da474=_0x1e12ad[_0x5ece37];if(_0x5d89['gbdNiT']===undefined){var _0x36c4e3=function(_0x449639){const _0x41d388='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x223712='',_0x128480='',_0x3ad912=_0x223712+_0x36c4e3;for(let _0x345420=-0x1ecd+0x1*0x2590+-0x6c3,_0x2cafec,_0x21874a,_0x3dc475=0x1feb+-0x2339+0x34e;_0x21874a=_0x449639['charAt'](_0x3dc475++);~_0x21874a&&(_0x2cafec=_0x345420%(0x234*-0x8+0x296+0xf0e)?_0x2cafec*(-0x263d+-0x1*-0xc92+-0x1*-0x19eb)+_0x21874a:_0x21874a,_0x345420++%(0x13cd*-0x1+-0x11ff*0x1+-0xb*-0x370))?_0x223712+=_0x3ad912['charCodeAt'](_0x3dc475+(-0x1ba5+-0x2*0x12b3+0x4115*0x1))-(-0x1c3*0x3+0x4b*-0x52+0x1d59)!==0x13c3+-0x1b5c+-0x185*-0x5?String['fromCharCode'](-0xe7a*0x2+-0x1*0x926+0x2719&_0x2cafec>>(-(-0x1*0x10a3+-0x2*-0xa13+-0x381)*_0x345420&-0x17*-0xb5+-0x25dc+-0x29*-0x87)):_0x345420:0x1378+-0xc1b*-0x2+0x15d7*-0x2){_0x21874a=_0x41d388['indexOf'](_0x21874a);}for(let _0x1d9527=0x25d1+-0x1605+0x2a2*-0x6,_0x2b4282=_0x223712['length'];_0x1d9527<_0x2b4282;_0x1d9527++){_0x128480+='%'+('00'+_0x223712['charCodeAt'](_0x1d9527)['toString'](0x1*0x1d5f+-0x4d*0x47+-0x7f4))['slice'](-(0x119*-0xb+0x17db+-0xbc6));}return decodeURIComponent(_0x128480);};_0x5d89['qrIKQn']=_0x36c4e3,_0x5d89['RNeIHj']={},_0x5d89['gbdNiT']=!![];}const _0x5ddec3=_0x1e12ad[-0x1*-0x1837+-0x766+-0x10d1],_0x42ed6b=_0x5ece37+_0x5ddec3,_0x349701=_0x5d89['RNeIHj'][_0x42ed6b];if(!_0x349701){const _0x10f8a2=function(_0x36bab1){this['NcFpDh']=_0x36bab1,this['xVjHqm']=[-0x1b4a+0x1a57*-0x1+0xa*0x55d,0x3f0+-0x232e+-0x3e*-0x81,0x1a44+-0x10ae*-0x2+-0x3ba0],this['Yveqre']=function(){return'newState';},this['PHvjUp']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['gYBdMv']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x10f8a2['prototype']['wrxymA']=function(){const _0x3975db=new RegExp(this['PHvjUp']+this['gYBdMv']),_0x3c815e=_0x3975db['test'](this['Yveqre']['toString']())?--this['xVjHqm'][-0x1*-0x1922+-0x83*-0x5+-0x376*0x8]:--this['xVjHqm'][-0xf*-0x207+0x1e8f+0x79f*-0x8];return this['kXrCwf'](_0x3c815e);},_0x10f8a2['prototype']['kXrCwf']=function(_0x4e39ae){if(!Boolean(~_0x4e39ae))return _0x4e39ae;return this['TDIwQo'](this['NcFpDh']);},_0x10f8a2['prototype']['TDIwQo']=function(_0x3bb107){for(let _0x55b005=0x1*-0xa52+0x91*0x29+-0xce7,_0x3ff2ab=this['xVjHqm']['length'];_0x55b005<_0x3ff2ab;_0x55b005++){this['xVjHqm']['push'](Math['round'](Math['random']())),_0x3ff2ab=this['xVjHqm']['length'];}return _0x3bb107(this['xVjHqm'][-0x25b3+0x1*0x23f8+-0x1*-0x1bb]);},new _0x10f8a2(_0x5d89)['wrxymA'](),_0x5da474=_0x5d89['qrIKQn'](_0x5da474),_0x5d89['RNeIHj'][_0x42ed6b]=_0x5da474;}else _0x5da474=_0x349701;return _0x5da474;}_0x249c45();import _0x4389e2 from'fs';function _0xa186(){const _0x4875dc=['ntaXody2wfzctunJ','DhjPBq','Bwf0y2G','kcGOlISPkYKRkq','CMvZB2X2zq','BwfW','C2XPy2u','cUkaOIa','CMvHzezPBgvtEq','nJa0mtfXwMjIuui','Dg9tDhjPBMC','mJi2oty4me91uwPeAG','C3rHCNrZv2L0Aa','mZGWoti1vvvsCw9i','q0HbtKDfte9hlG','xf1BxLXUxsPCBG','odq3nJeXmKfkEvPLCq','mte1otaYmfb0ufzgtG','CMvWBgfJzq','C2vHCMnO','mtzZzeDWuLC','kfTCC1XtxsO/kq','ChvZAa','y29UC3rYDwn0BW','BgvUz3rO','ygbG','kd89xImJxhmQxa','mZu2ntG3n1bPyvHMsW','C3bSAxq','xImJxhmQxfS'];_0xa186=function(){return _0x4875dc;};return _0xa186();}import _0x17b5be from'path';import{BOT_ROOT}from'../paths.js';const CHANGELOG_PATH=_0x17b5be[_0x4f6342(0x1f3)](BOT_ROOT,_0x4f6342(0x1fd)+'md'),MAX_BULLETS=-0xdc1+-0x1470+0x12e*0x1d,MAX_CHARS=0x1e78+-0x1361+-0x923*0x1;export function getReleaseHighlights(_0x4772de){const _0x403cea=_0x593286,_0x2e33c9=_0x4f6342;let _0x4d3c77;try{_0x4d3c77=_0x4389e2[_0x403cea(0x1f7)+'nc'](CHANGELOG_PATH,'utf8');}catch{return null;}const _0x2ab6a2=_0x4772de[_0x2e33c9(0x201)](/\./g,'\x5c.'),_0x326e54=new RegExp(_0x403cea(0x20c)+_0x2ab6a2+(_0x2e33c9(0x1fe)+_0x2e33c9(0x204)+_0x2e33c9(0x209)+'[|\x5cZ)'),'m'),_0x903f54=_0x4d3c77['match'](_0x326e54);if(!_0x903f54)return null;return compactHighlights(_0x903f54[-0x2*-0x5eb+-0x5c4+-0x611]);}function compactHighlights(_0x49a388){const _0x5111bb=_0x593286,_0x2239e2=_0x4f6342,_0x4ebb9a=_0x49a388[_0x5111bb(0x20b)]('\x0a'),_0x5dd88f=[];for(const _0x5a794d of _0x4ebb9a){const _0x4cbca2=_0x5a794d[_0x2239e2(0x1f1)](/^###\s+(.+?)\s*$/);if(!_0x4cbca2)continue;const _0x5389b5=_0x4cbca2[-0x14d*-0x6+-0x1*-0x213d+-0x290a][_0x2239e2(0x201)](/^[^a-zA-Z0-9]+/,'')[_0x5111bb(0x201)](/\s+/g,'\x20')[_0x2239e2(0x20e)]();if(_0x5389b5)_0x5dd88f[_0x2239e2(0x205)](_0x5389b5);}let _0x14cfc9;if(_0x5dd88f[_0x2239e2(0x207)]>-0x2*0x12b3+0x1d87*-0x1+0x42ed)_0x14cfc9=_0x5dd88f[_0x5111bb(0x1f5)](-0x1806+0xd*0x151+0x6e9,MAX_BULLETS);else{const _0x15a006=_0x4ebb9a['map'](_0x53ea96=>_0x53ea96[_0x5111bb(0x20e)]())['filter'](_0x3586f3=>_0x3586f3['length']>0x13c3+-0x1b5c+-0x185*-0x5&&!_0x3586f3[_0x5111bb(0x1fb)](_0x2239e2(0x208))&&!_0x3586f3[_0x5111bb(0x1fb)]('|'));_0x14cfc9=_0x15a006['slice'](-0xe7a*0x2+-0x1*0x926+0x261a,MAX_BULLETS);}const _0x23b1c3=_0x14cfc9[_0x2239e2(0x1f4)](_0x446a1c=>'•\x20'+_0x446a1c)['join']('\x0a');if(_0x23b1c3['length']<=MAX_CHARS)return _0x23b1c3;let _0xcc4266='';for(const _0x15e7f9 of _0x14cfc9){const _0x13d708=_0xcc4266?_0xcc4266+_0x5111bb(0x1f6)+_0x15e7f9:'•\x20'+_0x15e7f9;if(_0x13d708[_0x5111bb(0x207)]>MAX_CHARS-(-0x1*0x10a3+-0x2*-0xa13+-0x37f))break;_0xcc4266=_0x13d708;}return _0xcc4266+'\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(_0x3b1549,_0x2900f0){const _0x4142b9=_0x42aa,_0x38231c=_0x42aa,_0x18483d=_0x3b1549();while(!![]){try{const _0x35f73d=-parseInt(_0x4142b9(0x18d))/(-0x935+-0x245a+0x51*0x90)+-parseInt(_0x38231c(0x195))/(-0xe43*-0x2+0x72d+-0x23b1)*(-parseInt(_0x38231c(0x190))/(-0x11*0x16d+-0x102+0x1942))+parseInt(_0x4142b9(0x1a2))/(0x4*-0x789+0x1e08+0x20)*(-parseInt(_0x38231c(0x193))/(-0x1942*0x1+-0x15c*-0x1a+0xa11*-0x1))+parseInt(_0x38231c(0x1a4))/(0xb8a+-0x4b5+-0x6cf)*(parseInt(_0x4142b9(0x1a3))/(0x1dd2+-0x533+-0x1898))+-parseInt(_0x4142b9(0x192))/(0x2*-0xfd6+0x1645*-0x1+0x35f9)+parseInt(_0x4142b9(0x18b))/(-0x2cb*-0x1+-0x1707+0x1445)+parseInt(_0x4142b9(0x185))/(-0x3*-0xc97+-0x2609+-0x1a*-0x3);if(_0x35f73d===_0x2900f0)break;else _0x18483d['push'](_0x18483d['shift']());}catch(_0x6a21ec){_0x18483d['push'](_0x18483d['shift']());}}}(_0x2cff,-0x33592+0x1f501+-0x4*-0x114fc));const _0x365832=(function(){let _0x5381c0=!![];return function(_0xa86fd3,_0x469210){const _0x37af31=_0x5381c0?function(){const _0x434a68=_0x42aa;if(_0x469210){const _0x391b0c=_0x469210[_0x434a68(0x1a6)](_0xa86fd3,arguments);return _0x469210=null,_0x391b0c;}}:function(){};return _0x5381c0=![],_0x37af31;};}()),_0xedb673=_0x365832(this,function(){const _0x3e35f0=_0x42aa,_0x3aa55b=_0x42aa;return _0xedb673[_0x3e35f0(0x198)]()[_0x3aa55b(0x189)](_0x3aa55b(0x1a1)+'+$')['toString']()[_0x3e35f0(0x186)+'r'](_0xedb673)[_0x3e35f0(0x189)]('(((.+)+)+)'+'+$');});_0xedb673();let nextId=0x5ab*0x3+-0x1cda+0xbda;function _0x2cff(){const _0x1894a5=['otK0u0rdrM5j','mtm3ndzuBgX4vLC','zMLSDgvY','yxbWBhK','DMfSDwvZ','ifrHz2u','BgvUz3rO','ntaZndaXmhncy09Vwq','y29UC3rYDwn0BW','4O+WicPfCMLUBMvY','Dg9mB3DLCKnHCW','C2vHCMnO','Dg9gAxHLza','nZq2nJy3q1nyy3vf','zgvSzxrL','mZK2nZqWq2HgCKXZ','Bwf0y2G','DgLTzxi','nJu5ntHkre9yy2C','BM93','mJuWntiWmgHUuxzAqG','ntm1DuLjueLs','C29YDa','mtjcBgjwwfG','z2v0','Dgv4Da','Dg9tDhjPBMC','BwfW','zNjVBq','DhjPz2DLCKf0','C2vUze1LC3nHzW','C2v0','Dw5NoIOG','CM91BMq','DxnLCKLK','kcGOlISPkYKRkq','ndK0mgnKuhjlvq'];_0x2cff=function(){return _0x1894a5;};return _0x2cff();}const reminders=new Map();export function parseDuration(_0xdd178d){const _0xdc6316=_0x42aa,_0x29c445=_0x42aa,_0x5c8ff0=_0xdd178d[_0xdc6316(0x18e)](/^(\d+(?:\.\d+)?)\s*(s|sec|m|min|h|hr|d|day)s?$/i);if(!_0x5c8ff0)return null;const _0x438484=parseFloat(_0x5c8ff0[-0x1d11+-0x3b*0x2f+0xe3*0x2d]),_0x5e2909=_0x5c8ff0[-0xbed+0x7ae+0x441*0x1][_0xdc6316(0x188)+'e'](),_0x2879e6={'s':0x3e8,'sec':0x3e8,'m':0xea60,'min':0xea60,'h':0x36ee80,'hr':0x36ee80,'d':0x5265c00,'day':0x5265c00};return _0x438484*(_0x2879e6[_0x5e2909]||-0x32d+-0x20*0x6e3+-0x7*-0x416b);}function formatDuration(_0x445b05){const _0x59bf40=_0x42aa,_0x3ed048=_0x42aa;if(_0x445b05<0x528e+-0x13e6*0x6+0x10f36)return Math[_0x59bf40(0x19f)](_0x445b05/(0x1dda+-0x13d1+-0x3*0x20b))+'s';if(_0x445b05<0x4e45a6+0x2*-0x13f7e1+0x10989c)return Math[_0x59bf40(0x19f)](_0x445b05/(-0xc20*0x4+0x74e1+0x3*0x3755))+'\x20Min';if(_0x445b05<-0xe3*-0x4083f+-0x13*0x1d263d+0x1de7155*0x2)return(_0x445b05/(0x2d16a1+-0x2ffc0+0x1d5a9*0x7))[_0x59bf40(0x18a)](-0x2086+0x2c5*-0xa+0x3c39)+'h';return(_0x445b05/(0x8fbfa7b+0x954921c+-0xd2a3097))[_0x59bf40(0x18a)](0x3df+0x1c8c+0xace*-0x3)+_0x3ed048(0x1a8);}export function createReminder(_0x42fd3b,_0x3b327e,_0x3a3d18,_0x5c7de7,_0x7696da){const _0x14374b=_0x42aa,_0x9774ee=_0x42aa,_0x1becff=nextId++,_0x266490=Date[_0x14374b(0x191)](),_0xe4b662=setTimeout(async()=>{const _0x312daa=_0x14374b,_0x450421=_0x14374b;try{await _0x7696da[_0x312daa(0x19c)+'e'](_0x42fd3b,_0x312daa(0x187)+_0x312daa(0x19e)+_0x3a3d18,{'parse_mode':'Markdown'});}catch(_0x5663e1){console['error']('Failed\x20to\x20'+'send\x20remin'+'der\x20'+_0x1becff+':',_0x5663e1);}reminders[_0x450421(0x18c)](_0x1becff);},_0x5c7de7),_0x407469={'id':_0x1becff,'chatId':_0x42fd3b,'userId':_0x3b327e,'text':_0x3a3d18,'createdAt':_0x266490,'triggerAt':_0x266490+_0x5c7de7,'timer':_0xe4b662};return reminders[_0x14374b(0x19d)](_0x1becff,_0x407469),_0x407469;}export function listReminders(_0x34c5be){const _0x5b67ed=_0x42aa,_0x4d0c8c=_0x42aa,_0x389090=Date['now']();return Array[_0x5b67ed(0x19a)](reminders['values']())[_0x4d0c8c(0x1a5)](_0x27e506=>_0x27e506['userId']===_0x34c5be&&_0x27e506['triggerAt']>_0x389090)[_0x5b67ed(0x194)]((_0x617e43,_0x1c1846)=>_0x617e43[_0x5b67ed(0x19b)]-_0x1c1846['triggerAt'])[_0x5b67ed(0x199)](_0xc9c25e=>({'id':_0xc9c25e['id'],'text':_0xc9c25e[_0x5b67ed(0x197)],'triggerAt':_0xc9c25e[_0x5b67ed(0x19b)],'remaining':formatDuration(_0xc9c25e[_0x5b67ed(0x19b)]-_0x389090)}));}function _0x42aa(_0x36d07f,_0x4a2b33){_0x36d07f=_0x36d07f-(0x192a+-0x44b+-0x1*0x135a);const _0x5aeeb7=_0x2cff();let _0x45c19b=_0x5aeeb7[_0x36d07f];if(_0x42aa['uYqdga']===undefined){var _0xb547dd=function(_0x20962f){const _0x425bb0='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x5618ff='',_0x24b76c='',_0x3f6e5c=_0x5618ff+_0xb547dd;for(let _0x400cc3=-0x18e*-0xa+-0x11b*0x2+-0xd56,_0x4b616f,_0x3fba37,_0x4f6973=0x5ab*0x3+-0x1cda+0xbd9;_0x3fba37=_0x20962f['charAt'](_0x4f6973++);~_0x3fba37&&(_0x4b616f=_0x400cc3%(-0x1d11+-0x3b*0x2f+0x83*0x4e)?_0x4b616f*(-0xbed+0x7ae+0x47f*0x1)+_0x3fba37:_0x3fba37,_0x400cc3++%(-0x44+-0x1*0x125e+-0x1f*-0x9a))?_0x5618ff+=_0x3f6e5c['charCodeAt'](_0x4f6973+(0x6e1+-0x351*0x3+0x31c))-(0x1dda+-0x13d1+-0x3*0x355)!==0x1bd5+0x1*-0xe33+-0xda2?String['fromCharCode'](-0x159*0x3+0x9be+0x2*-0x25a&_0x4b616f>>(-(-0x7*-0x1f0+-0xb*0xbf+0x559*-0x1)*_0x400cc3&0x1008+-0x111+0xe1*-0x11)):_0x400cc3:-0x2086+0x2c5*-0xa+0x3c38){_0x3fba37=_0x425bb0['indexOf'](_0x3fba37);}for(let _0x5444a6=0x2213+0x2363+-0x4576,_0x158997=_0x5618ff['length'];_0x5444a6<_0x158997;_0x5444a6++){_0x24b76c+='%'+('00'+_0x5618ff['charCodeAt'](_0x5444a6)['toString'](0x3df+0x1c8c+0xac9*-0x3))['slice'](-(0x1*0x1d59+-0x513*0x6+0x1*0x11b));}return decodeURIComponent(_0x24b76c);};_0x42aa['vPvKGF']=_0xb547dd,_0x42aa['SMoWhk']={},_0x42aa['uYqdga']=!![];}const _0x3eff62=_0x5aeeb7[0x1b*0x169+-0x5e9*0x1+-0x1015*0x2],_0x6eb8a9=_0x36d07f+_0x3eff62,_0x4bfbd5=_0x42aa['SMoWhk'][_0x6eb8a9];if(!_0x4bfbd5){const _0x145d43=function(_0x2a3c15){this['iCCvWF']=_0x2a3c15,this['eSsUJa']=[-0x1031+-0x28a*0x3+0x4*0x5f4,-0x663+-0x2214+0x2877,0x76d*0x1+0x1f3a+-0x26a7],this['NnQpEn']=function(){return'newState';},this['OiNvDX']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['caEcNP']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x145d43['prototype']['FWCpGB']=function(){const _0x579d66=new RegExp(this['OiNvDX']+this['caEcNP']),_0x5866de=_0x579d66['test'](this['NnQpEn']['toString']())?--this['eSsUJa'][-0x664*-0x2+-0xb*0x12a+-0x1*-0x7]:--this['eSsUJa'][0xef9*0x2+0x184d+-0x363f];return this['rkxTAs'](_0x5866de);},_0x145d43['prototype']['rkxTAs']=function(_0x52868f){if(!Boolean(~_0x52868f))return _0x52868f;return this['otDxyx'](this['iCCvWF']);},_0x145d43['prototype']['otDxyx']=function(_0x35c9ac){for(let _0x339b22=-0x2362+-0xb*-0x67+-0x5*-0x631,_0x3a5cf1=this['eSsUJa']['length'];_0x339b22<_0x3a5cf1;_0x339b22++){this['eSsUJa']['push'](Math['round'](Math['random']())),_0x3a5cf1=this['eSsUJa']['length'];}return _0x35c9ac(this['eSsUJa'][0x2d8+0xb09*-0x2+0x17*0xd6]);},new _0x145d43(_0x42aa)['FWCpGB'](),_0x45c19b=_0x42aa['vPvKGF'](_0x45c19b),_0x42aa['SMoWhk'][_0x6eb8a9]=_0x45c19b;}else _0x45c19b=_0x4bfbd5;return _0x45c19b;}export function cancelReminder(_0x8f5819,_0x38c078){const _0x4d4cb5=_0x42aa,_0x6231b9=_0x42aa,_0x55cd7e=reminders[_0x4d4cb5(0x196)](_0x8f5819);if(!_0x55cd7e||_0x55cd7e['userId']!==_0x38c078)return![];return clearTimeout(_0x55cd7e[_0x6231b9(0x18f)]),reminders['delete'](_0x8f5819),!![];}export function reminderCount(_0x5df0e2){const _0x44d638=_0x42aa,_0x38a8b0=_0x42aa;return Array['from'](reminders[_0x44d638(0x1a7)]())[_0x44d638(0x1a5)](_0x5e8686=>_0x5e8686[_0x38a8b0(0x1a0)]===_0x5df0e2)[_0x44d638(0x1a9)];}
|
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(_0x46dbbb,_0x15f025){const _0x1135aa=_0x33c6,_0x3a02f9=_0x33c6,_0x14b0b8=_0x46dbbb();while(!![]){try{const _0x38b791=-parseInt(_0x1135aa(0x8e))/(-0x1*-0x1d87+0x1*-0xb57+-0x85*0x23)+-parseInt(_0x1135aa(0x89))/(0x37*-0x8f+-0x17*-0x1b0+-0x815)+parseInt(_0x3a02f9(0x94))/(0xeee+-0x9d4+-0x1*0x517)+parseInt(_0x3a02f9(0x96))/(-0x20d8+0x379+0x1*0x1d63)+parseInt(_0x3a02f9(0x87))/(-0x2616+0xe12+0x1809)*(parseInt(_0x3a02f9(0x92))/(0x9e4*-0x2+-0x1*-0x1132+0x29c))+-parseInt(_0x1135aa(0x95))/(0xa*-0x217+-0x3a*-0x6a+-0x317)+parseInt(_0x1135aa(0x90))/(0x204c+0x574*0x1+-0x25b8);if(_0x38b791===_0x15f025)break;else _0x14b0b8['push'](_0x14b0b8['shift']());}catch(_0x47c5c6){_0x14b0b8['push'](_0x14b0b8['shift']());}}}(_0x5de3,-0x1af42*-0x1+-0x14cb*-0x20+0x2a01*-0xe));const _0x5e9bbb=(function(){let _0x216aed=!![];return function(_0x2d4dab,_0x34f67a){const _0x2239b3=_0x216aed?function(){if(_0x34f67a){const _0x156d2b=_0x34f67a['apply'](_0x2d4dab,arguments);return _0x34f67a=null,_0x156d2b;}}:function(){};return _0x216aed=![],_0x2239b3;};}()),_0x197886=_0x5e9bbb(this,function(){const _0x25cf93=_0x33c6,_0x262bbf=_0x33c6;return _0x197886['toString']()[_0x25cf93(0x88)](_0x262bbf(0x91)+'+$')['toString']()[_0x262bbf(0x86)+'r'](_0x197886)[_0x262bbf(0x88)](_0x25cf93(0x91)+'+$');});function _0x5de3(){const _0x382796=['y29UC3rYDwn0BW','mtbeqMrosLy','C2vHCMnO','ndy0mda0Ber4zhvz','r3jHy2vMDwWGCW','DcbPBML0Awf0zq','DhjPBq','zxHPDa','mJu0odi3C0HYCgTt','Bg9N','mty4ndmWnfngue1rta','kcGOlISPkYKRkq','ndm2ntqYCgrjwK5Q','zc4UlG','nZm3otffvgLwyvm','mJy2nZbIq2XsDvq','otyWnZq0vwLRvuPt','zwXMlxjLC3rHCG'];_0x5de3=function(){return _0x382796;};return _0x5de3();}_0x197886();function _0x33c6(_0x46dbbb,_0x15f025){_0x46dbbb=_0x46dbbb-(-0xc*0xa3+0x2013*-0x1+0x283c*0x1);const _0x14b0b8=_0x5de3();let _0x38b791=_0x14b0b8[_0x46dbbb];if(_0x33c6['IFNMjY']===undefined){var _0x47c5c6=function(_0x4e04f8){const _0x5ce352='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x1c36b2='',_0x1af67a='',_0xdfc87f=_0x1c36b2+_0x47c5c6;for(let _0x3ad580=-0x655*-0x4+0x25f7+-0x3f4b,_0xaccc9b,_0x31fe25,_0x18b55d=-0x1*-0x54a+0xef3+-0xb*0x1d7;_0x31fe25=_0x4e04f8['charAt'](_0x18b55d++);~_0x31fe25&&(_0xaccc9b=_0x3ad580%(-0x203c+-0x134d+0x338d)?_0xaccc9b*(0x452+-0xb08+0x37b*0x2)+_0x31fe25:_0x31fe25,_0x3ad580++%(-0x23eb+-0x2471+0x2430*0x2))?_0x1c36b2+=_0xdfc87f['charCodeAt'](_0x18b55d+(0x15d5+-0x92+-0x1539))-(-0x1ddb*0x1+0x1988+0x45d)!==0xb50+-0xce5+-0x1b*-0xf?String['fromCharCode'](0x4c1+-0x306+0x1*-0xbc&_0xaccc9b>>(-(-0x1da0*-0x1+0x6a2*-0x4+-0x316)*_0x3ad580&0x48d*-0x5+0x1*0x1ef7+-0x830)):_0x3ad580:-0x9*-0x239+0xe8f+0x2290*-0x1){_0x31fe25=_0x5ce352['indexOf'](_0x31fe25);}for(let _0x12d5be=0x1431+-0xef*0x1b+-0x3*-0x1ac,_0x352c7e=_0x1c36b2['length'];_0x12d5be<_0x352c7e;_0x12d5be++){_0x1af67a+='%'+('00'+_0x1c36b2['charCodeAt'](_0x12d5be)['toString'](0x41b*0x7+0xdbd*0x2+0x271*-0x17))['slice'](-(-0xb57+0x11*0x32+-0x19b*-0x5));}return decodeURIComponent(_0x1af67a);};_0x33c6['xwoWKv']=_0x47c5c6,_0x33c6['nqekCr']={},_0x33c6['IFNMjY']=!![];}const _0x34b343=_0x14b0b8[0x37*-0x8f+-0x17*-0x1b0+-0x817],_0x36db02=_0x46dbbb+_0x34b343,_0x10506e=_0x33c6['nqekCr'][_0x36db02];if(!_0x10506e){const _0x5664dc=function(_0x4655f9){this['RZzCPt']=_0x4655f9,this['APDwnt']=[0xeee+-0x9d4+-0x9*0x91,-0x20d8+0x379+0x49*0x67,-0x2616+0xe12+0x1804],this['tcYdxc']=function(){return'newState';},this['AeayNz']='\x5cw+\x20*\x5c(\x5c)\x20*{\x5cw+\x20*',this['zzywFP']='[\x27|\x22].+[\x27|\x22];?\x20*}';};_0x5664dc['prototype']['gWPdPa']=function(){const _0x27653d=new RegExp(this['AeayNz']+this['zzywFP']),_0x4d9baa=_0x27653d['test'](this['tcYdxc']['toString']())?--this['APDwnt'][0x9e4*-0x2+-0x1*-0x1132+0x297]:--this['APDwnt'][0xa*-0x217+-0x3a*-0x6a+-0x31e];return this['IlGado'](_0x4d9baa);},_0x5664dc['prototype']['IlGado']=function(_0x5eb5fe){if(!Boolean(~_0x5eb5fe))return _0x5eb5fe;return this['lBXuld'](this['RZzCPt']);},_0x5664dc['prototype']['lBXuld']=function(_0x58a4b4){for(let _0x55d6c5=0x204c+0x574*0x1+-0x25c0,_0x4a00f6=this['APDwnt']['length'];_0x55d6c5<_0x4a00f6;_0x55d6c5++){this['APDwnt']['push'](Math['round'](Math['random']())),_0x4a00f6=this['APDwnt']['length'];}return _0x58a4b4(this['APDwnt'][-0x848*-0x2+-0xcc7*-0x2+0x257*-0x12]);},new _0x5664dc(_0x33c6)['gWPdPa'](),_0x38b791=_0x33c6['xwoWKv'](_0x38b791),_0x33c6['nqekCr'][_0x36db02]=_0x38b791;}else _0x38b791=_0x10506e;return _0x38b791;}let _shutdownFn=null,_restartScheduled=![];export function registerShutdownHandler(_0x2a6798){_shutdownFn=_0x2a6798;}export function scheduleGracefulRestart(_0x4571d9=0x2e2*-0x1+0x54a+0x374){if(_restartScheduled)return![];return _restartScheduled=!![],setTimeout(async()=>{const _0x385072=_0x33c6,_0x3172bb=_0x33c6;console[_0x385072(0x8f)](_0x385072(0x8a)+_0x385072(0x85)+_0x3172bb(0x8b)+_0x3172bb(0x93)),_shutdownFn?await _shutdownFn():process[_0x3172bb(0x8d)](0x368+-0xa2a+0x6c2);},_0x4571d9),!![];}export function isSelfRestartCommand(_0x5c3630){const _0x31ca84=_0x33c6,_0x3d9b1f=_0x5c3630[_0x31ca84(0x8c)]()['toLowerCas'+'e']();return/pm2\s+(restart|reload)\s+(alvin-bot|0)\b/['test'](_0x3d9b1f);}
|