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
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
// file: /commands/add.js (Upgraded with Invite Fallback)
|
|
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
|
const normalizeJid = require("../../utils/normalizeJid.esm.js").default;
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
7
8
|
name: "add",
|
|
8
|
-
description: {
|
|
9
|
-
en: "Adds a member to the group, or sends an invite if their privacy settings block it.",
|
|
10
|
-
ar: "يضيف عضوًا إلى المجموعة، أو يرسل له دعوة إذا منعت إعدادات الخصوصية إضافته.",
|
|
11
|
-
},
|
|
12
|
-
usage: {
|
|
13
|
-
en: "add [admin] <phone number>",
|
|
14
|
-
ar: "add [admin] <رقم الهاتف>",
|
|
15
|
-
},
|
|
16
9
|
chat: "group",
|
|
17
10
|
userAdminRequired: true,
|
|
18
11
|
botAdminRequired: true,
|
|
19
12
|
|
|
20
13
|
// The full, correct execute function for commands/add.js
|
|
21
14
|
|
|
22
|
-
async execute(sock, msg, args, body, groupMetadata
|
|
15
|
+
async execute(sock, msg, args, body, groupMetadata) {
|
|
23
16
|
const groupId = msg.key.remoteJid;
|
|
24
|
-
const senderId = msg.key.participant; // The admin who is running the command
|
|
25
17
|
let targetJid;
|
|
18
|
+
let statusLine = null;
|
|
26
19
|
let shouldPromote = false;
|
|
27
20
|
|
|
28
21
|
try {
|
|
@@ -60,18 +53,12 @@ module.exports = {
|
|
|
60
53
|
const cleanNumber = numberArg.replace(/\D/g, "");
|
|
61
54
|
if (!cleanNumber)
|
|
62
55
|
return await sock.sendMessage(groupId, {
|
|
63
|
-
text:
|
|
64
|
-
"Give a valid phone number, a mention, or a contact card.",
|
|
65
|
-
"يرجى تقديم رقم هاتف صالح، أو عمل منشن، أو إرسال جهة اتصال.",
|
|
66
|
-
),
|
|
56
|
+
text: t("bot.group.add.invalidNumber"),
|
|
67
57
|
});
|
|
68
58
|
targetJid = `${cleanNumber}@s.whatsapp.net`;
|
|
69
59
|
} else {
|
|
70
60
|
return await sock.sendMessage(groupId, {
|
|
71
|
-
text:
|
|
72
|
-
"To add someone, mention them, send their number, or send their contact card.",
|
|
73
|
-
"لإضافة عضو، قم بعمل منشن له، أو أرسل رقمه، أو أرسل جهة الاتصال الخاصة به.",
|
|
74
|
-
),
|
|
61
|
+
text: t("bot.group.add.usageHint"),
|
|
75
62
|
});
|
|
76
63
|
}
|
|
77
64
|
// --- End of Target Identification Logic ---
|
|
@@ -82,79 +69,44 @@ module.exports = {
|
|
|
82
69
|
);
|
|
83
70
|
if (isAlreadyMember) {
|
|
84
71
|
return await sock.sendMessage(groupId, {
|
|
85
|
-
text:
|
|
86
|
-
`⚠️ @${targetJid.split("@")[0]} is already in the group.`,
|
|
87
|
-
`⚠️ العضو @${targetJid.split("@")[0]} موجود بالفعل في المجموعة.`,
|
|
88
|
-
),
|
|
72
|
+
text: t("bot.group.add.alreadyMember", { number: targetJid.split("@")[0] }),
|
|
89
73
|
mentions: [targetJid],
|
|
90
74
|
});
|
|
91
75
|
}
|
|
92
76
|
|
|
93
|
-
await
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
});
|
|
77
|
+
statusLine = await createStatus(
|
|
78
|
+
sock,
|
|
79
|
+
groupId,
|
|
80
|
+
t("bot.group.add.trying", { number: targetJid.split("@")[0] }),
|
|
81
|
+
{ replyTo: msg, mentions: [targetJid] },
|
|
82
|
+
);
|
|
100
83
|
const response = await sock.groupParticipantsUpdate(groupId, [targetJid], "add");
|
|
101
84
|
const status = response[0].status;
|
|
102
85
|
|
|
103
86
|
if (status === "200") {
|
|
104
|
-
let successMsg =
|
|
105
|
-
`✅ Added @${targetJid.split("@")[0]}.`,
|
|
106
|
-
`✅ تم إضافة @${targetJid.split("@")[0]} بنجاح.`,
|
|
107
|
-
);
|
|
87
|
+
let successMsg = t("bot.group.add.added", { number: targetJid.split("@")[0] });
|
|
108
88
|
if (shouldPromote) {
|
|
109
89
|
await sock.groupParticipantsUpdate(groupId, [targetJid], "promote");
|
|
110
|
-
successMsg +=
|
|
90
|
+
successMsg += t("bot.group.add.madeAdmin");
|
|
111
91
|
}
|
|
112
|
-
await
|
|
113
|
-
text: successMsg,
|
|
114
|
-
mentions: [targetJid],
|
|
115
|
-
});
|
|
92
|
+
await statusLine.finish(successMsg, { mentions: [targetJid] });
|
|
116
93
|
} else if (status === "403") {
|
|
117
|
-
await
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
} can't be added directly because of their privacy settings.\n\nSend them an invite link in private?\nSend \`yes\` to confirm.`,
|
|
122
|
-
`⚠️ لا يمكن إضافة @${
|
|
123
|
-
targetJid.split("@")[0]
|
|
124
|
-
} مباشرة بسبب إعدادات الخصوصية لديه.\n\nهل تود إرسال رابط دعوة له في الخاص؟\nأرسل \`yes\` للتأكيد.`,
|
|
125
|
-
),
|
|
126
|
-
mentions: [targetJid],
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
confirmationSessions.set(senderId, {
|
|
130
|
-
command: "send_invite",
|
|
131
|
-
groupId: groupId,
|
|
132
|
-
targetJid: targetJid,
|
|
133
|
-
adminJid: senderId,
|
|
134
|
-
timestamp: Date.now(),
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
setTimeout(() => {
|
|
138
|
-
if (confirmationSessions.has(senderId)) {
|
|
139
|
-
confirmationSessions.delete(senderId);
|
|
140
|
-
}
|
|
141
|
-
}, 30000);
|
|
94
|
+
await statusLine.finish(
|
|
95
|
+
t("bot.group.add.privacyBlocked", { number: targetJid.split("@")[0] }),
|
|
96
|
+
{ mentions: [targetJid] },
|
|
97
|
+
);
|
|
142
98
|
} else {
|
|
143
|
-
await
|
|
144
|
-
text: tr(
|
|
145
|
-
`⚠️ I couldn't add that number. (status code: ${status})`,
|
|
146
|
-
`⚠️ لم أتمكن من إضافة الرقم. (كود الحالة: ${status})`,
|
|
147
|
-
),
|
|
148
|
-
});
|
|
99
|
+
await statusLine.finish(t("bot.group.add.failedStatus", { status }));
|
|
149
100
|
}
|
|
150
101
|
} catch (error) {
|
|
151
102
|
logger.error({ err: error, command: "add" }, "Error in !add command");
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
103
|
+
const failed = t("bot.group.add.failed");
|
|
104
|
+
if (statusLine) await statusLine.finish(failed);
|
|
105
|
+
else {
|
|
106
|
+
await sock.sendMessage(groupId, {
|
|
107
|
+
text: failed,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
158
110
|
}
|
|
159
111
|
},
|
|
160
112
|
};
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
// file: /commands/all.js
|
|
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: "all",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Mentions every member of the group.",
|
|
9
|
-
ar: "يذكر (منشن) جميع أعضاء المجموعة.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "all [message]",
|
|
13
|
-
ar: "all [رسالة التنبيه]",
|
|
14
|
-
},
|
|
15
7
|
chat: "group",
|
|
16
8
|
|
|
17
9
|
async execute(sock, msg, args) {
|
|
@@ -28,9 +20,9 @@ module.exports = {
|
|
|
28
20
|
|
|
29
21
|
// 7. Prepare the message text and the mentions array
|
|
30
22
|
// You can customize the message text here
|
|
31
|
-
let text =
|
|
23
|
+
let text = t("bot.group.all.default");
|
|
32
24
|
if (args && args.length > 0) {
|
|
33
|
-
text =
|
|
25
|
+
text = t("bot.group.all.header") + args.join(" ");
|
|
34
26
|
}
|
|
35
27
|
|
|
36
28
|
// 8. Send the message with mentions
|
|
@@ -43,10 +35,7 @@ module.exports = {
|
|
|
43
35
|
logger.error(error, "[Error] in !all command:");
|
|
44
36
|
// Send a reply in case of an error
|
|
45
37
|
await sock.sendMessage(msg.key.remoteJid, {
|
|
46
|
-
text:
|
|
47
|
-
"Something went wrong while mentioning everyone.",
|
|
48
|
-
"حدث خطأ أثناء محاولة عمل منشن للجميع.",
|
|
49
|
-
),
|
|
38
|
+
text: t("bot.group.all.failed"),
|
|
50
39
|
});
|
|
51
40
|
}
|
|
52
41
|
},
|
|
@@ -10,20 +10,20 @@ 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
|
+
// The validator's detail is English only. Other languages get a generic line.
|
|
17
|
+
// A catalog value of "{detail}" is rejected: placeholder sets must match.
|
|
18
|
+
function actionNotAllowed(error) {
|
|
19
|
+
const generic = t("bot.moderation.actionNotAllowed");
|
|
20
|
+
const detail = error.errors?.[0]?.message;
|
|
21
|
+
return currentLang() === "en" ? detail || generic : generic;
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
// --- The Main Command Logic ---
|
|
17
25
|
const command = {
|
|
18
26
|
name: "antilink",
|
|
19
|
-
description: {
|
|
20
|
-
en: "Advanced control of the anti-link protection.",
|
|
21
|
-
ar: "تحكم متقدم في ميزة منع الروابط.",
|
|
22
|
-
},
|
|
23
|
-
usage: {
|
|
24
|
-
en: "antilink [status]\nantilink <on|off>\nantilink mode <ALL|WHITELIST|BLACKLIST>\nantilink action <DELETE|WARN|KICK>\nantilink <allow|disallow> <domain>",
|
|
25
|
-
ar: "antilink [status]\nantilink <on|off>\nantilink mode <ALL|WHITELIST|BLACKLIST>\nantilink action <DELETE|WARN|KICK>\nantilink <allow|disallow> <النطاق>",
|
|
26
|
-
},
|
|
27
27
|
chat: "group",
|
|
28
28
|
userAdminRequired: true,
|
|
29
29
|
|
|
@@ -48,28 +48,25 @@ const command = {
|
|
|
48
48
|
case "on":
|
|
49
49
|
antilinkConfig.enabled = true;
|
|
50
50
|
await sock.sendMessage(groupId, {
|
|
51
|
-
text:
|
|
51
|
+
text: t("bot.moderation.antilink.antiLinkIsOn"),
|
|
52
52
|
});
|
|
53
53
|
break;
|
|
54
54
|
case "off":
|
|
55
55
|
antilinkConfig.enabled = false;
|
|
56
56
|
await sock.sendMessage(groupId, {
|
|
57
|
-
text:
|
|
57
|
+
text: t("bot.moderation.antilink.antiLinkIsOff"),
|
|
58
58
|
});
|
|
59
59
|
break;
|
|
60
60
|
case "mode": {
|
|
61
61
|
const mode = args[1] ? args[1].toUpperCase() : "";
|
|
62
62
|
if (!["ALL", "WHITELIST", "BLACKLIST"].includes(mode)) {
|
|
63
63
|
return await sock.sendMessage(groupId, {
|
|
64
|
-
text:
|
|
65
|
-
"Invalid mode. Available: `ALL`, `WHITELIST`, `BLACKLIST`",
|
|
66
|
-
"الوضع غير صالح. الأوضاع المتاحة: `ALL`, `WHITELIST`, `BLACKLIST`",
|
|
67
|
-
),
|
|
64
|
+
text: t("bot.moderation.antilink.invalidModeAvailableAllWhitelist"),
|
|
68
65
|
});
|
|
69
66
|
}
|
|
70
67
|
antilinkConfig.mode = mode;
|
|
71
68
|
await sock.sendMessage(groupId, {
|
|
72
|
-
text:
|
|
69
|
+
text: t("bot.moderation.antilink.antiLinkModeIsNow", { mode }),
|
|
73
70
|
});
|
|
74
71
|
break;
|
|
75
72
|
}
|
|
@@ -77,16 +74,13 @@ const command = {
|
|
|
77
74
|
const domainToAllow = args[1] ? args[1].toLowerCase() : "";
|
|
78
75
|
if (!domainToAllow)
|
|
79
76
|
return await sock.sendMessage(groupId, {
|
|
80
|
-
text:
|
|
77
|
+
text: t("bot.moderation.antilink.sayWhichDomainToAllow"),
|
|
81
78
|
});
|
|
82
79
|
if (!antilinkConfig.allowed_domains.includes(domainToAllow)) {
|
|
83
80
|
antilinkConfig.allowed_domains.push(domainToAllow);
|
|
84
81
|
}
|
|
85
82
|
await sock.sendMessage(groupId, {
|
|
86
|
-
text:
|
|
87
|
-
`✅ '${domainToAllow}' is now allowed.`,
|
|
88
|
-
`✅ تم إضافة '${domainToAllow}' إلى قائمة الدومينات المسموح بها.`,
|
|
89
|
-
),
|
|
83
|
+
text: t("bot.moderation.antilink.isNowAllowed", { domainToAllow }),
|
|
90
84
|
});
|
|
91
85
|
break;
|
|
92
86
|
}
|
|
@@ -94,24 +88,18 @@ const command = {
|
|
|
94
88
|
const action = normalizeFeatureAction(args[1]);
|
|
95
89
|
if (!action) {
|
|
96
90
|
return await sock.sendMessage(groupId, {
|
|
97
|
-
text:
|
|
98
|
-
"Invalid action. Available: `DELETE`, `WARN`, `KICK`",
|
|
99
|
-
"الإجراء غير صالح. الإجراءات المتاحة: `DELETE`, `WARN`, `KICK`",
|
|
100
|
-
),
|
|
91
|
+
text: t("bot.moderation.antilink.invalidActionAvailableDeleteWarn"),
|
|
101
92
|
});
|
|
102
93
|
}
|
|
103
94
|
try {
|
|
104
95
|
applyModerationPolicy(groupId, { features: { antilink: action } });
|
|
105
96
|
} catch (error) {
|
|
106
97
|
return await sock.sendMessage(groupId, {
|
|
107
|
-
text:
|
|
108
|
-
error.errors?.[0]?.message || "That action is not allowed.",
|
|
109
|
-
"هذا الإجراء غير مسموح.",
|
|
110
|
-
),
|
|
98
|
+
text: actionNotAllowed(error),
|
|
111
99
|
});
|
|
112
100
|
}
|
|
113
101
|
await sock.sendMessage(groupId, {
|
|
114
|
-
text:
|
|
102
|
+
text: t("bot.moderation.antilink.antiLinkActionIsNow", { action }),
|
|
115
103
|
});
|
|
116
104
|
return;
|
|
117
105
|
}
|
|
@@ -119,28 +107,27 @@ const command = {
|
|
|
119
107
|
const domainToDisallow = args[1] ? args[1].toLowerCase() : "";
|
|
120
108
|
if (!domainToDisallow)
|
|
121
109
|
return await sock.sendMessage(groupId, {
|
|
122
|
-
text:
|
|
110
|
+
text: t("bot.moderation.antilink.sayWhichDomainToRemove"),
|
|
123
111
|
});
|
|
124
112
|
antilinkConfig.allowed_domains = antilinkConfig.allowed_domains.filter(
|
|
125
113
|
(d) => d !== domainToDisallow,
|
|
126
114
|
);
|
|
127
115
|
await sock.sendMessage(groupId, {
|
|
128
|
-
text:
|
|
129
|
-
`☑️ '${domainToDisallow}' is no longer allowed.`,
|
|
130
|
-
`☑️ تم إزالة '${domainToDisallow}' من قائمة الدومينات المسموح بها.`,
|
|
131
|
-
),
|
|
116
|
+
text: t("bot.moderation.antilink.isNoLongerAllowed", { domainToDisallow }),
|
|
132
117
|
});
|
|
133
118
|
break;
|
|
134
119
|
}
|
|
135
120
|
default: {
|
|
136
121
|
// Display current status
|
|
137
|
-
const state = antilinkConfig.enabled ?
|
|
138
|
-
const allowed = antilinkConfig.allowed_domains.join(", ") ||
|
|
122
|
+
const state = antilinkConfig.enabled ? t("bot.moderation.antilink.on") : t("bot.moderation.antilink.off");
|
|
123
|
+
const allowed = antilinkConfig.allowed_domains.join(", ") || t("bot.moderation.antilink.none");
|
|
139
124
|
const action = featureActionOf(settings, "antilink");
|
|
140
|
-
const statusReply =
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
125
|
+
const statusReply = t("bot.moderation.antilink.antiLinkStateModeAction", {
|
|
126
|
+
state,
|
|
127
|
+
mode: antilinkConfig.mode,
|
|
128
|
+
action,
|
|
129
|
+
allowed,
|
|
130
|
+
});
|
|
144
131
|
await sock.sendMessage(groupId, { text: statusReply });
|
|
145
132
|
}
|
|
146
133
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs");
|
|
2
2
|
const { featureActionOf, normalizeFeatureAction } = require("../../utils/moderationSummary.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t, currentLang } = require("../../utils/i18n.cjs");
|
|
4
4
|
const { applyModerationPolicy } = require("../../services/moderationPolicy.cjs");
|
|
5
5
|
|
|
6
|
+
// The validator's detail is English only. Other languages get a generic line.
|
|
7
|
+
// A catalog value of "{detail}" is rejected: placeholder sets must match.
|
|
8
|
+
function actionNotAllowed(error) {
|
|
9
|
+
const generic = t("bot.moderation.actionNotAllowed");
|
|
10
|
+
const detail = error.errors?.[0]?.message;
|
|
11
|
+
return currentLang() === "en" ? detail || generic : generic;
|
|
12
|
+
}
|
|
13
|
+
|
|
6
14
|
module.exports = {
|
|
7
15
|
name: "antispam",
|
|
8
|
-
description: {
|
|
9
|
-
en: "Controls anti-spam in the group.",
|
|
10
|
-
ar: "يتحكم في مكافحة الإزعاج في المجموعة.",
|
|
11
|
-
},
|
|
12
|
-
usage: {
|
|
13
|
-
en: "antispam [status]\nantispam <on|off>\nantispam action <WARN|KICK>\nantispam window <seconds>\nantispam count <number>",
|
|
14
|
-
ar: "antispam [status]\nantispam <on|off>\nantispam action <WARN|KICK>\nantispam window <ثوان>\nantispam count <عدد>",
|
|
15
|
-
},
|
|
16
16
|
chat: "group",
|
|
17
17
|
userAdminRequired: true,
|
|
18
18
|
|
|
@@ -29,37 +29,31 @@ module.exports = {
|
|
|
29
29
|
case "on":
|
|
30
30
|
spam.enabled = true;
|
|
31
31
|
await sock.sendMessage(groupId, {
|
|
32
|
-
text:
|
|
32
|
+
text: t("bot.moderation.antispam.antiSpamIsOn"),
|
|
33
33
|
});
|
|
34
34
|
break;
|
|
35
35
|
case "off":
|
|
36
36
|
spam.enabled = false;
|
|
37
37
|
await sock.sendMessage(groupId, {
|
|
38
|
-
text:
|
|
38
|
+
text: t("bot.moderation.antispam.antiSpamIsOff"),
|
|
39
39
|
});
|
|
40
40
|
break;
|
|
41
41
|
case "action": {
|
|
42
42
|
const action = normalizeFeatureAction(args[1], { allowDelete: false });
|
|
43
43
|
if (!action) {
|
|
44
44
|
return await sock.sendMessage(groupId, {
|
|
45
|
-
text:
|
|
46
|
-
"Invalid action. Available: `WARN`, `KICK`",
|
|
47
|
-
"الإجراء غير صالح. الإجراءات المتاحة: `WARN`, `KICK`",
|
|
48
|
-
),
|
|
45
|
+
text: t("bot.moderation.antispam.invalidActionAvailableWarnKick"),
|
|
49
46
|
});
|
|
50
47
|
}
|
|
51
48
|
try {
|
|
52
49
|
applyModerationPolicy(groupId, { features: { antispam: action } });
|
|
53
50
|
} catch (error) {
|
|
54
51
|
return await sock.sendMessage(groupId, {
|
|
55
|
-
text:
|
|
56
|
-
error.errors?.[0]?.message || "That action is not allowed.",
|
|
57
|
-
"هذا الإجراء غير مسموح.",
|
|
58
|
-
),
|
|
52
|
+
text: actionNotAllowed(error),
|
|
59
53
|
});
|
|
60
54
|
}
|
|
61
55
|
await sock.sendMessage(groupId, {
|
|
62
|
-
text:
|
|
56
|
+
text: t("bot.moderation.antispam.antiSpamActionIsNow", { action }),
|
|
63
57
|
});
|
|
64
58
|
return;
|
|
65
59
|
}
|
|
@@ -67,15 +61,12 @@ module.exports = {
|
|
|
67
61
|
const seconds = parseInt(args[1], 10);
|
|
68
62
|
if (!Number.isFinite(seconds) || seconds < 1 || seconds > 600) {
|
|
69
63
|
return await sock.sendMessage(groupId, {
|
|
70
|
-
text:
|
|
71
|
-
"Give a window between 1 and 600 seconds.",
|
|
72
|
-
"يرجى تحديد مدة بين 1 و 600 ثانية.",
|
|
73
|
-
),
|
|
64
|
+
text: t("bot.moderation.antispam.giveAWindowBetweenAnd"),
|
|
74
65
|
});
|
|
75
66
|
}
|
|
76
67
|
spam.time_window = seconds;
|
|
77
68
|
await sock.sendMessage(groupId, {
|
|
78
|
-
text:
|
|
69
|
+
text: t("bot.moderation.antispam.antiSpamWindowIsNow", { seconds }),
|
|
79
70
|
});
|
|
80
71
|
break;
|
|
81
72
|
}
|
|
@@ -83,26 +74,25 @@ module.exports = {
|
|
|
83
74
|
const count = parseInt(args[1], 10);
|
|
84
75
|
if (!Number.isFinite(count) || count < 2 || count > 100) {
|
|
85
76
|
return await sock.sendMessage(groupId, {
|
|
86
|
-
text:
|
|
87
|
-
"Give a message count between 2 and 100.",
|
|
88
|
-
"يرجى تحديد عدد رسائل بين 2 و 100.",
|
|
89
|
-
),
|
|
77
|
+
text: t("bot.moderation.antispam.giveAMessageCountBetween"),
|
|
90
78
|
});
|
|
91
79
|
}
|
|
92
80
|
spam.message_count = count;
|
|
93
81
|
await sock.sendMessage(groupId, {
|
|
94
|
-
text:
|
|
82
|
+
text: t("bot.moderation.antispam.antiSpamLimitIsNow", { count }),
|
|
95
83
|
});
|
|
96
84
|
break;
|
|
97
85
|
}
|
|
98
86
|
default: {
|
|
99
|
-
const state = spam.enabled ?
|
|
87
|
+
const state = spam.enabled ? t("bot.moderation.antispam.on") : t("bot.moderation.antispam.off");
|
|
100
88
|
const action = featureActionOf(settings, "antispam");
|
|
101
89
|
await sock.sendMessage(groupId, {
|
|
102
|
-
text:
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
90
|
+
text: t("bot.moderation.antispam.antiSpamStateWindowS", {
|
|
91
|
+
state,
|
|
92
|
+
timeWindow: spam.time_window ?? 10,
|
|
93
|
+
messageCount: spam.message_count ?? 5,
|
|
94
|
+
action,
|
|
95
|
+
}),
|
|
106
96
|
});
|
|
107
97
|
return;
|
|
108
98
|
}
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
// file: /commands/group/approveall.js
|
|
2
2
|
const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs"); // Note the path is ../../
|
|
3
3
|
const logger = require("../../utils/logger.cjs");
|
|
4
|
-
const {
|
|
4
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
name: "approveall",
|
|
8
|
-
description: {
|
|
9
|
-
en: "Manages automatic approval of join requests.",
|
|
10
|
-
ar: "يدير الموافقة التلقائية على طلبات الانضمام.",
|
|
11
|
-
},
|
|
12
|
-
usage: {
|
|
13
|
-
en: "approveall <on|off>",
|
|
14
|
-
ar: "approveall <on|off>",
|
|
15
|
-
},
|
|
16
8
|
chat: "group",
|
|
17
9
|
userAdminRequired: true,
|
|
18
10
|
botAdminRequired: true, // The bot must be an admin to approve requests
|
|
@@ -31,31 +23,25 @@ module.exports = {
|
|
|
31
23
|
settings.join_requests.auto_approve_enabled = true;
|
|
32
24
|
saveGroupSettings(groupId, settings);
|
|
33
25
|
return await sock.sendMessage(groupId, {
|
|
34
|
-
text:
|
|
35
|
-
"✅ Join requests are now approved automatically.",
|
|
36
|
-
"✅ تم تفعيل نظام الموافقة التلقائية على طلبات الانضمام.",
|
|
37
|
-
),
|
|
26
|
+
text: t("bot.group.approveall.enabled"),
|
|
38
27
|
});
|
|
39
28
|
} else if (option === "off") {
|
|
40
29
|
settings.join_requests.auto_approve_enabled = false;
|
|
41
30
|
saveGroupSettings(groupId, settings);
|
|
42
31
|
return await sock.sendMessage(groupId, {
|
|
43
|
-
text:
|
|
32
|
+
text: t("bot.group.approveall.disabled"),
|
|
44
33
|
});
|
|
45
34
|
} else {
|
|
46
35
|
const status = settings.join_requests.auto_approve_enabled
|
|
47
|
-
?
|
|
48
|
-
:
|
|
36
|
+
? t("bot.group.approveall.stateOn")
|
|
37
|
+
: t("bot.group.approveall.stateOff");
|
|
49
38
|
return await sock.sendMessage(groupId, {
|
|
50
|
-
text:
|
|
51
|
-
`Automatic approval: ${status}.\nUse 'on' or 'off' to change it.`,
|
|
52
|
-
`حالة الموافقة التلقائية: ${status}.\nاستخدم 'on' أو 'off' للتغيير.`,
|
|
53
|
-
),
|
|
39
|
+
text: t("bot.group.approveall.status", { status }),
|
|
54
40
|
});
|
|
55
41
|
}
|
|
56
42
|
} catch (error) {
|
|
57
43
|
logger.error({ err: error, command: "approveall" }, "Error in !group approveall command");
|
|
58
|
-
await sock.sendMessage(groupId, { text:
|
|
44
|
+
await sock.sendMessage(groupId, { text: t("bot.group.approveall.failed") });
|
|
59
45
|
}
|
|
60
46
|
},
|
|
61
47
|
};
|
|
@@ -1,18 +1,10 @@
|
|
|
1
1
|
// file: /commands/clearwarns.js
|
|
2
2
|
const logger = require("../../utils/logger.cjs");
|
|
3
3
|
const { clearMemberModeration, targetFromCommand } = require("../../utils/moderationAction.cjs");
|
|
4
|
-
const {
|
|
4
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
name: "clearwarns",
|
|
8
|
-
description: {
|
|
9
|
-
en: "Clears all of a member's warnings and dismisses their flag.",
|
|
10
|
-
ar: "يمسح كل تحذيرات عضو معيّن ويلغي تعليمه للمراجعة.",
|
|
11
|
-
},
|
|
12
|
-
usage: {
|
|
13
|
-
en: "clearwarns @member",
|
|
14
|
-
ar: "clearwarns @عضو",
|
|
15
|
-
},
|
|
16
8
|
chat: "group",
|
|
17
9
|
userAdminRequired: true,
|
|
18
10
|
|
|
@@ -24,19 +16,13 @@ module.exports = {
|
|
|
24
16
|
|
|
25
17
|
if (!mentionedJid) {
|
|
26
18
|
return await sock.sendMessage(groupId, {
|
|
27
|
-
text:
|
|
28
|
-
"Mention the member whose warnings you want to clear.",
|
|
29
|
-
"يجب عمل منشن للعضو الذي تريد مسح تحذيراته.",
|
|
30
|
-
),
|
|
19
|
+
text: t("bot.moderation.clearwarns.mentionTheMemberWhoseWarnings"),
|
|
31
20
|
});
|
|
32
21
|
}
|
|
33
22
|
|
|
34
23
|
clearMemberModeration(groupId, mentionedJid);
|
|
35
24
|
|
|
36
|
-
const replyText =
|
|
37
|
-
`✅ Cleared every warning for @${mentionedJid.split("@")[0]}.`,
|
|
38
|
-
`✅ تم مسح جميع تحذيرات العضو @${mentionedJid.split("@")[0]} بنجاح.`,
|
|
39
|
-
);
|
|
25
|
+
const replyText = t("bot.moderation.clearwarns.clearedEveryWarningFor", { member: mentionedJid.split("@")[0] });
|
|
40
26
|
await sock.sendMessage(groupId, {
|
|
41
27
|
text: replyText,
|
|
42
28
|
mentions: [mentionedJid],
|
|
@@ -44,7 +30,7 @@ module.exports = {
|
|
|
44
30
|
} catch (error) {
|
|
45
31
|
logger.error({ err: error }, "Error in !clearwarns command");
|
|
46
32
|
await sock.sendMessage(msg.key.remoteJid, {
|
|
47
|
-
text:
|
|
33
|
+
text: t("bot.moderation.clearwarns.somethingWentWrongWhileClearing"),
|
|
48
34
|
});
|
|
49
35
|
}
|
|
50
36
|
},
|
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
// file: /commands/deletenote.js
|
|
2
2
|
const { deleteNote } = require("../../utils/storage.cjs");
|
|
3
|
-
const {
|
|
3
|
+
const { t } = require("../../utils/i18n.cjs");
|
|
4
4
|
|
|
5
5
|
module.exports = {
|
|
6
6
|
name: "deletenote",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Deletes a saved note.",
|
|
9
|
-
ar: "يحذف ملاحظة محفوظة.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "deletenote #keyword",
|
|
13
|
-
ar: "deletenote #الكلمة-المفتاحية",
|
|
14
|
-
},
|
|
15
7
|
chat: "all",
|
|
16
8
|
userAdminRequired: true,
|
|
17
9
|
|
|
@@ -21,10 +13,7 @@ module.exports = {
|
|
|
21
13
|
|
|
22
14
|
if (!keywordArg || !keywordArg.startsWith("#")) {
|
|
23
15
|
return await sock.sendMessage(groupId, {
|
|
24
|
-
text:
|
|
25
|
-
"Wrong format. Use: `!deletenote #keyword`",
|
|
26
|
-
"صيغة غير صحيحة. استخدم: `!deletenote #keyword`",
|
|
27
|
-
),
|
|
16
|
+
text: t("bot.group.deletenote.usageHint"),
|
|
28
17
|
});
|
|
29
18
|
}
|
|
30
19
|
|
|
@@ -32,14 +21,11 @@ module.exports = {
|
|
|
32
21
|
|
|
33
22
|
if (deleteNote(groupId, keyword)) {
|
|
34
23
|
await sock.sendMessage(groupId, {
|
|
35
|
-
text:
|
|
24
|
+
text: t("bot.group.deletenote.deleted", { keyword }),
|
|
36
25
|
});
|
|
37
26
|
} else {
|
|
38
27
|
await sock.sendMessage(groupId, {
|
|
39
|
-
text:
|
|
40
|
-
`⚠️ No note has the keyword \`${keywordArg}\``,
|
|
41
|
-
`⚠️ لم يتم العثور على ملاحظة بالكلمة المفتاحية: \`${keywordArg}\``,
|
|
42
|
-
),
|
|
28
|
+
text: t("bot.group.deletenote.notFound", { keyword: keywordArg }),
|
|
43
29
|
});
|
|
44
30
|
}
|
|
45
31
|
},
|