levix-bot 4.0.4 → 4.2.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/package.json +1 -1
- package/public/dashboard/assets/index-4AuqfnH5.js +431 -0
- package/public/dashboard/assets/index-LvfJ8ybs.css +2 -0
- package/public/dashboard/index.html +2 -2
- package/scheduler.cjs +25 -1
- package/src/commands/autoschedule.cjs +40 -10
- package/src/commands/blacklist.cjs +35 -10
- package/src/commands/block.cjs +18 -5
- package/src/commands/calc.cjs +90 -24
- package/src/commands/debt.cjs +59 -33
- package/src/commands/deleteschedule.cjs +21 -5
- package/src/commands/digit.cjs +34 -8
- package/src/commands/gemini.cjs +235 -108
- package/src/commands/group/add.cjs +46 -13
- package/src/commands/group/all.cjs +15 -5
- package/src/commands/group/antiSpam.cjs +11 -4
- package/src/commands/group/antilink.cjs +39 -19
- package/src/commands/group/approveall.cjs +22 -7
- package/src/commands/group/clearwarns.cjs +18 -5
- package/src/commands/group/deletenote.cjs +18 -5
- package/src/commands/group/demote.cjs +25 -7
- package/src/commands/group/kick.cjs +28 -12
- package/src/commands/group/media.cjs +34 -13
- package/src/commands/group/members.cjs +21 -6
- package/src/commands/group/note.cjs +14 -4
- package/src/commands/group/promote.cjs +22 -6
- package/src/commands/group/removeall.cjs +13 -3
- package/src/commands/group/rules.cjs +20 -5
- package/src/commands/group/save.cjs +20 -5
- package/src/commands/group/setname.cjs +19 -6
- package/src/commands/group/setpp.cjs +21 -6
- package/src/commands/group/setrules.cjs +17 -5
- package/src/commands/group/setwarn.cjs +23 -7
- package/src/commands/group/tagadmins.cjs +16 -6
- package/src/commands/group/warn.cjs +35 -15
- package/src/commands/group/warns.cjs +33 -13
- package/src/commands/group/welcome.cjs +34 -16
- package/src/commands/group.cjs +96 -70
- package/src/commands/help.cjs +270 -129
- package/src/commands/lang.cjs +46 -13
- package/src/commands/listschedules.cjs +28 -11
- package/src/commands/loop.cjs +43 -9
- package/src/commands/memory.cjs +90 -30
- package/src/commands/mod.cjs +72 -28
- package/src/commands/notes.cjs +15 -5
- package/src/commands/perm.cjs +52 -20
- package/src/commands/ping.cjs +15 -3
- package/src/commands/poll.cjs +71 -24
- package/src/commands/prayer.cjs +28 -12
- package/src/commands/qr.cjs +20 -5
- package/src/commands/rand.cjs +54 -12
- package/src/commands/restart.cjs +13 -3
- package/src/commands/schedule.cjs +32 -9
- package/src/commands/score.cjs +26 -10
- package/src/commands/setprefix.cjs +27 -5
- package/src/commands/shortlink.cjs +36 -10
- package/src/commands/shutdown.cjs +13 -3
- package/src/commands/status.cjs +32 -11
- package/src/commands/sticker.cjs +34 -7
- package/src/commands/stt.cjs +159 -107
- package/src/commands/todo.cjs +31 -9
- package/src/commands/tts.cjs +61 -36
- package/src/commands/unblock.cjs +17 -4
- package/src/commands/weather.cjs +55 -17
- package/src/config/baileys.config.js +5 -1
- package/src/config/settings.cjs +11 -3
- package/src/core/connection.js +21 -2
- package/src/core/socket.js +31 -7
- package/src/db/store.cjs +24 -0
- package/src/handlers/command.handler.js +55 -13
- package/src/handlers/group.handler.js +5 -1
- package/src/handlers/message.handler.js +9 -0
- package/src/middleware/antispam.middleware.js +13 -3
- package/src/middleware/blacklist.middleware.js +4 -1
- package/src/middleware/permissions.middleware.js +38 -51
- package/src/routes/dashboard.api.esm.js +91 -10
- package/src/services/aiAgent.cjs +51 -41
- package/src/services/aiProviders.cjs +46 -19
- package/src/services/aiRouter.cjs +11 -3
- package/src/services/aiToolAuth.cjs +114 -0
- package/src/services/aiTools.cjs +492 -56
- package/src/services/modelRegistry.cjs +20 -5
- package/src/utils/commandDocs.cjs +58 -0
- package/src/utils/geminiMedia.cjs +99 -0
- package/src/utils/groupMetadataCache.cjs +83 -0
- package/src/utils/i18n.cjs +113 -0
- package/src/utils/markdownParser.cjs +4 -2
- package/src/utils/memory.cjs +37 -21
- package/src/utils/permissionLevel.cjs +83 -0
- package/src/utils/providerUrl.cjs +29 -2
- package/src/utils/sendBotMessage.cjs +7 -3
- package/src/utils/sendBotMessage.esm.js +27 -3
- package/src/utils/statusMessage.cjs +11 -4
- package/src/utils/storage-hub.cjs +21 -0
- package/public/dashboard/assets/index-BnJbz8iW.css +0 -2
- package/public/dashboard/assets/index-Dn8ZyzsW.js +0 -426
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// file: /commands/tagadmins.js
|
|
2
2
|
const logger = require("../../utils/logger.cjs");
|
|
3
|
+
const { tr } = require("../../utils/i18n.cjs");
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
name: "tagadmins",
|
|
6
|
-
description:
|
|
7
|
-
|
|
7
|
+
description: {
|
|
8
|
+
en: "Mentions every admin in the group.",
|
|
9
|
+
ar: "يذكر (منشن) جميع مشرفي المجموعة.",
|
|
10
|
+
},
|
|
11
|
+
usage: {
|
|
12
|
+
en: "tagadmins [message]",
|
|
13
|
+
ar: "tagadmins [رسالة]",
|
|
14
|
+
},
|
|
8
15
|
chat: "group",
|
|
9
16
|
|
|
10
17
|
async execute(sock, msg, args, body, groupMetadata) {
|
|
@@ -18,17 +25,20 @@ module.exports = {
|
|
|
18
25
|
|
|
19
26
|
if (admins.length === 0) {
|
|
20
27
|
return await sock.sendMessage(groupId, {
|
|
21
|
-
text: "لا يوجد مشرفون في هذا الجروب.",
|
|
28
|
+
text: tr("This group has no admins.", "لا يوجد مشرفون في هذا الجروب."),
|
|
22
29
|
});
|
|
23
30
|
}
|
|
24
31
|
|
|
25
32
|
// Get the custom message provided by the user, or use a default one
|
|
26
|
-
const customMessage = args.join(" ") || "يرجى حضور المشرفين";
|
|
33
|
+
const customMessage = args.join(" ") || tr("Admins, please come here", "يرجى حضور المشرفين");
|
|
27
34
|
|
|
28
35
|
// Get an array of JIDs for the mentions property
|
|
29
36
|
const mentions = admins.map((a) => a.id);
|
|
30
37
|
|
|
31
|
-
let text =
|
|
38
|
+
let text = tr(
|
|
39
|
+
`*🚨 Calling the admins 🚨*\n\n*Message:* ${customMessage}\n\n`,
|
|
40
|
+
`*🚨 تنبيه للمشرفين 🚨*\n\n*الرسالة:* ${customMessage}\n\n`,
|
|
41
|
+
);
|
|
32
42
|
|
|
33
43
|
// Add a tag for each admin
|
|
34
44
|
for (const admin of admins) {
|
|
@@ -41,7 +51,7 @@ module.exports = {
|
|
|
41
51
|
});
|
|
42
52
|
} catch (error) {
|
|
43
53
|
logger.error({ err: error, command: "tagadmins" }, "Error in !tagadmins command");
|
|
44
|
-
await sock.sendMessage(groupId, { text: "حدث خطأ." });
|
|
54
|
+
await sock.sendMessage(groupId, { text: tr("Something went wrong.", "حدث خطأ.") });
|
|
45
55
|
}
|
|
46
56
|
},
|
|
47
57
|
};
|
|
@@ -7,11 +7,18 @@ const {
|
|
|
7
7
|
isAdminInGroupSync,
|
|
8
8
|
sameUserSync,
|
|
9
9
|
} = require("../../utils/permissions.cjs");
|
|
10
|
+
const { tr } = require("../../utils/i18n.cjs");
|
|
10
11
|
|
|
11
12
|
module.exports = {
|
|
12
13
|
name: "warn",
|
|
13
|
-
description:
|
|
14
|
-
|
|
14
|
+
description: {
|
|
15
|
+
en: "Warns a member, and takes action once the limit is reached.",
|
|
16
|
+
ar: "يوجّه تحذيرًا لعضو، ويتخذ إجراءً عند بلوغ الحد.",
|
|
17
|
+
},
|
|
18
|
+
usage: {
|
|
19
|
+
en: "warn @member [reason]",
|
|
20
|
+
ar: "warn @عضو [السبب]",
|
|
21
|
+
},
|
|
15
22
|
chat: "group",
|
|
16
23
|
userAdminRequired: true,
|
|
17
24
|
|
|
@@ -25,12 +32,12 @@ module.exports = {
|
|
|
25
32
|
// --- 1. Validate Inputs ---
|
|
26
33
|
if (!mentionedJid) {
|
|
27
34
|
return await sock.sendMessage(groupId, {
|
|
28
|
-
text: "يجب عمل منشن للعضو الذي تريد تحذيره.",
|
|
35
|
+
text: tr("Mention the member you want to warn.", "يجب عمل منشن للعضو الذي تريد تحذيره."),
|
|
29
36
|
});
|
|
30
37
|
}
|
|
31
38
|
if (!reason) {
|
|
32
39
|
return await sock.sendMessage(groupId, {
|
|
33
|
-
text: "يجب كتابة سبب التحذير.",
|
|
40
|
+
text: tr("Write a reason for the warning.", "يجب كتابة سبب التحذير."),
|
|
34
41
|
});
|
|
35
42
|
}
|
|
36
43
|
const isBot = [sock.user?.id, sock.user?.lid]
|
|
@@ -42,7 +49,10 @@ module.exports = {
|
|
|
42
49
|
isAdminInGroupSync(groupMetadata, mentionedJid)
|
|
43
50
|
) {
|
|
44
51
|
return await sock.sendMessage(groupId, {
|
|
45
|
-
text:
|
|
52
|
+
text: tr(
|
|
53
|
+
"The bot, its owner and admins can't be warned or kicked this way.",
|
|
54
|
+
"لا يمكن تحذير أو طرد البوت أو مالكه أو أحد المشرفين بهذه الطريقة.",
|
|
55
|
+
),
|
|
46
56
|
});
|
|
47
57
|
}
|
|
48
58
|
|
|
@@ -58,8 +68,10 @@ module.exports = {
|
|
|
58
68
|
const newWarnCount = userWarnings.length;
|
|
59
69
|
|
|
60
70
|
// --- 3. Send Confirmation & Check for Action ---
|
|
61
|
-
const replyText =
|
|
62
|
-
`✅
|
|
71
|
+
const replyText = tr(
|
|
72
|
+
`✅ @${mentionedJid.split("@")[0]} has been warned.\n*Reason:* ${reason}`,
|
|
73
|
+
`✅ تم توجيه تحذير إلى @${mentionedJid.split("@")[0]}.\n` + `*السبب:* ${reason}`,
|
|
74
|
+
);
|
|
63
75
|
|
|
64
76
|
await sock.sendMessage(groupId, {
|
|
65
77
|
text: replyText,
|
|
@@ -70,9 +82,14 @@ module.exports = {
|
|
|
70
82
|
|
|
71
83
|
if (warnConfig && warnConfig.action === "KICK" && newWarnCount >= warnConfig.max_warnings) {
|
|
72
84
|
await sock.sendMessage(groupId, {
|
|
73
|
-
text:
|
|
74
|
-
|
|
75
|
-
|
|
85
|
+
text: tr(
|
|
86
|
+
`🚫 @${
|
|
87
|
+
mentionedJid.split("@")[0]
|
|
88
|
+
} reached the warning limit (${newWarnCount}/${warnConfig.max_warnings}) and will be removed.`,
|
|
89
|
+
`🚫 لقد وصل العضو @${
|
|
90
|
+
mentionedJid.split("@")[0]
|
|
91
|
+
} إلى الحد الأقصى للتحذيرات (${newWarnCount}/${warnConfig.max_warnings}). سيتم حذفه.`,
|
|
92
|
+
),
|
|
76
93
|
mentions: [mentionedJid],
|
|
77
94
|
});
|
|
78
95
|
|
|
@@ -86,21 +103,24 @@ module.exports = {
|
|
|
86
103
|
} catch (kickError) {
|
|
87
104
|
logger.error({ err: kickError }, "Failed to kick user after max warnings");
|
|
88
105
|
await sock.sendMessage(groupId, {
|
|
89
|
-
text:
|
|
106
|
+
text: tr(
|
|
107
|
+
"I tried to remove the member, but I don't have enough permissions.",
|
|
108
|
+
"حاولت حذف العضو ولكني لا أملك صلاحية كافية لذلك.",
|
|
109
|
+
),
|
|
90
110
|
});
|
|
91
111
|
}
|
|
92
112
|
} else {
|
|
93
113
|
// If no action is taken, just inform about the new count
|
|
94
114
|
await sock.sendMessage(groupId, {
|
|
95
|
-
text:
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
text:
|
|
116
|
+
tr("*Warnings so far:* ", "*إجمالي التحذيرات الآن:* ") +
|
|
117
|
+
`${newWarnCount}${warnConfig ? `/${warnConfig.max_warnings}` : ""}`,
|
|
98
118
|
});
|
|
99
119
|
}
|
|
100
120
|
} catch (error) {
|
|
101
121
|
logger.error({ err: error }, "An error occurred in the !warn command.");
|
|
102
122
|
await sock.sendMessage(msg.key.remoteJid, {
|
|
103
|
-
text: "حدث خطأ عام في أمر التحذير.",
|
|
123
|
+
text: tr("Something went wrong with the warn command.", "حدث خطأ عام في أمر التحذير."),
|
|
104
124
|
});
|
|
105
125
|
}
|
|
106
126
|
},
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
// file: /commands/warns.js
|
|
2
2
|
const { getUserWarnings } = require("../../utils/storage.cjs");
|
|
3
3
|
const logger = require("../../utils/logger.cjs");
|
|
4
|
+
const { tr } = require("../../utils/i18n.cjs");
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
name: "warns",
|
|
7
|
-
description:
|
|
8
|
-
|
|
8
|
+
description: {
|
|
9
|
+
en: "Shows a member's warnings.",
|
|
10
|
+
ar: "يعرض تحذيرات عضو معيّن.",
|
|
11
|
+
},
|
|
12
|
+
usage: {
|
|
13
|
+
en: "warns @member",
|
|
14
|
+
ar: "warns @عضو",
|
|
15
|
+
},
|
|
9
16
|
chat: "group",
|
|
10
17
|
userAdminRequired: true,
|
|
11
18
|
|
|
@@ -16,7 +23,10 @@ module.exports = {
|
|
|
16
23
|
|
|
17
24
|
if (!mentionedJid) {
|
|
18
25
|
return await sock.sendMessage(groupId, {
|
|
19
|
-
text:
|
|
26
|
+
text: tr(
|
|
27
|
+
"Mention the member whose warnings you want to see.",
|
|
28
|
+
"يجب عمل منشن للعضو الذي تريد عرض تحذيراته.",
|
|
29
|
+
),
|
|
20
30
|
});
|
|
21
31
|
}
|
|
22
32
|
|
|
@@ -25,28 +35,38 @@ module.exports = {
|
|
|
25
35
|
|
|
26
36
|
if (userWarnings.length === 0) {
|
|
27
37
|
return await sock.sendMessage(groupId, {
|
|
28
|
-
text:
|
|
38
|
+
text: tr(
|
|
39
|
+
`✅ @${mentionedJid.split("@")[0]} has no warnings.`,
|
|
40
|
+
`✅ لا توجد أي تحذيرات للعضو @${mentionedJid.split("@")[0]}.`,
|
|
41
|
+
),
|
|
29
42
|
mentions: [mentionedJid],
|
|
30
43
|
});
|
|
31
44
|
}
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
46
|
+
const who = mentionedJid.split("@")[0];
|
|
47
|
+
let reply = tr(
|
|
48
|
+
`*Warnings for @${who}:*\n*Total: ${userWarnings.length}*\n\n`,
|
|
49
|
+
`*سجل تحذيرات @${who}:*\n*إجمالي التحذيرات: ${userWarnings.length}*\n\n`,
|
|
50
|
+
);
|
|
36
51
|
|
|
37
52
|
const mentionedAdmins = [];
|
|
38
53
|
userWarnings.forEach((warning, index) => {
|
|
39
54
|
const adminJid = warning.by;
|
|
40
55
|
mentionedAdmins.push(adminJid);
|
|
41
|
-
const warningDate = new Date(warning.date).toLocaleString("ar-EG", {
|
|
56
|
+
const warningDate = new Date(warning.date).toLocaleString(tr("en-GB", "ar-EG"), {
|
|
42
57
|
timeZone: "Africa/Cairo",
|
|
43
58
|
});
|
|
44
59
|
|
|
45
|
-
reply +=
|
|
60
|
+
reply += tr(
|
|
61
|
+
`*${index + 1}. Warning:*\n` +
|
|
62
|
+
`*Reason:* ${warning.reason}\n` +
|
|
63
|
+
`*By:* @${adminJid.split("@")[0]}\n` +
|
|
64
|
+
`*Date:* ${warningDate}\n\n`,
|
|
46
65
|
`*${index + 1}. التحذير:*\n` +
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
66
|
+
`*السبب:* ${warning.reason}\n` +
|
|
67
|
+
`*بواسطة المشرف:* @${adminJid.split("@")[0]}\n` +
|
|
68
|
+
`*التاريخ:* ${warningDate}\n\n`,
|
|
69
|
+
);
|
|
50
70
|
});
|
|
51
71
|
|
|
52
72
|
const mentions = [mentionedJid, ...mentionedAdmins];
|
|
@@ -58,7 +78,7 @@ module.exports = {
|
|
|
58
78
|
} catch (error) {
|
|
59
79
|
logger.error({ err: error }, "Error in !warns command");
|
|
60
80
|
await sock.sendMessage(msg.key.remoteJid, {
|
|
61
|
-
text: "حدث خطأ أثناء عرض التحذيرات.",
|
|
81
|
+
text: tr("Something went wrong while listing the warnings.", "حدث خطأ أثناء عرض التحذيرات."),
|
|
62
82
|
});
|
|
63
83
|
}
|
|
64
84
|
},
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
// file: /commands/welcome.js
|
|
2
2
|
const { getGroupSettings, saveGroupSettings } = require("../../utils/storage.cjs");
|
|
3
3
|
const logger = require("../../utils/logger.cjs");
|
|
4
|
+
const { tr } = require("../../utils/i18n.cjs");
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
name: "welcome",
|
|
7
|
-
description:
|
|
8
|
-
|
|
9
|
-
"
|
|
8
|
+
description: {
|
|
9
|
+
en: "Manages the group's welcome messages.",
|
|
10
|
+
ar: "يدير رسائل الترحيب في المجموعة.",
|
|
11
|
+
},
|
|
12
|
+
usage: {
|
|
13
|
+
en: "welcome [status]\nwelcome <on|off>\nwelcome add <welcome text>\nwelcome list\nwelcome delete <number>",
|
|
14
|
+
ar: "welcome [status]\nwelcome <on|off>\nwelcome add <نص الترحيب>\nwelcome list\nwelcome delete <رقم>",
|
|
15
|
+
},
|
|
10
16
|
chat: "group",
|
|
11
17
|
userAdminRequired: true,
|
|
12
18
|
|
|
@@ -27,14 +33,14 @@ module.exports = {
|
|
|
27
33
|
case "on":
|
|
28
34
|
welcomeConfig.enabled = true;
|
|
29
35
|
await sock.sendMessage(groupId, {
|
|
30
|
-
text: "✅ تم تفعيل نظام الترحيب التلقائي.",
|
|
36
|
+
text: tr("✅ Automatic welcome messages are on.", "✅ تم تفعيل نظام الترحيب التلقائي."),
|
|
31
37
|
});
|
|
32
38
|
break;
|
|
33
39
|
|
|
34
40
|
case "off":
|
|
35
41
|
welcomeConfig.enabled = false;
|
|
36
42
|
await sock.sendMessage(groupId, {
|
|
37
|
-
text: "☑️ تم تعطيل نظام الترحيب التلقائي.",
|
|
43
|
+
text: tr("☑️ Automatic welcome messages are off.", "☑️ تم تعطيل نظام الترحيب التلقائي."),
|
|
38
44
|
});
|
|
39
45
|
break;
|
|
40
46
|
|
|
@@ -42,12 +48,15 @@ module.exports = {
|
|
|
42
48
|
const messageToAdd = args.slice(1).join(" ");
|
|
43
49
|
if (!messageToAdd || !messageToAdd.includes("${user}")) {
|
|
44
50
|
return await sock.sendMessage(groupId, {
|
|
45
|
-
text:
|
|
51
|
+
text: tr(
|
|
52
|
+
"Write a welcome message containing ${user} to mention the new member.",
|
|
53
|
+
"يرجى كتابة رسالة ترحيب تحتوي على المتغير ${user} لعمل منشن للعضو الجديد.",
|
|
54
|
+
),
|
|
46
55
|
});
|
|
47
56
|
}
|
|
48
57
|
welcomeConfig.messages.push(messageToAdd);
|
|
49
58
|
await sock.sendMessage(groupId, {
|
|
50
|
-
text: "✅ تم إضافة رسالة الترحيب بنجاح.",
|
|
59
|
+
text: tr("✅ Welcome message added.", "✅ تم إضافة رسالة الترحيب بنجاح."),
|
|
51
60
|
});
|
|
52
61
|
break;
|
|
53
62
|
}
|
|
@@ -55,10 +64,10 @@ module.exports = {
|
|
|
55
64
|
case "list": {
|
|
56
65
|
if (welcomeConfig.messages.length === 0) {
|
|
57
66
|
return await sock.sendMessage(groupId, {
|
|
58
|
-
text: "لا توجد رسائل ترحيب محفوظة.",
|
|
67
|
+
text: tr("There are no saved welcome messages.", "لا توجد رسائل ترحيب محفوظة."),
|
|
59
68
|
});
|
|
60
69
|
}
|
|
61
|
-
let listReply = "*قائمة رسائل الترحيب المحفوظة:*\n\n";
|
|
70
|
+
let listReply = tr("*Saved welcome messages:*\n\n", "*قائمة رسائل الترحيب المحفوظة:*\n\n");
|
|
62
71
|
welcomeConfig.messages.forEach((message, index) => {
|
|
63
72
|
listReply += `#${index + 1}: ${message}\n`;
|
|
64
73
|
});
|
|
@@ -74,22 +83,31 @@ module.exports = {
|
|
|
74
83
|
indexToDelete >= welcomeConfig.messages.length
|
|
75
84
|
) {
|
|
76
85
|
return await sock.sendMessage(groupId, {
|
|
77
|
-
text:
|
|
86
|
+
text: tr(
|
|
87
|
+
"Invalid message number. Use `!welcome list` to see the numbers.",
|
|
88
|
+
"رقم الرسالة غير صالح. استخدم `!welcome list` لمعرفة الأرقام.",
|
|
89
|
+
),
|
|
78
90
|
});
|
|
79
91
|
}
|
|
80
92
|
const deletedMessage = welcomeConfig.messages.splice(indexToDelete, 1);
|
|
81
93
|
await sock.sendMessage(groupId, {
|
|
82
|
-
text:
|
|
94
|
+
text: tr(
|
|
95
|
+
`☑️ Deleted the message:\n*${deletedMessage[0]}*`,
|
|
96
|
+
`☑️ تم حذف الرسالة بنجاح:\n*${deletedMessage[0]}*`,
|
|
97
|
+
),
|
|
83
98
|
});
|
|
84
99
|
break;
|
|
85
100
|
}
|
|
86
101
|
|
|
87
102
|
case "status":
|
|
88
103
|
default: {
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
104
|
+
const state = welcomeConfig.enabled ? tr("on ✅", "مفعل ✅") : tr("off ☑️", "معطل ☑️");
|
|
105
|
+
const statusReply = tr(
|
|
106
|
+
`*Welcome messages:*\n\nState: ${state}\nSaved messages: ${welcomeConfig.messages.length}`,
|
|
107
|
+
`*حالة نظام الترحيب:*\n\n` +
|
|
108
|
+
`الحالة: ${state}\n` +
|
|
109
|
+
`عدد الرسائل المحفوظة: ${welcomeConfig.messages.length}`,
|
|
110
|
+
);
|
|
93
111
|
await sock.sendMessage(groupId, { text: statusReply });
|
|
94
112
|
break;
|
|
95
113
|
}
|
|
@@ -99,7 +117,7 @@ module.exports = {
|
|
|
99
117
|
saveGroupSettings(groupId, settings);
|
|
100
118
|
} catch (error) {
|
|
101
119
|
logger.error({ err: error, command: "welcome" }, "Error in !welcome command");
|
|
102
|
-
await sock.sendMessage(groupId, { text: "حدث خطأ." });
|
|
120
|
+
await sock.sendMessage(groupId, { text: tr("Something went wrong.", "حدث خطأ.") });
|
|
103
121
|
}
|
|
104
122
|
},
|
|
105
123
|
};
|
package/src/commands/group.cjs
CHANGED
|
@@ -15,6 +15,7 @@ const {
|
|
|
15
15
|
isBotAdminInGroupSync,
|
|
16
16
|
} = require("../utils/permissions.cjs");
|
|
17
17
|
const normalizeJid = require("../utils/normalizeJid.cjs");
|
|
18
|
+
const { langForCommand, withLang, tr } = require("../utils/i18n.cjs");
|
|
18
19
|
|
|
19
20
|
// --- Sub-command Loader ---
|
|
20
21
|
//
|
|
@@ -63,8 +64,14 @@ if (manifest) {
|
|
|
63
64
|
|
|
64
65
|
module.exports = {
|
|
65
66
|
name: "group",
|
|
66
|
-
description:
|
|
67
|
-
|
|
67
|
+
description: {
|
|
68
|
+
en: "Main command for all group management actions.",
|
|
69
|
+
ar: "الأمر الرئيسي لكل إجراءات إدارة المجموعة.",
|
|
70
|
+
},
|
|
71
|
+
usage: {
|
|
72
|
+
en: "group <sub-command> [arguments]",
|
|
73
|
+
ar: "group <أمر فرعي> [المعاملات]",
|
|
74
|
+
},
|
|
68
75
|
chat: "group",
|
|
69
76
|
|
|
70
77
|
async execute(sock, msg, args, body, groupMetadata) {
|
|
@@ -72,86 +79,105 @@ module.exports = {
|
|
|
72
79
|
|
|
73
80
|
if (!subCommandName) {
|
|
74
81
|
return await sock.sendMessage(msg.key.remoteJid, {
|
|
75
|
-
text: "يرجى تحديد أمر فرعي بعد `!group`.",
|
|
82
|
+
text: tr("Name a sub-command after `!group`.", "يرجى تحديد أمر فرعي بعد `!group`."),
|
|
76
83
|
});
|
|
77
84
|
}
|
|
78
85
|
|
|
79
86
|
const subCommand = subCommands.get(subCommandName);
|
|
80
87
|
if (!subCommand) {
|
|
81
88
|
return await sock.sendMessage(msg.key.remoteJid, {
|
|
82
|
-
text:
|
|
89
|
+
text: tr(
|
|
90
|
+
`Unknown sub-command \`${subCommandName}\`.`,
|
|
91
|
+
`الأمر الفرعي \`${subCommandName}\` غير معروف.`,
|
|
92
|
+
),
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
95
|
|
|
86
|
-
//
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
const senderId = normalizeJid(msg.key.participant || msg.key.remoteJid);
|
|
95
|
-
// Centralized owner check — covers the bot itself, LID<->PN,
|
|
96
|
-
// and the user_metadata table.
|
|
97
|
-
const isOwner = msg.key.fromMe || isOwnerJidSync(senderId);
|
|
98
|
-
const isSenderAdmin = isAdminInGroupSync(groupMetadata, senderId);
|
|
99
|
-
|
|
100
|
-
// "group:kick" — the flat key runtime-config uses for sub-commands, so a
|
|
101
|
-
// level changed from the dashboard applies here too.
|
|
102
|
-
const permissionLevel = runtimeConfig.getPermission(`group:${subCommand.name}`);
|
|
103
|
-
|
|
104
|
-
let hasPermission = false;
|
|
105
|
-
switch (permissionLevel) {
|
|
106
|
-
case "MEMBERS":
|
|
107
|
-
case "ALL":
|
|
108
|
-
hasPermission = true;
|
|
109
|
-
break;
|
|
110
|
-
case "OWNER_ONLY":
|
|
111
|
-
hasPermission = isOwner;
|
|
112
|
-
break;
|
|
113
|
-
case "ADMINS_ONLY":
|
|
114
|
-
hasPermission = isSenderAdmin || isOwner;
|
|
115
|
-
break;
|
|
116
|
-
case "ADMINS_OWNER":
|
|
117
|
-
hasPermission = isOwner || isSenderAdmin;
|
|
118
|
-
break;
|
|
119
|
-
default:
|
|
120
|
-
logger.warn(
|
|
121
|
-
`[group] Unknown permission level "${permissionLevel}" for sub-command "${subCommand.name}"`,
|
|
122
|
-
);
|
|
123
|
-
}
|
|
96
|
+
// The dispatcher judged the language against `!group`'s own syntax, where
|
|
97
|
+
// `kick` looks like an English word. Judge it again against the
|
|
98
|
+
// sub-command's, the way a direct `!kick` is judged.
|
|
99
|
+
const lang = langForCommand(subCommand, args);
|
|
100
|
+
return withLang(lang, () => runSubCommand(sock, msg, args, body, groupMetadata, subCommand));
|
|
101
|
+
},
|
|
102
|
+
};
|
|
124
103
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
text: "🚫 ليس لديك الصلاحية لاستخدام هذا الأمر.",
|
|
128
|
-
});
|
|
129
|
-
}
|
|
104
|
+
async function runSubCommand(sock, msg, args, body, groupMetadata, subCommand) {
|
|
105
|
+
const subCommandName = subCommand.name;
|
|
130
106
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return await sock.sendMessage(msg.key.remoteJid, {
|
|
139
|
-
text: "⚠️ يجب أن أكون مشرفًا لتنفيذ هذا الأمر.",
|
|
140
|
-
});
|
|
141
|
-
}
|
|
107
|
+
// Switched off from the dashboard: `!group kick` has to refuse it too, not
|
|
108
|
+
// just the direct `!kick`.
|
|
109
|
+
if (runtimeConfig.isDisabled(subCommand.name)) {
|
|
110
|
+
return await sock.sendMessage(msg.key.remoteJid, {
|
|
111
|
+
text: tr("⛔ This command is turned off right now.", "⛔ الأمر ده متوقف حاليًا."),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
142
114
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
115
|
+
const senderId = normalizeJid(msg.key.participant || msg.key.remoteJid);
|
|
116
|
+
// Centralized owner check — covers the bot itself, LID<->PN,
|
|
117
|
+
// and the user_metadata table.
|
|
118
|
+
const isOwner = msg.key.fromMe || isOwnerJidSync(senderId);
|
|
119
|
+
const isSenderAdmin = isAdminInGroupSync(groupMetadata, senderId);
|
|
120
|
+
|
|
121
|
+
// "group:kick" — the flat key runtime-config uses for sub-commands, so a
|
|
122
|
+
// level changed from the dashboard applies here too.
|
|
123
|
+
const permissionLevel = runtimeConfig.getPermission(`group:${subCommand.name}`);
|
|
124
|
+
|
|
125
|
+
let hasPermission = false;
|
|
126
|
+
switch (permissionLevel) {
|
|
127
|
+
case "MEMBERS":
|
|
128
|
+
case "ALL":
|
|
129
|
+
hasPermission = true;
|
|
130
|
+
break;
|
|
131
|
+
case "OWNER_ONLY":
|
|
132
|
+
hasPermission = isOwner;
|
|
133
|
+
break;
|
|
134
|
+
case "ADMINS_ONLY":
|
|
135
|
+
hasPermission = isSenderAdmin || isOwner;
|
|
136
|
+
break;
|
|
137
|
+
case "ADMINS_OWNER":
|
|
138
|
+
hasPermission = isOwner || isSenderAdmin;
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
logger.warn(
|
|
142
|
+
`[group] Unknown permission level "${permissionLevel}" for sub-command "${subCommand.name}"`,
|
|
149
143
|
);
|
|
150
|
-
|
|
151
|
-
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!hasPermission) {
|
|
147
|
+
return await sock.sendMessage(msg.key.remoteJid, {
|
|
148
|
+
text: tr(
|
|
149
|
+
"🚫 You don't have permission to use this command.",
|
|
150
|
+
"🚫 ليس لديك الصلاحية لاستخدام هذا الأمر.",
|
|
151
|
+
),
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const isBotAdmin = isBotAdminInGroupSync(groupMetadata, sock);
|
|
156
|
+
if (subCommand.userAdminRequired && !isSenderAdmin && !isOwner) {
|
|
157
|
+
return await sock.sendMessage(msg.key.remoteJid, {
|
|
158
|
+
text: tr(
|
|
159
|
+
"⚠️ You need to be a group admin to use this command.",
|
|
160
|
+
"⚠️ هذا الأمر يتطلب أن تكون مشرفًا.",
|
|
161
|
+
),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (subCommand.botAdminRequired && !isBotAdmin) {
|
|
165
|
+
return await sock.sendMessage(msg.key.remoteJid, {
|
|
166
|
+
text: tr("⚠️ I need to be a group admin to do that.", "⚠️ يجب أن أكون مشرفًا لتنفيذ هذا الأمر."),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
await subCommand.execute(sock, msg, args, body, groupMetadata);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
logger.error({ err: error, subCommand: subCommandName }, "Error executing a group sub-command");
|
|
174
|
+
await sock.sendMessage(msg.key.remoteJid, {
|
|
175
|
+
text: tr(
|
|
176
|
+
`❌ *The sub-command failed* (\`${error.name || "Error"}\`): ${error.message || "unknown"}`,
|
|
177
|
+
`❌ *فشل تنفيذ الأمر الفرعي* (\`${error.name || "Error"}\`): ${
|
|
152
178
|
error.message || "غير معروف"
|
|
153
179
|
}`,
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
180
|
+
),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|