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
|
@@ -5,18 +5,10 @@ const {
|
|
|
5
5
|
rosterJidForSync,
|
|
6
6
|
} = require("../../utils/permissions.cjs");
|
|
7
7
|
const { targetFromCommand } = require("../../utils/moderationAction.cjs");
|
|
8
|
-
const {
|
|
8
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
name: "demote",
|
|
12
|
-
description: {
|
|
13
|
-
en: "Demotes an admin to a regular member.",
|
|
14
|
-
ar: "يحوّل مشرفًا إلى عضو عادي.",
|
|
15
|
-
},
|
|
16
|
-
usage: {
|
|
17
|
-
en: "demote @member",
|
|
18
|
-
ar: "demote @عضو",
|
|
19
|
-
},
|
|
20
12
|
chat: "group",
|
|
21
13
|
userAdminRequired: true,
|
|
22
14
|
botAdminRequired: true,
|
|
@@ -28,10 +20,7 @@ module.exports = {
|
|
|
28
20
|
|
|
29
21
|
if (!targetJid) {
|
|
30
22
|
return await sock.sendMessage(groupId, {
|
|
31
|
-
text:
|
|
32
|
-
"Mention the admin, or reply to their message, to demote them.",
|
|
33
|
-
"يجب عمل منشن للمشرف أو الرد على رسالته لعزله.",
|
|
34
|
-
),
|
|
23
|
+
text: t("bot.group.demote.noTarget"),
|
|
35
24
|
});
|
|
36
25
|
}
|
|
37
26
|
|
|
@@ -40,33 +29,27 @@ module.exports = {
|
|
|
40
29
|
|
|
41
30
|
if (!targetUser || !targetUser.admin) {
|
|
42
31
|
return await sock.sendMessage(groupId, {
|
|
43
|
-
text:
|
|
44
|
-
`⚠️ @${targetJid.split("@")[0]} isn't an admin.`,
|
|
45
|
-
`⚠️ العضو @${targetJid.split("@")[0]} ليس مشرفًا بالفعل.`,
|
|
46
|
-
),
|
|
32
|
+
text: t("bot.group.demote.notAdmin", { number: targetJid.split("@")[0] }),
|
|
47
33
|
mentions: [targetJid],
|
|
48
34
|
});
|
|
49
35
|
}
|
|
50
36
|
|
|
51
37
|
if (targetUser.admin === "superadmin") {
|
|
52
38
|
return await sock.sendMessage(groupId, {
|
|
53
|
-
text:
|
|
39
|
+
text: t("bot.group.demote.creator"),
|
|
54
40
|
});
|
|
55
41
|
}
|
|
56
42
|
|
|
57
43
|
try {
|
|
58
44
|
await sock.groupParticipantsUpdate(groupId, [rosterJid], "demote");
|
|
59
45
|
await sock.sendMessage(groupId, {
|
|
60
|
-
text:
|
|
61
|
-
`👤 @${targetJid.split("@")[0]} is no longer an admin.`,
|
|
62
|
-
`👤 تم عزل @${targetJid.split("@")[0]} من الإشراف.`,
|
|
63
|
-
),
|
|
46
|
+
text: t("bot.group.demote.done", { number: targetJid.split("@")[0] }),
|
|
64
47
|
mentions: [targetJid],
|
|
65
48
|
});
|
|
66
49
|
} catch (error) {
|
|
67
50
|
logger.error({ err: error, command: "demote" }, "Error in !demote command");
|
|
68
51
|
await sock.sendMessage(groupId, {
|
|
69
|
-
text:
|
|
52
|
+
text: t("bot.group.demote.failed"),
|
|
70
53
|
});
|
|
71
54
|
}
|
|
72
55
|
},
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
const { listModerationFlags } = require("../../utils/storage.cjs");
|
|
2
2
|
const logger = require("../../utils/logger.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
name: "flagged",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Lists members waiting for admin review.",
|
|
9
|
-
ar: "يعرض الأعضاء بانتظار مراجعة المشرف.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "flagged",
|
|
13
|
-
ar: "flagged",
|
|
14
|
-
},
|
|
15
7
|
chat: "group",
|
|
16
8
|
userAdminRequired: true,
|
|
17
9
|
|
|
@@ -21,31 +13,30 @@ module.exports = {
|
|
|
21
13
|
const flags = listModerationFlags(groupId);
|
|
22
14
|
if (!flags.length) {
|
|
23
15
|
return await sock.sendMessage(groupId, {
|
|
24
|
-
text:
|
|
16
|
+
text: t("bot.moderation.flagged.noMembersAreWaitingFor"),
|
|
25
17
|
});
|
|
26
18
|
}
|
|
27
19
|
const mentions = flags.map((row) => row.user_id);
|
|
28
20
|
const lines = [
|
|
29
|
-
|
|
30
|
-
`*Flagged members* (${flags.length})`,
|
|
31
|
-
`*الأعضاء المعلَّمون للمراجعة* (${flags.length})`,
|
|
32
|
-
),
|
|
21
|
+
t("bot.moderation.flagged.flaggedMembers", { count: flags.length }),
|
|
33
22
|
];
|
|
34
23
|
for (const row of flags) {
|
|
35
24
|
const tag = `@${String(row.user_id).split("@")[0]}`;
|
|
36
25
|
const when = row.flagged_at ? new Date(row.flagged_at).toISOString() : "";
|
|
37
26
|
lines.push(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
t("bot.moderation.flagged.line", {
|
|
28
|
+
tag,
|
|
29
|
+
count: row.warn_count,
|
|
30
|
+
rule: row.last_rule || "—",
|
|
31
|
+
when: when ? t("bot.moderation.flagged.when", { when }) : "",
|
|
32
|
+
}),
|
|
42
33
|
);
|
|
43
34
|
}
|
|
44
35
|
await sock.sendMessage(groupId, { text: lines.join("\n"), mentions });
|
|
45
36
|
} catch (error) {
|
|
46
37
|
logger.error({ err: error }, "Error in !flagged command");
|
|
47
38
|
await sock.sendMessage(groupId, {
|
|
48
|
-
text:
|
|
39
|
+
text: t("bot.moderation.flagged.somethingWentWrongWhileListing"),
|
|
49
40
|
});
|
|
50
41
|
}
|
|
51
42
|
},
|
|
@@ -5,34 +5,26 @@ const {
|
|
|
5
5
|
isAdminInGroupSync,
|
|
6
6
|
sameUserSync,
|
|
7
7
|
} = require("../../utils/permissions.cjs");
|
|
8
|
-
const
|
|
9
|
-
const {
|
|
8
|
+
const moderationAction = require("../../utils/moderationAction.cjs");
|
|
9
|
+
const { senderCandidates, targetFromCommand } = moderationAction;
|
|
10
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
name: "kick",
|
|
13
|
-
description: {
|
|
14
|
-
en: "Removes a member from the group.",
|
|
15
|
-
ar: "يطرد عضوًا من المجموعة.",
|
|
16
|
-
},
|
|
17
|
-
usage: {
|
|
18
|
-
en: "kick @member [reason]",
|
|
19
|
-
ar: "kick @عضو [السبب]",
|
|
20
|
-
},
|
|
21
14
|
chat: "group",
|
|
22
15
|
userAdminRequired: true,
|
|
23
16
|
botAdminRequired: true,
|
|
24
17
|
|
|
25
|
-
|
|
18
|
+
// Direct `!kick` has no `ctx.nested`. `!group kick` sets `nested: true`.
|
|
19
|
+
// The re-check below uses the gate that admitted this call.
|
|
20
|
+
async execute(sock, msg, args, body, groupMetadata, ctx) {
|
|
26
21
|
const groupId = msg.key.remoteJid;
|
|
27
22
|
const target = targetFromCommand(msg);
|
|
28
23
|
const targetJid = target?.jid;
|
|
29
24
|
|
|
30
25
|
if (!targetJid) {
|
|
31
26
|
return await sock.sendMessage(groupId, {
|
|
32
|
-
text:
|
|
33
|
-
"Mention the member, or reply to their message, to kick them.",
|
|
34
|
-
"يجب عمل منشن للعضو أو الرد على رسالته لطرده.",
|
|
35
|
-
),
|
|
27
|
+
text: t("bot.group.kick.noTarget"),
|
|
36
28
|
});
|
|
37
29
|
}
|
|
38
30
|
const targetCandidates = target.candidates;
|
|
@@ -44,37 +36,35 @@ module.exports = {
|
|
|
44
36
|
.filter(Boolean)
|
|
45
37
|
.some((id) => targetCandidates.some((candidate) => sameUserSync(id, candidate)))
|
|
46
38
|
) {
|
|
47
|
-
return await sock.sendMessage(groupId, { text:
|
|
39
|
+
return await sock.sendMessage(groupId, { text: t("bot.group.kick.self") });
|
|
48
40
|
}
|
|
49
41
|
|
|
50
42
|
// Bot owners/admins are privileged across chats and cannot be removed by
|
|
51
43
|
// a group-only admin through an alternate LID/PN representation.
|
|
52
|
-
if (targetCandidates.some((candidate) => hasBotPrivilegesSync(candidate))) {
|
|
44
|
+
if (targetCandidates.some((candidate) => hasBotPrivilegesSync(candidate, groupMetadata))) {
|
|
53
45
|
return await sock.sendMessage(groupId, {
|
|
54
|
-
text:
|
|
46
|
+
text: t("bot.group.kick.botPrivileged"),
|
|
55
47
|
});
|
|
56
48
|
}
|
|
57
49
|
|
|
58
50
|
// Check if the target is also an admin
|
|
59
51
|
if (targetCandidates.some((candidate) => isAdminInGroupSync(groupMetadata, candidate))) {
|
|
60
52
|
return await sock.sendMessage(groupId, {
|
|
61
|
-
text:
|
|
53
|
+
text: t("bot.group.kick.targetIsAdmin"),
|
|
62
54
|
});
|
|
63
55
|
}
|
|
64
56
|
|
|
65
57
|
// --- Execution ---
|
|
66
58
|
try {
|
|
67
|
-
const reason = args.slice(1).join(" ") ||
|
|
59
|
+
const reason = args.slice(1).join(" ") || t("bot.group.kick.noReason");
|
|
68
60
|
const senderName = msg.pushName;
|
|
69
61
|
const member = `@${targetJid.split("@")[0]}`;
|
|
70
62
|
|
|
71
|
-
const kickMessage =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`*السبب:* ${reason}`,
|
|
77
|
-
);
|
|
63
|
+
const kickMessage = t("bot.group.kick.announcement", {
|
|
64
|
+
sender: senderName,
|
|
65
|
+
member,
|
|
66
|
+
reason,
|
|
67
|
+
});
|
|
78
68
|
|
|
79
69
|
// Announce the kick before performing it
|
|
80
70
|
await sock.sendMessage(groupId, {
|
|
@@ -82,26 +72,26 @@ module.exports = {
|
|
|
82
72
|
mentions: [targetJid],
|
|
83
73
|
});
|
|
84
74
|
|
|
85
|
-
|
|
75
|
+
// The announcement above awaited, so the roster may have changed: the
|
|
76
|
+
// requester is re-checked on a fresh roster, as the dispatcher checked it.
|
|
77
|
+
const result = await moderationAction.kickGroupMember(sock, {
|
|
86
78
|
groupId,
|
|
87
79
|
groupMetadata,
|
|
88
80
|
targetCandidates,
|
|
81
|
+
requesterCandidates: senderCandidates(msg, sock),
|
|
82
|
+
requesterFromMe: Boolean(msg.key?.fromMe),
|
|
83
|
+
requesterRule: ctx?.nested === true ? "nested" : "direct",
|
|
84
|
+
accountEpoch: ctx?.accountEpoch,
|
|
89
85
|
});
|
|
90
86
|
if (!result.kicked) {
|
|
91
87
|
await sock.sendMessage(groupId, {
|
|
92
|
-
text:
|
|
93
|
-
"Something went wrong while kicking the member. I may not have enough permissions.",
|
|
94
|
-
"حدث خطأ أثناء محاولة طرد العضو. قد تكون صلاحياتي غير كافية.",
|
|
95
|
-
),
|
|
88
|
+
text: t("bot.group.kick.failed"),
|
|
96
89
|
});
|
|
97
90
|
}
|
|
98
91
|
} catch (error) {
|
|
99
92
|
logger.error({ err: error, command: "kick" }, "Error in !kick command");
|
|
100
93
|
await sock.sendMessage(groupId, {
|
|
101
|
-
text:
|
|
102
|
-
"Something went wrong while kicking the member. I may not have enough permissions.",
|
|
103
|
-
"حدث خطأ أثناء محاولة طرد العضو. قد تكون صلاحياتي غير كافية.",
|
|
104
|
-
),
|
|
94
|
+
text: t("bot.group.kick.failed"),
|
|
105
95
|
});
|
|
106
96
|
}
|
|
107
97
|
},
|
|
@@ -10,22 +10,22 @@ const {
|
|
|
10
10
|
normalizeFeatureAction,
|
|
11
11
|
policyFromFeatureAction,
|
|
12
12
|
} = require("../../utils/moderationSummary.cjs");
|
|
13
|
-
const {
|
|
13
|
+
const { t, currentLang } = require("../../utils/i18n.cjs");
|
|
14
14
|
const { applyModerationPolicy } = require("../../services/moderationPolicy.cjs");
|
|
15
15
|
|
|
16
16
|
const VALID_TYPES = ["image", "video", "sticker", "audio"];
|
|
17
17
|
|
|
18
|
+
// The validator's detail is English only. Other languages get a generic line.
|
|
19
|
+
// A catalog value of "{detail}" is rejected: placeholder sets must match.
|
|
20
|
+
function actionNotAllowed(error) {
|
|
21
|
+
const generic = t("bot.moderation.actionNotAllowed");
|
|
22
|
+
const detail = error.errors?.[0]?.message;
|
|
23
|
+
return currentLang() === "en" ? detail || generic : generic;
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
// --- The Main Command Logic ---
|
|
19
27
|
const command = {
|
|
20
28
|
name: "media",
|
|
21
|
-
description: {
|
|
22
|
-
en: "Controls which message types are allowed in the group.",
|
|
23
|
-
ar: "يتحكم في أنواع الرسائل المسموح بها في المجموعة.",
|
|
24
|
-
},
|
|
25
|
-
usage: {
|
|
26
|
-
en: "media [status]\nmedia <on|off>\nmedia action <DELETE|WARN|KICK>\nmedia <block|unblock> <image|video|sticker|audio>",
|
|
27
|
-
ar: "media [status]\nmedia <on|off>\nmedia action <DELETE|WARN|KICK>\nmedia <block|unblock> <image|video|sticker|audio>",
|
|
28
|
-
},
|
|
29
29
|
chat: "group",
|
|
30
30
|
userAdminRequired: true,
|
|
31
31
|
|
|
@@ -43,37 +43,31 @@ const command = {
|
|
|
43
43
|
case "on":
|
|
44
44
|
mediaConfig.enabled = true;
|
|
45
45
|
await sock.sendMessage(groupId, {
|
|
46
|
-
text:
|
|
46
|
+
text: t("bot.moderation.media.mediaControlIsOn"),
|
|
47
47
|
});
|
|
48
48
|
break;
|
|
49
49
|
case "off":
|
|
50
50
|
mediaConfig.enabled = false;
|
|
51
51
|
await sock.sendMessage(groupId, {
|
|
52
|
-
text:
|
|
52
|
+
text: t("bot.moderation.media.mediaControlIsOff"),
|
|
53
53
|
});
|
|
54
54
|
break;
|
|
55
55
|
case "action": {
|
|
56
56
|
const action = normalizeFeatureAction(args[1]);
|
|
57
57
|
if (!action) {
|
|
58
58
|
return await sock.sendMessage(groupId, {
|
|
59
|
-
text:
|
|
60
|
-
"Invalid action. Available: `DELETE`, `WARN`, `KICK`",
|
|
61
|
-
"الإجراء غير صالح. الإجراءات المتاحة: `DELETE`, `WARN`, `KICK`",
|
|
62
|
-
),
|
|
59
|
+
text: t("bot.moderation.media.invalidActionAvailableDeleteWarn"),
|
|
63
60
|
});
|
|
64
61
|
}
|
|
65
62
|
try {
|
|
66
63
|
applyModerationPolicy(groupId, { features: { media: action } });
|
|
67
64
|
} catch (error) {
|
|
68
65
|
return await sock.sendMessage(groupId, {
|
|
69
|
-
text:
|
|
70
|
-
error.errors?.[0]?.message || "That action is not allowed.",
|
|
71
|
-
"هذا الإجراء غير مسموح.",
|
|
72
|
-
),
|
|
66
|
+
text: actionNotAllowed(error),
|
|
73
67
|
});
|
|
74
68
|
}
|
|
75
69
|
await sock.sendMessage(groupId, {
|
|
76
|
-
text:
|
|
70
|
+
text: t("bot.moderation.media.mediaActionIsNow", { action }),
|
|
77
71
|
});
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
@@ -81,16 +75,13 @@ const command = {
|
|
|
81
75
|
const typeToBlock = args[1] ? args[1].toLowerCase() : "";
|
|
82
76
|
if (!VALID_TYPES.includes(typeToBlock))
|
|
83
77
|
return await sock.sendMessage(groupId, {
|
|
84
|
-
text:
|
|
85
|
-
`Invalid type. Available types: ${VALID_TYPES.join(", ")}`,
|
|
86
|
-
`نوع غير صالح. الأنواع المتاحة: ${VALID_TYPES.join(", ")}`,
|
|
87
|
-
),
|
|
78
|
+
text: t("bot.moderation.media.invalidTypeAvailableTypes", { types: VALID_TYPES.join(", ") }),
|
|
88
79
|
});
|
|
89
80
|
if (!mediaConfig.blocked_types.includes(typeToBlock)) {
|
|
90
81
|
mediaConfig.blocked_types.push(typeToBlock);
|
|
91
82
|
}
|
|
92
83
|
await sock.sendMessage(groupId, {
|
|
93
|
-
text:
|
|
84
|
+
text: t("bot.moderation.media.isNowBlocked", { typeToBlock }),
|
|
94
85
|
});
|
|
95
86
|
break;
|
|
96
87
|
}
|
|
@@ -98,26 +89,20 @@ const command = {
|
|
|
98
89
|
const typeToUnblock = args[1] ? args[1].toLowerCase() : "";
|
|
99
90
|
if (!typeToUnblock)
|
|
100
91
|
return await sock.sendMessage(groupId, {
|
|
101
|
-
text:
|
|
92
|
+
text: t("bot.moderation.media.sayWhichTypeToUnblock"),
|
|
102
93
|
});
|
|
103
94
|
mediaConfig.blocked_types = mediaConfig.blocked_types.filter((t) => t !== typeToUnblock);
|
|
104
95
|
await sock.sendMessage(groupId, {
|
|
105
|
-
text:
|
|
106
|
-
`☑️ '${typeToUnblock}' is no longer blocked.`,
|
|
107
|
-
`☑️ تم إزالة '${typeToUnblock}' من الأنواع الممنوعة.`,
|
|
108
|
-
),
|
|
96
|
+
text: t("bot.moderation.media.isNoLongerBlocked", { typeToUnblock }),
|
|
109
97
|
});
|
|
110
98
|
break;
|
|
111
99
|
}
|
|
112
100
|
default: {
|
|
113
101
|
// 'status'
|
|
114
|
-
const state = mediaConfig.enabled ?
|
|
115
|
-
const blocked = mediaConfig.blocked_types.join(", ") ||
|
|
102
|
+
const state = mediaConfig.enabled ? t("bot.moderation.media.on") : t("bot.moderation.media.off");
|
|
103
|
+
const blocked = mediaConfig.blocked_types.join(", ") || t("bot.moderation.media.none");
|
|
116
104
|
const action = featureActionOf(settings, "media");
|
|
117
|
-
const statusReply =
|
|
118
|
-
`*Media control:*\n\nState: ${state}\nAction: ${action}\nBlocked types: ${blocked}`,
|
|
119
|
-
`*حالة نظام مراقبة الوسائط:*\n\nالحالة: ${state}\nالإجراء: ${action}\nالأنواع الممنوعة: ${blocked}`,
|
|
120
|
-
);
|
|
105
|
+
const statusReply = t("bot.moderation.media.mediaControlStateActionBlocked", { state, action, blocked });
|
|
121
106
|
await sock.sendMessage(groupId, { text: statusReply });
|
|
122
107
|
}
|
|
123
108
|
}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
// file: /commands/members.js
|
|
2
2
|
const logger = require("../../utils/logger.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
4
|
+
const { createStatus } = require("../../utils/statusMessage.cjs");
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
name: "members",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Lists every member of the group with their number.",
|
|
9
|
-
ar: "يعرض كل أعضاء المجموعة مع أرقامهم.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "members",
|
|
13
|
-
ar: "members",
|
|
14
|
-
},
|
|
15
8
|
chat: "group", // This command only works in groups
|
|
16
9
|
|
|
17
10
|
async execute(sock, msg) {
|
|
11
|
+
let status = null;
|
|
18
12
|
try {
|
|
19
13
|
// Get the group ID from the message
|
|
20
14
|
const groupId = msg.key.remoteJid;
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
text: tr("Fetching the member list...", "جارٍ جلب قائمة الأعضاء..."),
|
|
16
|
+
status = await createStatus(sock, groupId, t("bot.group.members.fetching"), {
|
|
17
|
+
replyTo: msg,
|
|
25
18
|
});
|
|
26
19
|
|
|
27
20
|
// Fetch the group's metadata
|
|
@@ -31,10 +24,7 @@ module.exports = {
|
|
|
31
24
|
// --- Building the reply message ---
|
|
32
25
|
|
|
33
26
|
// Start with a header
|
|
34
|
-
let replyText =
|
|
35
|
-
`*Group members:*\n*Total: ${members.length}*\n\n`,
|
|
36
|
-
`*قائمة أعضاء المجموعة:*\n*العدد الإجمالي: ${members.length}*\n\n`,
|
|
37
|
-
);
|
|
27
|
+
let replyText = t("bot.group.members.header", { count: members.length });
|
|
38
28
|
|
|
39
29
|
// Create an array of JIDs for the mentions property
|
|
40
30
|
const mentions = [];
|
|
@@ -49,25 +39,23 @@ module.exports = {
|
|
|
49
39
|
|
|
50
40
|
// Add the formatted line to our reply text
|
|
51
41
|
// Using @ will create a "mention link" in the WhatsApp message
|
|
52
|
-
replyText += `${index + 1}. @${phone}${isAdmin ?
|
|
42
|
+
replyText += `${index + 1}. @${phone}${isAdmin ? t("bot.group.members.adminBadge") : ""}\n`;
|
|
53
43
|
|
|
54
44
|
// Add the member's JID to the mentions array
|
|
55
45
|
mentions.push(member.id);
|
|
56
46
|
});
|
|
57
47
|
|
|
58
|
-
//
|
|
59
|
-
await
|
|
60
|
-
text: replyText,
|
|
61
|
-
mentions: mentions, // This makes the @ tags clickable
|
|
62
|
-
});
|
|
48
|
+
// Rewrite the progress line. Mentions stay on the same message.
|
|
49
|
+
await status.finish(replyText, { mentions });
|
|
63
50
|
} catch (error) {
|
|
64
51
|
logger.error(error, "[Error] in !members command:");
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
const failed = t("bot.group.members.failed");
|
|
53
|
+
if (status) await status.finish(failed);
|
|
54
|
+
else {
|
|
55
|
+
await sock.sendMessage(msg.key.remoteJid, {
|
|
56
|
+
text: failed,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
71
59
|
}
|
|
72
60
|
},
|
|
73
61
|
};
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
// file: /commands/note.js
|
|
2
2
|
const { getAllNotes, getNote } = require("../../utils/storage.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
name: "note",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Shows a saved note.",
|
|
9
|
-
ar: "يعرض ملاحظة محفوظة.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "note #keyword",
|
|
13
|
-
ar: "note #الكلمة-المفتاحية",
|
|
14
|
-
},
|
|
15
7
|
chat: "all",
|
|
16
8
|
|
|
17
9
|
async execute(sock, msg, args) {
|
|
@@ -20,7 +12,7 @@ module.exports = {
|
|
|
20
12
|
|
|
21
13
|
if (!keywordArg || !keywordArg.startsWith("#")) {
|
|
22
14
|
return await sock.sendMessage(groupId, {
|
|
23
|
-
text:
|
|
15
|
+
text: t("bot.group.note.usageHint"),
|
|
24
16
|
});
|
|
25
17
|
}
|
|
26
18
|
|
|
@@ -32,10 +24,7 @@ module.exports = {
|
|
|
32
24
|
await sock.sendMessage(groupId, { text: noteText });
|
|
33
25
|
} else {
|
|
34
26
|
await sock.sendMessage(groupId, {
|
|
35
|
-
text:
|
|
36
|
-
`⚠️ No note has the keyword \`${keywordArg}\`\n\nTo see every note, use: \`!notes\``,
|
|
37
|
-
`⚠️ لم يتم العثور على ملاحظة بالكلمة المفتاحية: \`${keywordArg}\`\n\nلعرض كل الملاحظات، استخدم: \`!notes\``,
|
|
38
|
-
),
|
|
27
|
+
text: t("bot.group.note.notFound", { keyword: keywordArg }),
|
|
39
28
|
});
|
|
40
29
|
}
|
|
41
30
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { getGroupSettings } = require("../../utils/storage.cjs");
|
|
2
2
|
const { buildModerationSummary } = require("../../utils/moderationSummary.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t, currentLang } = require("../../utils/i18n.cjs");
|
|
4
4
|
const {
|
|
5
5
|
applyModerationPolicy,
|
|
6
6
|
applyModerationPreset,
|
|
@@ -66,29 +66,28 @@ function assignPath(patch, path, value) {
|
|
|
66
66
|
function allowedReply(sock, groupId, allowed) {
|
|
67
67
|
const list = allowed.join(", ");
|
|
68
68
|
return sock.sendMessage(groupId, {
|
|
69
|
-
text:
|
|
69
|
+
text: t("bot.moderation.policy.invalidValueAvailable", { list }),
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
function rangeReply(sock, groupId, min, max) {
|
|
74
74
|
return sock.sendMessage(groupId, {
|
|
75
|
-
text:
|
|
76
|
-
`Give a whole number from ${min} to ${max}.`,
|
|
77
|
-
`يرجى تحديد عدد صحيح من ${min} إلى ${max}.`,
|
|
78
|
-
),
|
|
75
|
+
text: t("bot.moderation.policy.giveAWholeNumberFrom", { min, max }),
|
|
79
76
|
});
|
|
80
77
|
}
|
|
81
78
|
|
|
82
79
|
function policyErrorReply(sock, groupId, error) {
|
|
83
80
|
const item = error?.errors?.[0];
|
|
81
|
+
// The validator's detail is English only. Other languages get a generic line.
|
|
82
|
+
// A catalog value of "{detail}" is rejected: placeholder sets must match.
|
|
84
83
|
if (item?.code === "conflict") {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
84
|
+
const text =
|
|
85
|
+
currentLang() === "en" ? item.message : t("bot.moderation.policy.conflictGeneric");
|
|
86
|
+
return sock.sendMessage(groupId, { text });
|
|
88
87
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
88
|
+
const generic = t("bot.moderation.policy.valueNotAllowed");
|
|
89
|
+
const text = currentLang() === "en" ? item?.message || generic : generic;
|
|
90
|
+
return sock.sendMessage(groupId, { text });
|
|
92
91
|
}
|
|
93
92
|
|
|
94
93
|
function parsePatch(field, raw) {
|
|
@@ -136,14 +135,6 @@ function parsePatch(field, raw) {
|
|
|
136
135
|
|
|
137
136
|
module.exports = {
|
|
138
137
|
name: "policy",
|
|
139
|
-
description: {
|
|
140
|
-
en: "Shows and changes this group's moderation policy.",
|
|
141
|
-
ar: "يعرض سياسة إشراف المجموعة ويغيّرها.",
|
|
142
|
-
},
|
|
143
|
-
usage: {
|
|
144
|
-
en: "policy\npolicy set <field> <value>\npolicy reset",
|
|
145
|
-
ar: "policy\npolicy set <حقل> <قيمة>\npolicy reset",
|
|
146
|
-
},
|
|
147
138
|
chat: "group",
|
|
148
139
|
userAdminRequired: true,
|
|
149
140
|
|
|
@@ -163,19 +154,13 @@ module.exports = {
|
|
|
163
154
|
return policyErrorReply(sock, groupId, error);
|
|
164
155
|
}
|
|
165
156
|
return sock.sendMessage(groupId, {
|
|
166
|
-
text:
|
|
167
|
-
"✅ Moderation policy reset to standard.",
|
|
168
|
-
"✅ تمت إعادة سياسة الإشراف إلى الوضع القياسي.",
|
|
169
|
-
),
|
|
157
|
+
text: t("bot.moderation.policy.moderationPolicyResetToStandard"),
|
|
170
158
|
});
|
|
171
159
|
}
|
|
172
160
|
|
|
173
161
|
if (sub !== "set") {
|
|
174
162
|
return sock.sendMessage(groupId, {
|
|
175
|
-
text:
|
|
176
|
-
"Wrong format. Use:\n`!group policy`\n`!group policy set <field> <value>`\n`!group policy reset`",
|
|
177
|
-
"صيغة غير صحيحة. استخدم:\n`!group policy`\n`!group policy set <field> <value>`\n`!group policy reset`",
|
|
178
|
-
),
|
|
163
|
+
text: t("bot.moderation.policy.wrongFormatUseGroupPolicy"),
|
|
179
164
|
});
|
|
180
165
|
}
|
|
181
166
|
|
|
@@ -183,10 +168,7 @@ module.exports = {
|
|
|
183
168
|
const raw = args.slice(2).join(" ").trim();
|
|
184
169
|
if (!field || !raw) {
|
|
185
170
|
return sock.sendMessage(groupId, {
|
|
186
|
-
text:
|
|
187
|
-
`Name a field and a value. Available: ${FIELD_LIST.join(", ")}`,
|
|
188
|
-
`حدد الحقل والقيمة. المتاح: ${FIELD_LIST.join(", ")}`,
|
|
189
|
-
),
|
|
171
|
+
text: t("bot.moderation.policy.nameAFieldAndA", { fields: FIELD_LIST.join(", ") }),
|
|
190
172
|
});
|
|
191
173
|
}
|
|
192
174
|
|
|
@@ -195,10 +177,7 @@ module.exports = {
|
|
|
195
177
|
if (parsed.error === "range") return rangeReply(sock, groupId, parsed.min, parsed.max);
|
|
196
178
|
if (parsed.error) {
|
|
197
179
|
return sock.sendMessage(groupId, {
|
|
198
|
-
text:
|
|
199
|
-
`Unknown field. Available: ${FIELD_LIST.join(", ")}`,
|
|
200
|
-
`حقل غير معروف. المتاح: ${FIELD_LIST.join(", ")}`,
|
|
201
|
-
),
|
|
180
|
+
text: t("bot.moderation.policy.unknownFieldAvailable", { fields: FIELD_LIST.join(", ") }),
|
|
202
181
|
});
|
|
203
182
|
}
|
|
204
183
|
|
|
@@ -209,7 +188,7 @@ module.exports = {
|
|
|
209
188
|
return policyErrorReply(sock, groupId, error);
|
|
210
189
|
}
|
|
211
190
|
return sock.sendMessage(groupId, {
|
|
212
|
-
text:
|
|
191
|
+
text: t("bot.moderation.policy.isNow", { field, raw }),
|
|
213
192
|
});
|
|
214
193
|
},
|
|
215
194
|
};
|