levix-bot 4.2.1 → 4.3.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.
@@ -10,7 +10,7 @@
10
10
  <link rel="preconnect" href="https://fonts.googleapis.com" />
11
11
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
12
12
  <link href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=Tajawal:wght@400;500;700;800&family=JetBrains+Mono:wght@400;500&display=swap" rel="stylesheet" />
13
- <script type="module" crossorigin src="/dashboard/assets/index-4AuqfnH5.js"></script>
13
+ <script type="module" crossorigin src="/dashboard/assets/index-BCXZoPGP.js"></script>
14
14
  <link rel="stylesheet" crossorigin href="/dashboard/assets/index-LvfJ8ybs.css">
15
15
  </head>
16
16
  <body>
@@ -2902,4 +2902,74 @@ html[dir="rtl"] .logout-btn svg {
2902
2902
  animation-iteration-count: 1 !important;
2903
2903
  transition-duration: 0.001ms !important;
2904
2904
  }
2905
- }
2905
+ }
2906
+ /* --- gateway: password visibility, reset link, screen guard ------------- */
2907
+
2908
+ .input-wrap {
2909
+ position: relative;
2910
+ }
2911
+
2912
+ .input-wrap input {
2913
+ padding-inline-end: 44px;
2914
+ }
2915
+
2916
+ .eye-btn {
2917
+ position: absolute;
2918
+ inset-inline-end: 6px;
2919
+ top: 50%;
2920
+ transform: translateY(-50%);
2921
+ display: grid;
2922
+ place-items: center;
2923
+ width: 32px;
2924
+ height: 32px;
2925
+ border: none;
2926
+ border-radius: 8px;
2927
+ background: transparent;
2928
+ color: var(--faint);
2929
+ cursor: pointer;
2930
+ }
2931
+
2932
+ .eye-btn:hover {
2933
+ color: var(--text);
2934
+ background: color-mix(in srgb, var(--line) 55%, transparent);
2935
+ }
2936
+
2937
+ .eye-btn svg {
2938
+ width: 17px;
2939
+ height: 17px;
2940
+ }
2941
+
2942
+ .auth-alt {
2943
+ margin-top: 14px;
2944
+ text-align: center;
2945
+ }
2946
+
2947
+ .link-btn {
2948
+ padding: 0;
2949
+ border: none;
2950
+ background: none;
2951
+ color: #70a3ff;
2952
+ font-size: 0.8rem;
2953
+ font-weight: 600;
2954
+ cursor: pointer;
2955
+ }
2956
+
2957
+ .link-btn:hover {
2958
+ text-decoration: underline;
2959
+ }
2960
+
2961
+ /* The password screens blur themselves whenever the page can't be watched —
2962
+ another tab, a minimised window, the task switcher. Best effort: the web
2963
+ platform cannot truly forbid screenshots, but this keeps the form out of
2964
+ task-switcher thumbnails and casual captures. Printing one of these pages
2965
+ gets a blank sheet instead. */
2966
+ html.screen-guard .gateway-panel {
2967
+ filter: blur(18px);
2968
+ }
2969
+
2970
+ @media print {
2971
+
2972
+ .gateway-panel {
2973
+ display: none;
2974
+ }
2975
+ }
@@ -0,0 +1,41 @@
1
+ // Shared behaviour for the gateway pages (login · setup · reset).
2
+ //
3
+ // Two small things, both of which must never break the form if the script
4
+ // itself fails to load: the page works without either one.
5
+
6
+ (function () {
7
+ // Eye toggles. One delegated listener covers every password field on the
8
+ // page — the button carries two icons and swaps which one is visible.
9
+ document.addEventListener("click", function (event) {
10
+ var btn = event.target.closest ? event.target.closest(".eye-btn") : null;
11
+ if (!btn) return;
12
+ event.preventDefault();
13
+ var input = btn.parentElement ? btn.parentElement.querySelector("input") : null;
14
+ if (!input) return;
15
+ var show = input.type === "password";
16
+ input.type = show ? "text" : "password";
17
+ var on = btn.querySelector(".eye-on");
18
+ var off = btn.querySelector(".eye-off");
19
+ if (on) on.style.display = show ? "none" : "";
20
+ if (off) off.style.display = show ? "" : "none";
21
+ btn.setAttribute("aria-label", show ? "Hide password" : "Show password");
22
+ });
23
+
24
+ // Blur the password screens whenever the page can't be watched: another
25
+ // tab, a minimised window, the OS task switcher. This is best effort —
26
+ // the web platform cannot truly forbid screenshots — but it keeps the form
27
+ // out of task-switcher thumbnails and casual over-the-shoulder captures.
28
+ var root = document.documentElement;
29
+ function engage() {
30
+ root.classList.add("screen-guard");
31
+ }
32
+ function release() {
33
+ root.classList.remove("screen-guard");
34
+ }
35
+ document.addEventListener("visibilitychange", function () {
36
+ if (document.visibilityState === "hidden") engage();
37
+ else release();
38
+ });
39
+ window.addEventListener("blur", engage);
40
+ window.addEventListener("focus", release);
41
+ })();
@@ -66,6 +66,10 @@ export async function bootstrapCore({ autoStart = false } = {}) {
66
66
  log: logger,
67
67
  });
68
68
 
69
+ // WhatsApp commands (!stopbot, !restart) drive the same state machine the
70
+ // panel does — nothing here ever touches a socket directly.
71
+ require("../core/session-holder.cjs").setSession(session);
72
+
69
73
  const startup = sessionStartupPolicy({ autoStart, wasPaired });
70
74
  if (startup.start) await session.start({ reason: startup.reason });
71
75
 
@@ -66,6 +66,8 @@ export async function bootstrapPanel({ core } = {}) {
66
66
  // The routes read the live socket off the session manager, so a reconnect
67
67
  // needs no re-wiring here.
68
68
  if (core?.session) setSession(core.session);
69
+ // The WhatsApp-code password reset talks to the same session manager.
70
+ if (core?.session) require("../panel/password-reset.cjs").setSession(core.session);
69
71
 
70
72
  // After every route is registered — the 404 and the error handler have to be
71
73
  // last, or they swallow what comes after them.
@@ -1,6 +1,6 @@
1
1
  const { scheduleNewJob, saveScheduledJob } = require("../../scheduler.cjs");
2
2
  const { randomUUID } = require("node:crypto");
3
- const { defaultTimezone } = require("../utils/datetime.cjs");
3
+ const logger = require("../utils/logger.cjs");
4
4
  const { parseRecurringArgs } = require("../utils/recurrence.cjs");
5
5
  const { tr } = require("../utils/i18n.cjs");
6
6
 
@@ -71,17 +71,14 @@ module.exports = {
71
71
 
72
72
  saveScheduledJob(newJob);
73
73
 
74
- await sock.sendMessage(creatorJid, {
75
- text:
76
- parsed.type === "weekly"
77
- ? tr(
78
- `✅ Scheduled weekly on ${args[1]} at ${parsed.time} (${defaultTimezone()})`,
79
- `✅ تم جدولة الرسالة أسبوعيًا يوم ${args[1]} الساعة ${parsed.time} (${defaultTimezone()})`,
80
- )
81
- : tr(
82
- `✅ Scheduled daily at ${parsed.time} (${defaultTimezone()})`,
83
- `✅ تم جدولة الرسالة يوميًا الساعة ${parsed.time} (${defaultTimezone()})`,
84
- ),
85
- });
74
+ // تأكيد صامت: تفاعل على رسالة الإنشاء بدل رسالة "تم الجدولة" المنفصلة
75
+ try {
76
+ await sock.sendMessage(targetJid, { react: { text: "✅", key: msg.key } });
77
+ } catch (error) {
78
+ logger.warn(
79
+ { err: error, command: "autoschedule" },
80
+ "failed to react to the scheduled message",
81
+ );
82
+ }
86
83
  },
87
84
  };
@@ -1,7 +1,7 @@
1
1
  // file: /commands/block.js (Upgraded with private chat context)
2
2
  const logger = require("../utils/logger.cjs");
3
3
  const { isOwnerJidSync } = require("../utils/permissions.cjs");
4
- const normalizeJid = require("../utils/normalizeJid.esm.js");
4
+ const normalizeJid = require("../utils/normalizeJid.esm.js").default;
5
5
  const { tr } = require("../utils/i18n.cjs");
6
6
 
7
7
  module.exports = {
@@ -1,13 +1,20 @@
1
- // file: /commands/restart.js
2
- const { delay } = require("@whiskeysockets/baileys");
1
+ // Restarts the WhatsApp connection — not the process.
2
+ //
3
+ // It used to SIGTERM the whole bot and lean on the supervisor to bring it
4
+ // back, which took the control panel down with the socket. What people mean
5
+ // by restart here is the connection: session.reconnect() is the same
6
+ // stop()+start() the panel's Connection screen uses, so the state machine
7
+ // stays the only socket owner and a restart never kicks whoever is watching
8
+ // the panel out.
9
+ const { getSession } = require("../core/session-holder.cjs");
3
10
  const logger = require("../utils/logger.cjs");
4
11
  const { tr } = require("../utils/i18n.cjs");
5
12
 
6
13
  module.exports = {
7
14
  name: "restart",
8
15
  description: {
9
- en: "Restarts the bot.",
10
- ar: "يعيد تشغيل البوت.",
16
+ en: "Reconnects WhatsApp (the process and panel stay up).",
17
+ ar: "يعيد تشغيل اتصال واتساب (عملية البوت واللوحة يفضلوا شغالين).",
11
18
  },
12
19
  usage: {
13
20
  en: "restart",
@@ -16,24 +23,46 @@ module.exports = {
16
23
  chat: "all",
17
24
 
18
25
  async execute(sock, msg) {
19
- logger.warn("Received !restart command. Restarting bot...");
26
+ const chatId = msg.key.remoteJid;
27
+ const session = getSession();
28
+ if (!session) {
29
+ return await sock.sendMessage(chatId, {
30
+ text: tr("The session manager isn't ready yet.", "مدير الجلسة لسه مش جاهز."),
31
+ });
32
+ }
20
33
 
21
- // Send a confirmation message before exiting
22
- await sock.sendMessage(msg.key.remoteJid, {
34
+ // Goes out while the current socket is still alive.
35
+ await sock.sendMessage(chatId, {
23
36
  text: tr(
24
- "✅ Restarting the bot... back in a moment.",
25
- "✅ جاري إعادة تشغيل البوت... سأعود بعد لحظات.",
37
+ "🔄 Reconnecting WhatsApp... back in a moment.",
38
+ "🔄 جاري إعادة تشغيل اتصال واتساب... هرجع في لحظة.",
26
39
  ),
27
40
  });
28
41
 
29
- // A small delay to ensure the message is sent before the process exits
30
- await delay(2000); // 2-second delay
42
+ let state = null;
43
+ try {
44
+ state = await session.reconnect({ reason: "command" });
45
+ logger.info("[commands] WhatsApp connection restarted by !restart");
46
+ } catch (error) {
47
+ logger.error({ err: error, command: "restart" }, "Failed to reconnect WhatsApp");
48
+ }
31
49
 
32
- // SIGTERM to ourselves, not process.exit(): that is the path in
33
- // src/index.js that cancels the reconnect timers, closes the WhatsApp
34
- // socket, flushes the store and closes the database. Exiting straight from
35
- // here skipped all four and left the WAL unchecked-pointed. The supervisor
36
- // (pm2 / systemd / docker) brings the process back.
37
- process.kill(process.pid, "SIGTERM");
50
+ if (state?.connected) {
51
+ await sock.sendMessage(chatId, {
52
+ text: tr("✅ WhatsApp is back online.", "✅ اتصال واتساب رجع يشتغل."),
53
+ });
54
+ } else {
55
+ // Not connected (a QR wait, a retry, a failure) — say where things
56
+ // stand instead of claiming success. The old socket is gone either way,
57
+ // so this send is best-effort.
58
+ await sock
59
+ .sendMessage(chatId, {
60
+ text: tr(
61
+ `Connection state now: ${state?.status || "unknown"}. Check the panel's Connection screen.`,
62
+ `حالة الاتصال دلوقتي: ${state?.status || "غير معروفة"}. راجع شاشة Connection في لوحة التحكم.`,
63
+ ),
64
+ })
65
+ .catch(() => {});
66
+ }
38
67
  },
39
68
  };
@@ -1,6 +1,7 @@
1
1
  // file: commands/schedule.js
2
2
  const { scheduleNewJob, saveScheduledJob } = require("../../scheduler.cjs");
3
- const { zonedTimeToDate, defaultTimezone } = require("../utils/datetime.cjs");
3
+ const { zonedTimeToDate } = require("../utils/datetime.cjs");
4
+ const logger = require("../utils/logger.cjs");
4
5
  const { tr } = require("../utils/i18n.cjs");
5
6
 
6
7
  const DATETIME_RE = /^(\d{1,2}):(\d{2})\s+(\d{1,2})-(\d{1,2})-(\d{4})$/;
@@ -92,14 +93,11 @@ module.exports = {
92
93
 
93
94
  saveScheduledJob(newJob);
94
95
 
95
- const when = scheduleDate.toLocaleString(tr("en-GB", "ar-EG"), {
96
- timeZone: defaultTimezone(),
97
- });
98
- await sock.sendMessage(creatorJid, {
99
- text: tr(
100
- `✅ Your message is scheduled for:\n*${when}*`,
101
- `✅ تم جدولة رسالتك بنجاح ليتم إرسالها في:\n*${when}*`,
102
- ),
103
- });
96
+ // تأكيد صامت: تفاعل على رسالة الإنشاء بدل رسالة "تم الجدولة" المنفصلة
97
+ try {
98
+ await sock.sendMessage(targetJid, { react: { text: "✅", key: msg.key } });
99
+ } catch (error) {
100
+ logger.warn({ err: error, command: "schedule" }, "failed to react to the scheduled message");
101
+ }
104
102
  },
105
103
  };
@@ -0,0 +1,116 @@
1
+ // Re-sends content into the current chat. Built for statuses (stories): reply
2
+ // to one with !send and the bot re-posts it here, so a photo that lives 24
3
+ // hours on the status ring stays in the chat. Works on any replied message —
4
+ // photo, video, voice note, sticker, document or plain text.
5
+ //
6
+ // No storage is involved: the reply's quotedMessage carries the full media
7
+ // metadata (url, mediaKey, directPath), which is enough to download and
8
+ // decrypt it again — nothing is cached and nothing is archived.
9
+ const { downloadContentFromMessage } = require("@whiskeysockets/baileys");
10
+ const { downloadMedia } = require("../utils/geminiMedia.cjs");
11
+ const { unwrapMessage, visibleText } = require("../utils/messageContent.cjs");
12
+ const { createStatus } = require("../utils/statusMessage.cjs");
13
+ const logger = require("../utils/logger.cjs");
14
+ const { tr } = require("../utils/i18n.cjs");
15
+
16
+ // The media in a message plus the download type that decrypts it — the type
17
+ // WhatsApp filed it under, not the MIME type (same rule as the AI command).
18
+ function pickMedia(message) {
19
+ const inner = unwrapMessage(message);
20
+ if (inner.stickerMessage) return { media: inner.stickerMessage, type: "sticker" };
21
+ if (inner.imageMessage) return { media: inner.imageMessage, type: "image" };
22
+ if (inner.videoMessage) return { media: inner.videoMessage, type: "video" };
23
+ if (inner.audioMessage) return { media: inner.audioMessage, type: "audio" };
24
+ if (inner.documentMessage) return { media: inner.documentMessage, type: "document" };
25
+ return null;
26
+ }
27
+
28
+ function quotedOf(msg) {
29
+ const own = unwrapMessage(msg.message);
30
+ return own.extendedTextMessage?.contextInfo?.quotedMessage || null;
31
+ }
32
+
33
+ module.exports = {
34
+ name: "send",
35
+ description: {
36
+ en: "Re-sends the replied message here: a status/story, photo, video, voice note, sticker, document or text.",
37
+ ar: "يعيد إرسال الرسالة الموجّه لها الرد هنا: استوري، صورة، فيديو، رسالة صوتية، ستيكر، مستند أو نص.",
38
+ },
39
+ usage: {
40
+ en: "send (reply to a status or any message with it)",
41
+ ar: "send (اعمل رد على استوري أو أي رسالة بالأمر)",
42
+ },
43
+ chat: "all",
44
+
45
+ async execute(sock, msg) {
46
+ const chatId = msg.key.remoteJid;
47
+ const quoted = quotedOf(msg);
48
+
49
+ // Media attached to the command itself counts too — "send this" with a
50
+ // caption works like a reply does.
51
+ const target = pickMedia(msg.message) || (quoted ? pickMedia(quoted) : null);
52
+
53
+ if (!target) {
54
+ const quotedText = quoted ? visibleText(quoted) : "";
55
+ if (quotedText) {
56
+ return await sock.sendMessage(chatId, { text: quotedText });
57
+ }
58
+ return await sock.sendMessage(chatId, {
59
+ text: tr(
60
+ "Reply to a status or any message with `!send` and I'll re-send it here.",
61
+ "اعمل رد على استوري أو أي رسالة بالأمر `!send` وأنا هعيد إرسالها هنا.",
62
+ ),
63
+ });
64
+ }
65
+
66
+ const status = await createStatus(sock, chatId, tr("📥 Sending...", "📥 جاري الإرسال..."), {
67
+ replyTo: msg,
68
+ });
69
+
70
+ try {
71
+ const buffer = await downloadMedia(downloadContentFromMessage, target.media, target.type);
72
+ const media = target.media;
73
+ const { mimetype, caption } = media;
74
+
75
+ let content;
76
+ if (target.type === "image") {
77
+ content = {
78
+ image: buffer,
79
+ ...(caption ? { caption } : {}),
80
+ ...(mimetype ? { mimetype } : {}),
81
+ };
82
+ } else if (target.type === "video") {
83
+ content = {
84
+ video: buffer,
85
+ ...(caption ? { caption } : {}),
86
+ ...(mimetype ? { mimetype } : {}),
87
+ ...(media.gifPlayback ? { gifPlayback: true } : {}),
88
+ };
89
+ } else if (target.type === "audio") {
90
+ content = { audio: buffer, ...(mimetype ? { mimetype } : {}), ptt: !!media.ptt };
91
+ } else if (target.type === "sticker") {
92
+ content = { sticker: buffer, ...(mimetype ? { mimetype } : {}) };
93
+ } else {
94
+ content = {
95
+ document: buffer,
96
+ ...(mimetype ? { mimetype } : {}),
97
+ ...(media.fileName ? { fileName: media.fileName } : {}),
98
+ ...(caption ? { caption } : {}),
99
+ };
100
+ }
101
+
102
+ await sock.sendMessage(chatId, content);
103
+ // The media is the answer — the status line goes away.
104
+ await status.remove();
105
+ } catch (error) {
106
+ logger.error({ err: error, command: "send" }, "Failed to re-send replied media");
107
+ await status.fail(
108
+ error,
109
+ tr(
110
+ "Couldn't re-send it — the media may have expired",
111
+ "معرفتش أبعته — ممكن الميديا تكون انتهت",
112
+ ),
113
+ );
114
+ }
115
+ },
116
+ };
@@ -0,0 +1,68 @@
1
+ // Pauses the WhatsApp connection without touching the process.
2
+ //
3
+ // It replaced `!shutdown`, which shelled out to `pm2 stop` — a command from an
4
+ // install shape Levix outgrew, and one that took the control panel down with
5
+ // the bot. This is the panel's own "Stop" from inside a chat: the same state
6
+ // machine call, pairing kept, panel up, no retry afterwards. Resuming is the
7
+ // Connection screen — once the socket is down no message can arrive, so there
8
+ // is no way to type a start command.
9
+ const { getSession } = require("../core/session-holder.cjs");
10
+ const logger = require("../utils/logger.cjs");
11
+ const { tr } = require("../utils/i18n.cjs");
12
+
13
+ module.exports = {
14
+ name: "stopbot",
15
+ aliases: ["stop", "pause"],
16
+ description: {
17
+ en: "Pauses the WhatsApp connection (the bot process and panel keep running).",
18
+ ar: "يوقف اتصال واتساب مؤقتًا (عملية البوت ولوحة التحكم يفضلوا شغالين).",
19
+ },
20
+ usage: {
21
+ en: "stopbot",
22
+ ar: "stopbot",
23
+ },
24
+ chat: "all",
25
+
26
+ async execute(sock, msg) {
27
+ const chatId = msg.key.remoteJid;
28
+ const session = getSession();
29
+ if (!session) {
30
+ return await sock.sendMessage(chatId, {
31
+ text: tr("The session manager isn't ready yet.", "مدير الجلسة لسه مش جاهز."),
32
+ });
33
+ }
34
+
35
+ const state = session.getState();
36
+ if (!state.connected && !state.canStop) {
37
+ return await sock.sendMessage(chatId, {
38
+ text: tr(
39
+ "The WhatsApp connection isn't up — nothing to pause.",
40
+ "اتصال واتساب مش شغال أصلًا — مفيش حاجة أوقفها.",
41
+ ),
42
+ });
43
+ }
44
+
45
+ // The goodbye goes out before the socket comes down: once stop() runs,
46
+ // nothing can be sent through this chat until the session starts again.
47
+ await sock.sendMessage(chatId, {
48
+ text: tr(
49
+ "⏸️ Pausing the WhatsApp connection. The bot and the control panel stay up — resume from the Connection screen in the panel.",
50
+ "⏸️ جاري إيقاف اتصال واتساب مؤقتًا. البوت واللوحة هيفضلوا شغالين — شغّله تاني من شاشة Connection في لوحة التحكم.",
51
+ ),
52
+ });
53
+
54
+ try {
55
+ await session.stop({ reason: "command" });
56
+ logger.warn("[commands] WhatsApp connection paused by !stopbot");
57
+ } catch (error) {
58
+ logger.error({ err: error, command: "stopbot" }, "Failed to pause the WhatsApp connection");
59
+ // The socket may still be up, so the operator can actually read this.
60
+ await sock.sendMessage(chatId, {
61
+ text: tr(
62
+ "Couldn't pause the connection. Try the panel's Connection screen.",
63
+ "معرفتش أوقف الاتصال. جرب شاشة Connection في لوحة التحكم.",
64
+ ),
65
+ });
66
+ }
67
+ },
68
+ };
@@ -1,6 +1,6 @@
1
1
  // file: /commands/unblock.js (Upgraded with private chat context)
2
2
  const logger = require("../utils/logger.cjs");
3
- const normalizeJid = require("../utils/normalizeJid.esm.js");
3
+ const normalizeJid = require("../utils/normalizeJid.esm.js").default;
4
4
  const { tr } = require("../utils/i18n.cjs");
5
5
 
6
6
  module.exports = {
@@ -47,12 +47,13 @@ const COMMAND_PERMISSIONS = Object.freeze({
47
47
  perm: "OWNER_ONLY",
48
48
  setprefix: "OWNER_ONLY",
49
49
  restart: "OWNER_ONLY",
50
- shutdown: "OWNER_ONLY",
50
+ stopbot: "OWNER_ONLY",
51
51
  status: "OWNER_ONLY",
52
52
  lang: "MEMBERS",
53
53
  digit: "MEMBERS",
54
54
  block: "OWNER_ONLY",
55
55
  unblock: "OWNER_ONLY",
56
+ send: "MEMBERS",
56
57
  group: {
57
58
  default_permission: "ADMINS_OWNER",
58
59
  sub_commands: {
@@ -586,8 +586,7 @@ function set(key, value) {
586
586
  }
587
587
 
588
588
  const clean = validate(definition, value);
589
- const toStore =
590
- definition.type === "secret" ? require("./vault.cjs").seal(String(clean)) : clean;
589
+ const toStore = definition.type === "secret" ? require("./vault.cjs").seal(String(clean)) : clean;
591
590
  storage.saveBotSetting(`setting:${key}`, toStore);
592
591
  // Never log the value of a secret.
593
592
  logger.info(`[settings] ${key} -> ${definition.type === "secret" ? "(updated)" : clean}`);
@@ -629,4 +628,7 @@ module.exports = {
629
628
  sourceOf,
630
629
  SETTING_KEYS: [...BY_KEY.keys()],
631
630
  SECRET_SETTING_KEYS: [...SECRET_SETTING_KEYS],
631
+ RESTART_SETTING_KEYS: SETTINGS.filter((definition) => definition.restart === true).map(
632
+ (definition) => definition.key,
633
+ ),
632
634
  };
@@ -0,0 +1,23 @@
1
+ // A process-wide pointer to the backend's session manager.
2
+ //
3
+ // The state machine in session.js is the only thing allowed to create or
4
+ // destroy a Baileys socket, but it is built once in bootstrap/core.js and not
5
+ // every caller sits on that dependency path — the WhatsApp commands (!stopbot,
6
+ // !restart) don't (the panel gets its own hand-over in bootstrap/panel.js).
7
+ // bootstrapCore() sets this right after constructing the manager; commands
8
+ // read it at call time.
9
+ //
10
+ // Null until the core is up — callers answer that with a friendly line,
11
+ // never a crash.
12
+
13
+ let session = null;
14
+
15
+ function setSession(manager) {
16
+ session = manager;
17
+ }
18
+
19
+ function getSession() {
20
+ return session;
21
+ }
22
+
23
+ module.exports = { setSession, getSession };
@@ -3,8 +3,8 @@ import { createRequire } from "module";
3
3
  import { dirname, join } from "path";
4
4
  import { fileURLToPath } from "url";
5
5
  import { checkBotAdmin, checkCommandPermission } from "../middleware/permissions.middleware.js";
6
- import { sendBotMessage } from "../utils/sendBotMessage.esm.js";
7
6
  import { resolveGroupMetadata } from "../utils/groupMetadataCache.cjs";
7
+ import { sendBotMessage } from "../utils/sendBotMessage.esm.js";
8
8
 
9
9
  const __filename = fileURLToPath(import.meta.url);
10
10
  const __dirname = dirname(__filename);
@@ -32,6 +32,7 @@ const EDIT_IN_PLACE_EXCLUDE = new Set([
32
32
  "prayer",
33
33
  "tts",
34
34
  "stt",
35
+ "send",
35
36
  "weather",
36
37
  "qr",
37
38
  "status",
@@ -319,10 +320,7 @@ async function runCommand(sock, msg, body, { command, args, invokedName, isGroup
319
320
  sock,
320
321
  msg.key.remoteJid,
321
322
  {
322
- text: tr(
323
- "⚠️ This command only works in groups.",
324
- "⚠️ هذا الأمر يعمل في المجموعات فقط.",
325
- ),
323
+ text: tr("⚠️ This command only works in groups.", "⚠️ هذا الأمر يعمل في المجموعات فقط."),
326
324
  },
327
325
  { replyTo: msg },
328
326
  );