levix-bot 4.8.0 → 4.9.2

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.
Files changed (66) hide show
  1. package/README.md +9 -5
  2. package/SETUP.md +21 -2
  3. package/app.cjs +69 -23
  4. package/package.json +3 -2
  5. package/public/dashboard/assets/index-4xhK_Tpl.js +561 -0
  6. package/public/dashboard/assets/index-CK8osB4o.css +2 -0
  7. package/public/dashboard/index.html +2 -2
  8. package/public/dashboard.css +21 -0
  9. package/public/dashboard.js +25 -2
  10. package/public/gateway-i18n.js +26 -0
  11. package/src/bootstrap/core.js +4 -0
  12. package/src/bootstrap/session-startup-policy.js +6 -6
  13. package/src/commands/group/antilink.cjs +82 -59
  14. package/src/commands/group/antispam.cjs +112 -0
  15. package/src/commands/group/clearwarns.cjs +6 -6
  16. package/src/commands/group/demote.cjs +11 -13
  17. package/src/commands/group/flagged.cjs +52 -0
  18. package/src/commands/group/kick.cjs +25 -15
  19. package/src/commands/group/media.cjs +65 -29
  20. package/src/commands/group/policy.cjs +215 -0
  21. package/src/commands/group/promote.cjs +11 -12
  22. package/src/commands/group/rules.cjs +9 -6
  23. package/src/commands/group/setwarn.cjs +17 -27
  24. package/src/commands/group/warn.cjs +13 -63
  25. package/src/commands/group.cjs +5 -2
  26. package/src/commands/mod.cjs +101 -26
  27. package/src/commands/translate.cjs +585 -0
  28. package/src/config/ai-identity.cjs +53 -1
  29. package/src/config/ai-persona.md +32 -73
  30. package/src/config/baileys.config.js +15 -2
  31. package/src/config/defaults.cjs +2 -0
  32. package/src/config/secrets.cjs +71 -3
  33. package/src/config/settings.cjs +39 -1
  34. package/src/core/connection.js +40 -1
  35. package/src/core/session.js +11 -2
  36. package/src/core/socket.js +4 -5
  37. package/src/db/db.cjs +66 -0
  38. package/src/db/store.cjs +264 -16
  39. package/src/diagnostics/baileysLog.cjs +87 -0
  40. package/src/diagnostics/crashReports.cjs +35 -9
  41. package/src/diagnostics/debugLog.cjs +405 -0
  42. package/src/diagnostics/nodeRuntime.cjs +131 -0
  43. package/src/handlers/command.handler.js +1 -0
  44. package/src/handlers/group.handler.js +32 -1
  45. package/src/handlers/message.handler.js +53 -17
  46. package/src/middleware/antispam.middleware.js +95 -48
  47. package/src/panel/feedback.cjs +32 -5
  48. package/src/panel/one-time-code.cjs +156 -0
  49. package/src/panel/password-reset.cjs +187 -91
  50. package/src/panel/recovery-email.cjs +333 -0
  51. package/src/routes/dashboard.api.esm.js +267 -20
  52. package/src/services/aiAgent.cjs +25 -3
  53. package/src/services/moderationPolicy.cjs +895 -0
  54. package/src/services/settingsTransfer.cjs +4 -2
  55. package/src/utils/linkedCreds.cjs +22 -0
  56. package/src/utils/logger.cjs +11 -0
  57. package/src/utils/moderationAction.cjs +637 -0
  58. package/src/utils/moderationSummary.cjs +225 -0
  59. package/src/utils/permissions.cjs +70 -0
  60. package/src/utils/permissions.esm.js +48 -8
  61. package/src/utils/storage.cjs +8 -0
  62. package/src/utils/storage.esm.js +4 -0
  63. package/views/login.ejs +100 -28
  64. package/public/dashboard/assets/index-B8E5IYlB.js +0 -540
  65. package/public/dashboard/assets/index-C5D4wzm4.css +0 -2
  66. package/src/commands/group/antiSpam.cjs +0 -97
@@ -15,8 +15,10 @@
15
15
  // language, delays, thumbnails, port and proxy shape, …) plus the command
16
16
  // table — prefix, permission overrides, alias overrides, disabled commands.
17
17
  // Not covered on purpose: per-group config and the memory files (they are
18
- // personal data, not settings) and the AI persona (a behaviour file the
19
- // operator authors, shared by copy-paste if wanted).
18
+ // personal data, not settings), the AI persona (a behaviour file the
19
+ // operator authors, shared by copy-paste if wanted), and account security
20
+ // (`auth:password`, `auth:recovery-email`). The recovery address is sealed
21
+ // outside the settings list and must never be added to this file.
20
22
 
21
23
  const settings = require("../config/settings.cjs");
22
24
  const runtimeConfig = require("../config/runtime-config.cjs");
@@ -0,0 +1,22 @@
1
+ // Whether Baileys credentials describe a finished link to a WhatsApp account.
2
+ //
3
+ // One definition, because three places need the answer (the boot policy that
4
+ // resumes a paired install, the session manager, and the socket factory) and
5
+ // they used to disagree with Baileys instead of with each other.
6
+ //
7
+ // me.id requestPairingCode writes it, with name "~", before the phone
8
+ // accepts the code. Alone it proves nothing.
9
+ // registered Baileys sets it true only in the pairing-code flow. A link
10
+ // made by scanning a QR code stays `registered: false` forever,
11
+ // so `false` cannot mean "unfinished".
12
+ // account the signed device identity, written by pair-success in both
13
+ // flows and in neither unfinished state.
14
+ //
15
+ // So a link is finished when there is a me.id and either the code flow said so
16
+ // or the account identity arrived.
17
+ function isLinkedCreds(creds) {
18
+ if (!creds?.me?.id) return false;
19
+ return creds.registered !== false || Boolean(creds.account);
20
+ }
21
+
22
+ module.exports = { isLinkedCreds };
@@ -3,6 +3,7 @@ const fs = require("node:fs");
3
3
  const pino = require("pino");
4
4
 
5
5
  const { ensureDataDir } = require("../config/paths.cjs");
6
+ const debugLog = require("../diagnostics/debugLog.cjs");
6
7
 
7
8
  // Logs go in the data directory with everything else the bot writes, so a
8
9
  // global install never tries to write next to its own code.
@@ -52,6 +53,8 @@ const logger = pino(
52
53
  base,
53
54
  pino.multistream([
54
55
  { level: "trace", stream: combinedStream },
56
+ // Detailed, sanitized, local only. See src/diagnostics/debugLog.cjs.
57
+ { level: "debug", stream: debugLog.stream },
55
58
  { level: "error", stream: errorStream },
56
59
  {
57
60
  level: "trace",
@@ -62,6 +65,12 @@ const logger = pino(
62
65
  ]),
63
66
  );
64
67
 
68
+ // Writes only to the sanitized debug log: never combined.log, error.log or the
69
+ // console. For detail that matters only when diagnosing (Baileys, Node's
70
+ // network layer), and that leaves the device only inside an operator-sent
71
+ // crash report or feedback with diagnostics ticked.
72
+ logger.debugOnly = pino(base, debugLog.stream);
73
+
65
74
  const MAX_READ_BYTES = 256 * 1024;
66
75
 
67
76
  /** Read only the bounded tail of the operational log, never arbitrary files. */
@@ -127,6 +136,8 @@ logger.clearLogs = function clearLogs() {
127
136
  errorStream.flushSync();
128
137
  fs.ftruncateSync(combinedStream.fd, 0);
129
138
  fs.ftruncateSync(errorStream.fd, 0);
139
+ // The debug log is part of "the logs": one Clear removes it too.
140
+ debugLog.clearDebugLogs();
130
141
  };
131
142
 
132
143
  module.exports = logger;