levix-bot 4.9.1 → 5.0.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/README.md +57 -3
- package/SETUP.md +63 -7
- package/app.cjs +159 -46
- package/deploy/install.sh +10 -5
- package/package.json +9 -6
- package/public/dashboard/assets/40af6d88b63079a0-BZ8ojJNu.woff2 +0 -0
- package/public/dashboard/assets/481acf6760031cee-BypgxfGb.woff2 +0 -0
- package/public/dashboard/assets/6d3351fc535f8ef3-D2-eand5.woff2 +0 -0
- package/public/dashboard/assets/8ab0af53a3bda9d3-CyCXRvzh.woff2 +0 -0
- package/public/dashboard/assets/8f262393e9249e61-TQp-UTiE.woff2 +0 -0
- package/public/dashboard/assets/94d65887a83f1282-DmpS2jIq.woff2 +0 -0
- package/public/dashboard/assets/99e400330f36ae77-D3oMJlXt.woff2 +0 -0
- package/public/dashboard/assets/9d1f41b13e519d90-BVNSOH3d.woff2 +0 -0
- package/public/dashboard/assets/a005256cb957ecc7-CoYeBiSI.woff2 +0 -0
- package/public/dashboard/assets/b19c2080652a3c2b-DIC32ArD.woff2 +0 -0
- package/public/dashboard/assets/c4064400db3750ce-BehTv68k.woff2 +0 -0
- package/public/dashboard/assets/c69d345fa1068c2d-CmI34b-g.woff2 +0 -0
- package/public/dashboard/assets/cc27b30471250057-6fWv1k7M.woff2 +0 -0
- package/public/dashboard/assets/d8c30647abfeffe6-eXO_dkmS.woff2 +0 -0
- package/public/dashboard/assets/eb83d8d40af4411f-Buze_B52.woff2 +0 -0
- package/public/dashboard/assets/effc6711249e7349-qRpaaN48.woff2 +0 -0
- package/public/dashboard/assets/gateway-BDYet0pI.css +1 -0
- package/public/dashboard/assets/gateway-BYt6-s1O.js +1 -0
- package/public/dashboard/assets/index-B9wFpD_z.css +2 -0
- package/public/dashboard/assets/index-DWcQmu0_.js +124 -0
- package/public/dashboard/assets/index-Da-j89O-.js +458 -0
- package/public/dashboard/font-licenses/jetbrainsmono-OFL.txt +93 -0
- package/public/dashboard/font-licenses/plusjakartasans-OFL.txt +93 -0
- package/public/dashboard/font-licenses/tajawal-OFL.txt +93 -0
- package/public/dashboard/gateway.html +17 -0
- package/public/dashboard/index.html +3 -5
- package/public/ui-boot.js +33 -14
- package/scheduler.cjs +76 -23
- package/src/auth/auth-storage.cjs +54 -7
- package/src/auth/use-database-auth-state.js +70 -39
- package/src/automation/engine.js +412 -0
- package/src/automation/limits.cjs +6 -0
- package/src/automation/manage.js +290 -0
- package/src/automation/reactions.js +471 -0
- package/src/automation/rules.cjs +114 -0
- package/src/automation/status.cjs +76 -0
- package/src/backup/account.cjs +29 -0
- package/src/backup/activation.cjs +247 -0
- package/src/backup/content.cjs +36 -0
- package/src/backup/create.cjs +280 -0
- package/src/backup/extensions.cjs +101 -0
- package/src/backup/format.cjs +565 -0
- package/src/backup/jobs.cjs +111 -0
- package/src/backup/journal.cjs +41 -0
- package/src/backup/plan.cjs +223 -0
- package/src/backup/recovery.cjs +110 -0
- package/src/backup/restore.cjs +460 -0
- package/src/backup/uploads.cjs +146 -0
- package/src/bootstrap/core.js +50 -12
- package/src/bootstrap/panel.js +53 -2
- package/src/bootstrap/session-startup-policy.js +8 -1
- package/src/cli.js +163 -22
- package/src/commands/autodelete.cjs +41 -57
- package/src/commands/autoschedule.cjs +7 -33
- package/src/commands/blacklist.cjs +17 -35
- package/src/commands/block.cjs +4 -18
- package/src/commands/calc.cjs +22 -74
- package/src/commands/debt.cjs +28 -59
- package/src/commands/deleteschedule.cjs +7 -23
- package/src/commands/digit.cjs +5 -39
- package/src/commands/gemini.cjs +135 -218
- package/src/commands/group/add.cjs +28 -76
- package/src/commands/group/all.cjs +4 -15
- package/src/commands/group/antilink.cjs +28 -41
- package/src/commands/group/antispam.cjs +25 -35
- package/src/commands/group/approveall.cjs +7 -21
- package/src/commands/group/clearwarns.cjs +4 -18
- package/src/commands/group/deletenote.cjs +4 -18
- package/src/commands/group/demote.cjs +6 -23
- package/src/commands/group/flagged.cjs +10 -19
- package/src/commands/group/kick.cjs +26 -36
- package/src/commands/group/media.cjs +21 -36
- package/src/commands/group/members.cjs +16 -28
- package/src/commands/group/note.cjs +3 -14
- package/src/commands/group/policy.cjs +16 -37
- package/src/commands/group/promote.cjs +5 -22
- package/src/commands/group/removeall.cjs +6 -38
- package/src/commands/group/rules.cjs +4 -19
- package/src/commands/group/save.cjs +4 -18
- package/src/commands/group/setname.cjs +5 -19
- package/src/commands/group/setpp.cjs +8 -26
- package/src/commands/group/setrules.cjs +4 -15
- package/src/commands/group/setwarn.cjs +6 -23
- package/src/commands/group/tagadmins.cjs +5 -16
- package/src/commands/group/warn.cjs +5 -16
- package/src/commands/group/warns.cjs +12 -33
- package/src/commands/group/welcome.cjs +17 -34
- package/src/commands/group.cjs +91 -68
- package/src/commands/help.cjs +48 -89
- package/src/commands/lang.cjs +38 -97
- package/src/commands/listschedules.cjs +19 -30
- package/src/commands/loop.cjs +9 -55
- package/src/commands/md.cjs +2 -13
- package/src/commands/memory.cjs +53 -87
- package/src/commands/mod.cjs +40 -79
- package/src/commands/notes.cjs +4 -15
- package/src/commands/pack.cjs +26 -49
- package/src/commands/packs.cjs +8 -18
- package/src/commands/perm.cjs +48 -51
- package/src/commands/ping.cjs +2 -10
- package/src/commands/poll.cjs +5 -38
- package/src/commands/prayer.cjs +55 -36
- package/src/commands/qr.cjs +4 -18
- package/src/commands/rand.cjs +9 -58
- package/src/commands/restart.cjs +15 -33
- package/src/commands/schedule.cjs +5 -25
- package/src/commands/score.cjs +6 -27
- package/src/commands/send.cjs +4 -18
- package/src/commands/setprefix.cjs +11 -23
- package/src/commands/shortlink.cjs +13 -39
- package/src/commands/status.cjs +188 -76
- package/src/commands/sticker.cjs +5 -16
- package/src/commands/stickers.cjs +16 -20
- package/src/commands/stopbot.cjs +9 -25
- package/src/commands/stt.cjs +75 -107
- package/src/commands/todo.cjs +11 -31
- package/src/commands/toimage.cjs +11 -27
- package/src/commands/translate.cjs +53 -36
- package/src/commands/tts.cjs +46 -40
- package/src/commands/unblock.cjs +3 -17
- package/src/commands/update.cjs +23 -0
- package/src/commands/weather.cjs +40 -47
- package/src/config/ai-identity.cjs +14 -1
- package/src/config/baileys.config.js +16 -3
- package/src/config/data-dir.cjs +37 -0
- package/src/config/defaults.cjs +1 -0
- package/src/config/exit-codes.cjs +11 -0
- package/src/config/lock.cjs +55 -81
- package/src/config/official-links.cjs +61 -0
- package/src/config/paths.cjs +4 -33
- package/src/config/release.cjs +87 -0
- package/src/config/settings.cjs +199 -10
- package/src/core/connection.js +77 -9
- package/src/core/events.js +119 -33
- package/src/core/session.js +536 -84
- package/src/core/socket.js +81 -10
- package/src/db/copy.cjs +136 -0
- package/src/db/db.cjs +241 -36
- package/src/db/startup-guard.js +5 -0
- package/src/db/store.cjs +561 -54
- package/src/diagnostics/baileysLog.cjs +87 -0
- package/src/diagnostics/debugLog.cjs +16 -4
- package/src/diagnostics/device.cjs +4 -2
- package/src/diagnostics/nodeRuntime.cjs +131 -0
- package/src/diagnostics/signalSessionInspect.cjs +38 -0
- package/src/domain/command.js +24 -22
- package/src/extensions/autoReply.cjs +521 -0
- package/src/extensions/context.cjs +73 -0
- package/src/extensions/contract.cjs +69 -0
- package/src/extensions/entitlement/client.cjs +381 -0
- package/src/extensions/entitlement/index.cjs +629 -0
- package/src/extensions/entitlement/installation.cjs +117 -0
- package/src/extensions/entitlement/keys.cjs +72 -0
- package/src/extensions/entitlement/state.cjs +201 -0
- package/src/extensions/entitlement/target.cjs +7 -0
- package/src/extensions/entitlement/token.cjs +225 -0
- package/src/extensions/host.cjs +519 -0
- package/src/extensions/templateKeys.cjs +81 -0
- package/src/handlers/command.handler.js +191 -64
- package/src/handlers/group.handler.js +78 -18
- package/src/handlers/message.handler.js +56 -25
- package/src/i18n/catalog.generated.cjs +3537 -0
- package/src/index.js +51 -12
- package/src/legal/bundled/ar.json +102 -0
- package/src/legal/bundled/en.json +102 -0
- package/src/legal/bundled/es-419.json +102 -0
- package/src/legal/bundled/pt-BR.json +102 -0
- package/src/legal/cli.cjs +200 -0
- package/src/legal/consent.cjs +187 -0
- package/src/legal/document.cjs +156 -0
- package/src/legal/keys.cjs +100 -0
- package/src/legal/release.cjs +226 -0
- package/src/legal/remote.cjs +419 -0
- package/src/legal/terms.cjs +142 -0
- package/src/messaging/escape.cjs +31 -0
- package/src/messaging/health.cjs +65 -0
- package/src/messaging/identity.cjs +42 -0
- package/src/messaging/message.cjs +136 -0
- package/src/messaging/parser.cjs +88 -0
- package/src/messaging/router.cjs +217 -0
- package/src/middleware/permissions.middleware.js +34 -2
- package/src/panel/account-profile.cjs +489 -0
- package/src/panel/fallback-page.cjs +177 -0
- package/src/panel/password-reset.cjs +13 -14
- package/src/panel/recovery-email.cjs +3 -1
- package/src/routes/backup.api.esm.js +175 -0
- package/src/routes/dashboard.api.esm.js +183 -7
- package/src/routes/plus.api.esm.js +172 -0
- package/src/routes/reactions.api.esm.js +60 -0
- package/src/services/aiAgent.cjs +56 -43
- package/src/services/aiDocs.cjs +187 -0
- package/src/services/aiImage.cjs +183 -0
- package/src/services/aiMedia.cjs +146 -0
- package/src/services/aiProviders.cjs +76 -80
- package/src/services/aiRouter.cjs +2 -2
- package/src/services/aiToolAuth.cjs +76 -4
- package/src/services/aiTools.cjs +431 -105
- package/src/services/autoDelete.cjs +9 -1
- package/src/services/levix-docs.generated.json +2623 -0
- package/src/services/memoryPolicy.cjs +56 -0
- package/src/services/updateCheck.cjs +362 -0
- package/src/stickers/errors.cjs +53 -97
- package/src/stickers/library.cjs +13 -6
- package/src/stickers/owner.cjs +1 -1
- package/src/utils/commandContext.cjs +13 -0
- package/src/utils/commandDocs.cjs +42 -20
- package/src/utils/geminiHttpOptions.cjs +56 -0
- package/src/utils/geminiMedia.cjs +28 -3
- package/src/utils/groupMetadataCache.cjs +386 -21
- package/src/utils/httpsFetch.cjs +113 -0
- package/src/utils/i18n.cjs +117 -7
- package/src/utils/linkPreview.cjs +90 -0
- package/src/utils/logger.cjs +6 -0
- package/src/utils/markdownParser.cjs +3 -3
- package/src/utils/memory.cjs +375 -28
- package/src/utils/messageContent.cjs +7 -1
- package/src/utils/moderationAction.cjs +116 -73
- package/src/utils/moderationSummary.cjs +32 -56
- package/src/utils/permissionLevel.cjs +7 -28
- package/src/utils/permissions.cjs +23 -14
- package/src/utils/permissions.esm.js +99 -166
- package/src/utils/recentMessageCache.esm.js +241 -37
- package/src/utils/recurrence.cjs +78 -66
- package/src/utils/sendBotMessage.cjs +14 -29
- package/src/utils/sendBotMessage.esm.js +28 -13
- package/src/utils/statusMessage.cjs +94 -33
- package/src/utils/stickerBot.cjs +18 -16
- package/src/utils/storage.cjs +2 -0
- package/src/utils/storage.esm.js +2 -0
- package/src/utils/thumbnail.cjs +5 -21
- package/public/dashboard/assets/index-B1sOW2VX.js +0 -561
- package/public/dashboard/assets/index-CK8osB4o.css +0 -2
- package/public/dashboard.css +0 -3127
- package/public/dashboard.js +0 -1981
- package/public/gateway-i18n.js +0 -321
- package/public/gateway.js +0 -70
- package/views/dashboard.ejs +0 -775
- package/views/login.ejs +0 -408
- package/views/qr.ejs +0 -155
- package/views/setup.ejs +0 -118
|
@@ -4,8 +4,7 @@ import { checkBlacklist } from "../middleware/blacklist.middleware.js";
|
|
|
4
4
|
import { trackForwardedMessage } from "../middleware/forward-tracking.middleware.js";
|
|
5
5
|
import normalizeJid from "../utils/normalizeJid.esm.js";
|
|
6
6
|
import { getSenderCandidates, isBotAdminInGroup, sameUser } from "../utils/permissions.esm.js";
|
|
7
|
-
import {
|
|
8
|
-
import { saveUserMetadata, updateUserLastSeen } from "../utils/storage.esm.js";
|
|
7
|
+
import { accountEpoch, saveUserMetadata, updateUserLastSeen } from "../utils/storage.esm.js";
|
|
9
8
|
import { handleCommand } from "./command.handler.js";
|
|
10
9
|
|
|
11
10
|
const require = createRequire(import.meta.url);
|
|
@@ -54,15 +53,12 @@ export async function handleIncomingMessage(sock, m) {
|
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
// Baileys' getMessage hook needs to hand back messages WE sent when a peer
|
|
58
|
-
// asks for a retry (see utils/recentMessageCache.esm.js). Only our own
|
|
59
|
-
// outgoing messages are kept, in memory, and only for that purpose.
|
|
60
|
-
if (msg.key?.fromMe && msg.key.id && msg.message) {
|
|
61
|
-
rememberMessage(msg.key.id, msg);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
56
|
if (!hasUserContent(msg.message)) return;
|
|
65
57
|
|
|
58
|
+
// Captured before the first await. A later unlink, logout or activation
|
|
59
|
+
// advances the epoch and the metadata write below is skipped.
|
|
60
|
+
const epoch = accountEpoch();
|
|
61
|
+
|
|
66
62
|
// Track forwarded messages
|
|
67
63
|
await trackForwardedMessage(msg);
|
|
68
64
|
|
|
@@ -96,25 +92,29 @@ export async function handleIncomingMessage(sock, m) {
|
|
|
96
92
|
// Everything the bot says about this message — a moderation warning, a
|
|
97
93
|
// command's reply — goes out in one language (see utils/i18n.cjs). A
|
|
98
94
|
// command narrows this down to its own arguments.
|
|
99
|
-
return withLang(detectLang(body), () => processMessage(sock, msg, body));
|
|
95
|
+
return withLang(detectLang(body), () => processMessage(sock, msg, body, epoch));
|
|
100
96
|
}
|
|
101
97
|
|
|
102
|
-
async function processMessage(sock, msg, body) {
|
|
98
|
+
export async function processMessage(sock, msg, body, epoch) {
|
|
103
99
|
const isGroup = msg.key.remoteJid.endsWith("@g.us");
|
|
104
100
|
|
|
105
101
|
// Update user metadata (last seen)
|
|
106
102
|
const senderId = normalizeJid(msg.key.participant || msg.key.remoteJid);
|
|
107
103
|
if (senderId && !senderId.includes("@broadcast") && !senderId.includes("@newsletter")) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
104
|
+
if (accountEpoch() !== epoch) {
|
|
105
|
+
logger.debug("[Message] skipped account metadata write after account change");
|
|
106
|
+
} else {
|
|
107
|
+
try {
|
|
108
|
+
saveUserMetadata({
|
|
109
|
+
jid: senderId,
|
|
110
|
+
lid: null,
|
|
111
|
+
phone: senderId.split("@")[0],
|
|
112
|
+
displayName: msg.pushName || null,
|
|
113
|
+
});
|
|
114
|
+
updateUserLastSeen(senderId);
|
|
115
|
+
} catch (err) {
|
|
116
|
+
logger.error({ err }, "Failed to update user metadata");
|
|
117
|
+
}
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
|
|
@@ -123,9 +123,17 @@ async function processMessage(sock, msg, body) {
|
|
|
123
123
|
if (isBlacklisted) return;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
// The epoch from message entry is this message's account lifetime. A command
|
|
127
|
+
// or a moderation pass that samples accountEpoch() later would otherwise act
|
|
128
|
+
// for the account that paired while this message was still in flight.
|
|
129
|
+
if (accountEpoch() !== epoch) {
|
|
130
|
+
logger.debug("[Message] skipped account work after account change");
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
126
134
|
// Try to handle as command
|
|
127
135
|
try {
|
|
128
|
-
const wasCommand = await handleCommand(sock, msg, body);
|
|
136
|
+
const wasCommand = await handleCommand(sock, msg, body, epoch);
|
|
129
137
|
if (wasCommand) {
|
|
130
138
|
const text = typeof body === "string" ? body : "";
|
|
131
139
|
const command = text.trim().split(/\s+/, 1)[0] || "";
|
|
@@ -140,15 +148,33 @@ async function processMessage(sock, msg, body) {
|
|
|
140
148
|
}
|
|
141
149
|
|
|
142
150
|
// Handle regular group messages (moderation)
|
|
151
|
+
let moderationActed = false;
|
|
143
152
|
if (isGroup) {
|
|
144
|
-
|
|
153
|
+
if (accountEpoch() !== epoch) {
|
|
154
|
+
logger.debug("[Message] skipped account work after account change");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const result = await handleGroupModeration(sock, msg, epoch);
|
|
158
|
+
moderationActed = Boolean(result?.acted);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
if (!moderationActed) {
|
|
162
|
+
try {
|
|
163
|
+
const { host } = require("../extensions/host.cjs");
|
|
164
|
+
const pending = host.dispatchAutoReply(sock, msg, epoch);
|
|
165
|
+
if (pending && typeof pending.catch === "function") {
|
|
166
|
+
pending.catch((error) => logger.error({ err: error }, "auto-reply dispatch failed"));
|
|
167
|
+
}
|
|
168
|
+
} catch (error) {
|
|
169
|
+
logger.error({ err: error }, "auto-reply dispatch failed");
|
|
170
|
+
}
|
|
145
171
|
}
|
|
146
172
|
}
|
|
147
173
|
|
|
148
174
|
// One message, one decision. Detectors only report hits; enforceHits applies
|
|
149
175
|
// them. A missing id is refused here so a live redelivery cannot be guessed.
|
|
150
176
|
// Direct detector calls used by older tests still enforce without an id.
|
|
151
|
-
export async function handleGroupModeration(sock, msg) {
|
|
177
|
+
export async function handleGroupModeration(sock, msg, accountEpoch) {
|
|
152
178
|
try {
|
|
153
179
|
if (!msg?.key?.id) {
|
|
154
180
|
logger.warn(
|
|
@@ -192,7 +218,12 @@ export async function handleGroupModeration(sock, msg) {
|
|
|
192
218
|
logger.error({ err: error, detector: "spam" }, "moderation detector failed");
|
|
193
219
|
}
|
|
194
220
|
if (!hits.length) return;
|
|
195
|
-
return await enforceHits(sock, {
|
|
221
|
+
return await enforceHits(sock, {
|
|
222
|
+
msg,
|
|
223
|
+
groupMetadata,
|
|
224
|
+
hits,
|
|
225
|
+
...(Number.isInteger(accountEpoch) ? { accountEpoch } : {}),
|
|
226
|
+
});
|
|
196
227
|
} catch (error) {
|
|
197
228
|
logger.error({ err: error }, "Error in group moderation");
|
|
198
229
|
}
|