levix-bot 4.8.0 → 4.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -5
- package/SETUP.md +21 -2
- package/app.cjs +69 -23
- package/package.json +3 -2
- package/public/dashboard/assets/index-B1sOW2VX.js +561 -0
- package/public/dashboard/assets/index-CK8osB4o.css +2 -0
- package/public/dashboard/index.html +2 -2
- package/public/dashboard.css +21 -0
- package/public/dashboard.js +25 -2
- package/public/gateway-i18n.js +26 -0
- package/src/bootstrap/session-startup-policy.js +6 -6
- package/src/commands/group/antilink.cjs +82 -59
- package/src/commands/group/antispam.cjs +112 -0
- package/src/commands/group/clearwarns.cjs +6 -6
- package/src/commands/group/demote.cjs +11 -13
- package/src/commands/group/flagged.cjs +52 -0
- package/src/commands/group/kick.cjs +25 -15
- package/src/commands/group/media.cjs +65 -29
- package/src/commands/group/policy.cjs +215 -0
- package/src/commands/group/promote.cjs +11 -12
- package/src/commands/group/rules.cjs +9 -6
- package/src/commands/group/setwarn.cjs +17 -27
- package/src/commands/group/warn.cjs +13 -63
- package/src/commands/group.cjs +5 -2
- package/src/commands/mod.cjs +101 -26
- package/src/commands/translate.cjs +585 -0
- package/src/config/ai-identity.cjs +53 -1
- package/src/config/ai-persona.md +32 -73
- package/src/config/defaults.cjs +2 -0
- package/src/config/secrets.cjs +71 -3
- package/src/config/settings.cjs +22 -1
- package/src/core/socket.js +4 -5
- package/src/db/db.cjs +66 -0
- package/src/db/store.cjs +264 -16
- package/src/diagnostics/crashReports.cjs +35 -9
- package/src/diagnostics/debugLog.cjs +405 -0
- package/src/handlers/command.handler.js +1 -0
- package/src/handlers/group.handler.js +32 -1
- package/src/handlers/message.handler.js +53 -17
- package/src/middleware/antispam.middleware.js +95 -48
- package/src/panel/feedback.cjs +32 -5
- package/src/panel/one-time-code.cjs +156 -0
- package/src/panel/password-reset.cjs +187 -91
- package/src/panel/recovery-email.cjs +333 -0
- package/src/routes/dashboard.api.esm.js +267 -20
- package/src/services/aiAgent.cjs +25 -3
- package/src/services/moderationPolicy.cjs +895 -0
- package/src/services/settingsTransfer.cjs +4 -2
- package/src/utils/linkedCreds.cjs +22 -0
- package/src/utils/logger.cjs +5 -0
- package/src/utils/moderationAction.cjs +637 -0
- package/src/utils/moderationSummary.cjs +225 -0
- package/src/utils/permissions.cjs +70 -0
- package/src/utils/permissions.esm.js +48 -8
- package/src/utils/storage.cjs +8 -0
- package/src/utils/storage.esm.js +4 -0
- package/views/login.ejs +100 -28
- package/public/dashboard/assets/index-B8E5IYlB.js +0 -540
- package/public/dashboard/assets/index-C5D4wzm4.css +0 -2
- package/src/commands/group/antiSpam.cjs +0 -97
package/src/commands/mod.cjs
CHANGED
|
@@ -4,7 +4,14 @@ const { getGroupSettings, saveGroupSettings } = require("../utils/storage.cjs");
|
|
|
4
4
|
const { isOwnerJidSync, isAdminInGroupSync } = require("../utils/permissions.cjs");
|
|
5
5
|
const { visibleText } = require("../utils/messageContent.cjs");
|
|
6
6
|
const { resolveGroupMetadata } = require("../utils/groupMetadataCache.cjs");
|
|
7
|
+
const { enforceGroupRule, senderCandidates } = require("../utils/moderationAction.cjs");
|
|
8
|
+
const {
|
|
9
|
+
featureActionOf,
|
|
10
|
+
normalizeFeatureAction,
|
|
11
|
+
policyFromFeatureAction,
|
|
12
|
+
} = require("../utils/moderationSummary.cjs");
|
|
7
13
|
const { tr } = require("../utils/i18n.cjs");
|
|
14
|
+
const { applyModerationPolicy } = require("../services/moderationPolicy.cjs");
|
|
8
15
|
|
|
9
16
|
// الهيكل الافتراضي لإعدادات المراقبة
|
|
10
17
|
const defaultModSettings = {
|
|
@@ -55,21 +62,21 @@ module.exports = {
|
|
|
55
62
|
ar: "يتحكم في إعدادات الإشراف على المجموعة.",
|
|
56
63
|
},
|
|
57
64
|
usage: {
|
|
58
|
-
en: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod words <add|remove> <word>\nmod words list",
|
|
59
|
-
ar: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod words <add|remove> <الكلمة>\nmod words list",
|
|
65
|
+
en: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod action <antiLink|forbiddenWords> <DELETE|WARN|KICK>\nmod action antiSpam <WARN|KICK>\nmod words <add|remove> <word>\nmod words list",
|
|
66
|
+
ar: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod action <antiLink|forbiddenWords> <DELETE|WARN|KICK>\nmod action antiSpam <WARN|KICK>\nmod words <add|remove> <الكلمة>\nmod words list",
|
|
60
67
|
},
|
|
61
68
|
chat: "group", // يعمل في الجروبات فقط
|
|
62
69
|
botAdminRequired: false, // لا يتطلب أن يكون البوت مشرفًا لتغيير الإعدادات
|
|
63
70
|
|
|
64
71
|
async execute(sock, msg, args) {
|
|
65
72
|
const groupId = msg.key.remoteJid;
|
|
66
|
-
const
|
|
73
|
+
const senderIds = senderCandidates(msg, sock);
|
|
67
74
|
|
|
68
75
|
// التحقق من صلاحيات المشرف (LID-aware via central module). Owners can
|
|
69
76
|
// also drive moderation settings.
|
|
70
|
-
const groupMetadata = await sock
|
|
71
|
-
const senderIsAdmin = isAdminInGroupSync(groupMetadata,
|
|
72
|
-
const isOwner = msg.key.fromMe || isOwnerJidSync
|
|
77
|
+
const groupMetadata = await resolveGroupMetadata(sock, groupId);
|
|
78
|
+
const senderIsAdmin = senderIds.some((id) => isAdminInGroupSync(groupMetadata, id));
|
|
79
|
+
const isOwner = msg.key.fromMe || senderIds.some(isOwnerJidSync);
|
|
73
80
|
if (!senderIsAdmin && !isOwner) {
|
|
74
81
|
return sock.sendMessage(
|
|
75
82
|
groupId,
|
|
@@ -130,13 +137,73 @@ module.exports = {
|
|
|
130
137
|
);
|
|
131
138
|
break;
|
|
132
139
|
|
|
140
|
+
case "action": {
|
|
141
|
+
if (!feature) {
|
|
142
|
+
return sock.sendMessage(
|
|
143
|
+
groupId,
|
|
144
|
+
{
|
|
145
|
+
text: tr(
|
|
146
|
+
`⚠️ There is no feature called "${args[1] || ""}".`,
|
|
147
|
+
`⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
|
|
148
|
+
),
|
|
149
|
+
},
|
|
150
|
+
{ quoted: msg },
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
const allowDelete = feature !== "antiSpam";
|
|
154
|
+
const action = normalizeFeatureAction(args[2], { allowDelete });
|
|
155
|
+
if (!action) {
|
|
156
|
+
return sock.sendMessage(
|
|
157
|
+
groupId,
|
|
158
|
+
{
|
|
159
|
+
text: tr(
|
|
160
|
+
allowDelete
|
|
161
|
+
? "Invalid action. Available: `DELETE`, `WARN`, `KICK`"
|
|
162
|
+
: "Invalid action. Available: `WARN`, `KICK`",
|
|
163
|
+
allowDelete
|
|
164
|
+
? "الإجراء غير صالح. الإجراءات المتاحة: `DELETE`, `WARN`, `KICK`"
|
|
165
|
+
: "الإجراء غير صالح. الإجراءات المتاحة: `WARN`, `KICK`",
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
{ quoted: msg },
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
const featureName =
|
|
172
|
+
feature === "antiLink" ? "antilink" : feature === "antiSpam" ? "antispam" : "forbidden";
|
|
173
|
+
try {
|
|
174
|
+
applyModerationPolicy(groupId, { features: { [featureName]: action } });
|
|
175
|
+
} catch (error) {
|
|
176
|
+
return sock.sendMessage(
|
|
177
|
+
groupId,
|
|
178
|
+
{
|
|
179
|
+
text: tr(
|
|
180
|
+
error.errors?.[0]?.message || "That action is not allowed.",
|
|
181
|
+
"هذا الإجراء غير مسموح.",
|
|
182
|
+
),
|
|
183
|
+
},
|
|
184
|
+
{ quoted: msg },
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
await sock.sendMessage(
|
|
188
|
+
groupId,
|
|
189
|
+
{ text: tr(`✅ *${feature}* action is now ${action}.`, `✅ تم تعيين إجراء *${feature}* إلى ${action}.`) },
|
|
190
|
+
{ quoted: msg },
|
|
191
|
+
);
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
|
|
133
195
|
case "status": {
|
|
134
196
|
let statusText = tr("📊 *Moderation settings* 📊\n\n", "📊 *حالة إعدادات المراقبة* 📊\n\n");
|
|
197
|
+
const actionOf = {
|
|
198
|
+
antiLink: featureActionOf(settings, "antilink"),
|
|
199
|
+
antiSpam: featureActionOf(settings, "antispam"),
|
|
200
|
+
forbiddenWords: featureActionOf(settings, "forbidden"),
|
|
201
|
+
};
|
|
135
202
|
for (const key of Object.values(FEATURE_KEYS)) {
|
|
136
203
|
const status = featureEnabled(settings, key)
|
|
137
204
|
? tr("✅ on", "✅ مفعل")
|
|
138
205
|
: tr("❌ off", "❌ معطل");
|
|
139
|
-
statusText += `› *${key}*: ${status}\n`;
|
|
206
|
+
statusText += `› *${key}*: ${status} · ${actionOf[key]}\n`;
|
|
140
207
|
}
|
|
141
208
|
statusText += tr(
|
|
142
209
|
`\n- To see the forbidden words, type: \`!mod words list\``,
|
|
@@ -203,6 +270,7 @@ module.exports = {
|
|
|
203
270
|
"🤖 *Moderation commands*\n\n" +
|
|
204
271
|
"• `!mod enable <feature>`\nTurn a feature on (antilink, antispam, forbiddenwords)\n\n" +
|
|
205
272
|
"• `!mod disable <feature>`\nTurn a feature off.\n\n" +
|
|
273
|
+
"• `!mod action <feature> <DELETE|WARN|KICK>`\nSet the feature action (antiSpam: WARN|KICK).\n\n" +
|
|
206
274
|
"• `!mod status`\nShow which features are on.\n\n" +
|
|
207
275
|
"• `!mod words add <word>`\nAdd a forbidden word.\n\n" +
|
|
208
276
|
"• `!mod words remove <word>`\nRemove a forbidden word.\n\n" +
|
|
@@ -210,6 +278,7 @@ module.exports = {
|
|
|
210
278
|
"🤖 *أوامر التحكم في المراقبة*\n\n" +
|
|
211
279
|
"• `!mod enable <feature>`\nلتفعيل ميزة (antilink, antispam, forbiddenwords)\n\n" +
|
|
212
280
|
"• `!mod disable <feature>`\nلتعطيل ميزة.\n\n" +
|
|
281
|
+
"• `!mod action <feature> <DELETE|WARN|KICK>`\nتعيين إجراء الميزة (antiSpam: WARN|KICK).\n\n" +
|
|
213
282
|
"• `!mod status`\nلعرض حالة الميزات الحالية.\n\n" +
|
|
214
283
|
"• `!mod words add <word>`\nلإضافة كلمة ممنوعة.\n\n" +
|
|
215
284
|
"• `!mod words remove <word>`\nلإزالة كلمة ممنوعة.\n\n" +
|
|
@@ -222,22 +291,24 @@ module.exports = {
|
|
|
222
291
|
},
|
|
223
292
|
};
|
|
224
293
|
|
|
294
|
+
function detectForbiddenWords(msg, settings) {
|
|
295
|
+
const groupId = msg?.key?.remoteJid;
|
|
296
|
+
if (!groupId?.endsWith("@g.us")) return null;
|
|
297
|
+
const config = settings?.moderation?.forbiddenWords;
|
|
298
|
+
if (!config?.enabled || !Array.isArray(config.list) || !config.list.length) return null;
|
|
299
|
+
const body = visibleText(msg.message).toLowerCase();
|
|
300
|
+
if (!body || !config.list.some((word) => word && body.includes(String(word).toLowerCase()))) {
|
|
301
|
+
return null;
|
|
302
|
+
}
|
|
303
|
+
return { rule: "forbidden", reason: "forbidden-word" };
|
|
304
|
+
}
|
|
305
|
+
|
|
225
306
|
async function handleForbiddenWords(sock, msg) {
|
|
226
307
|
const groupId = msg.key.remoteJid;
|
|
227
308
|
if (!groupId?.endsWith("@g.us")) return false;
|
|
228
309
|
|
|
229
310
|
const settings = getGroupSettings(groupId) || {};
|
|
230
|
-
const
|
|
231
|
-
if (!config?.enabled || !Array.isArray(config.list) || !config.list.length) return false;
|
|
232
|
-
|
|
233
|
-
const body = visibleText(msg.message).toLowerCase();
|
|
234
|
-
if (!body || !config.list.some((word) => word && body.includes(String(word).toLowerCase()))) {
|
|
235
|
-
return false;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const senderId = msg.key.participant || msg.key.remoteJid;
|
|
239
|
-
const senderIds = [senderId, msg.key.participantAlt, msg.key.participantPn].filter(Boolean);
|
|
240
|
-
// Cache-first: this runs on every group message while forbidden words are on.
|
|
311
|
+
const senderIds = senderCandidates(msg, sock);
|
|
241
312
|
const groupMetadata = await resolveGroupMetadata(sock, groupId);
|
|
242
313
|
if (
|
|
243
314
|
msg.key.fromMe ||
|
|
@@ -247,15 +318,19 @@ async function handleForbiddenWords(sock, msg) {
|
|
|
247
318
|
return false;
|
|
248
319
|
}
|
|
249
320
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
321
|
+
const hit = detectForbiddenWords(msg, settings);
|
|
322
|
+
if (!hit) return false;
|
|
323
|
+
const policy = policyFromFeatureAction(featureActionOf(settings, "forbidden"));
|
|
324
|
+
const result = await enforceGroupRule(sock, {
|
|
325
|
+
msg,
|
|
326
|
+
groupMetadata,
|
|
327
|
+
rule: "forbidden",
|
|
328
|
+
warningReason: hit.reason,
|
|
329
|
+
...policy,
|
|
330
|
+
targetCandidates: senderIds,
|
|
257
331
|
});
|
|
258
|
-
return
|
|
332
|
+
return Boolean(result.acted);
|
|
259
333
|
}
|
|
260
334
|
|
|
261
335
|
module.exports.handleForbiddenWords = handleForbiddenWords;
|
|
336
|
+
module.exports.detectForbiddenWords = detectForbiddenWords;
|