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
package/src/commands/loop.cjs
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// flood bot (and from getting the account banned).
|
|
14
14
|
|
|
15
15
|
const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
|
|
16
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
16
17
|
|
|
17
18
|
const MAX_ITEMS = 100; // total iterations, one-message mode
|
|
18
19
|
const MAX_SPLIT_ITEMS = 15; // total iterations, separate-messages mode
|
|
@@ -22,7 +23,28 @@ const SPLIT_GAP_MS = 900; // breathing room between separate sends
|
|
|
22
23
|
const SPLIT_FLAGS = new Set(["-s", "--split", "split", "منفصل", "منفصلة"]);
|
|
23
24
|
const NO_NUMBER_FLAGS = new Set(["-n", "--nonum", "--plain", "بدون-ترقيم"]);
|
|
24
25
|
|
|
25
|
-
const
|
|
26
|
+
const helpText = () =>
|
|
27
|
+
tr(
|
|
28
|
+
"🔁 *Loop*\n\n" +
|
|
29
|
+
"*Usage:*\n" +
|
|
30
|
+
"`!loop <count> <text>` — repeat the text in one message\n" +
|
|
31
|
+
"`!loop <from>-<to>` — print the numbers from/to\n" +
|
|
32
|
+
"`!loop <from>-<to>:<step>` — with a custom step\n\n" +
|
|
33
|
+
"*Options:*\n" +
|
|
34
|
+
"`-s` separate messages instead of one\n" +
|
|
35
|
+
"`-n` no numbering\n\n" +
|
|
36
|
+
"*Placeholders in the text:*\n" +
|
|
37
|
+
"`{n}` the current number · `{i}` the repetition number\n\n" +
|
|
38
|
+
"*Examples:*\n" +
|
|
39
|
+
"`!loop 5 hello`\n" +
|
|
40
|
+
"`!loop 1-10`\n" +
|
|
41
|
+
"`!loop 0-100:25 counter {n}`\n" +
|
|
42
|
+
"`!loop 3 good morning -s`\n\n" +
|
|
43
|
+
`_At most ${MAX_ITEMS} repetitions in one message, ${MAX_SPLIT_ITEMS} separate messages._`,
|
|
44
|
+
HELP_TEXT_AR,
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const HELP_TEXT_AR =
|
|
26
48
|
"🔁 *أمر التكرار*\n\n" +
|
|
27
49
|
"*الاستخدام:*\n" +
|
|
28
50
|
"`!loop <عدد> <النص>` — يكرر النص في رسالة واحدة\n" +
|
|
@@ -91,8 +113,14 @@ function renderLine(template, number, index) {
|
|
|
91
113
|
module.exports = {
|
|
92
114
|
name: "loop",
|
|
93
115
|
aliases: ["repeat", "كرر", "تكرار"],
|
|
94
|
-
description:
|
|
95
|
-
|
|
116
|
+
description: {
|
|
117
|
+
en: "Repeats text or numbers — in one message or as separate messages.",
|
|
118
|
+
ar: "يكرر نصًا أو أرقامًا — في رسالة واحدة أو في رسائل منفصلة.",
|
|
119
|
+
},
|
|
120
|
+
usage: {
|
|
121
|
+
en: "loop <count|from-to[:step]> [text] [-s separate messages] [-n no numbering]",
|
|
122
|
+
ar: "loop <عدد|من-إلى[:خطوة]> [النص] [-s رسائل منفصلة] [-n بدون ترقيم]",
|
|
123
|
+
},
|
|
96
124
|
chat: "all",
|
|
97
125
|
|
|
98
126
|
async execute(sock, msg, args) {
|
|
@@ -111,22 +139,28 @@ module.exports = {
|
|
|
111
139
|
}
|
|
112
140
|
|
|
113
141
|
const range = parseRange(rest[0]);
|
|
114
|
-
if (!range) return reply(
|
|
142
|
+
if (!range) return reply(helpText());
|
|
115
143
|
|
|
116
144
|
const template = rest.slice(1).join(" ").trim();
|
|
117
145
|
const limit = split ? MAX_SPLIT_ITEMS : MAX_ITEMS;
|
|
118
146
|
const requested = countOf(range);
|
|
119
147
|
|
|
120
|
-
|
|
148
|
+
const emptyRange = () =>
|
|
149
|
+
reply(tr("❌ That range doesn't produce any numbers.", "❌ المدى ده مش بيطلع أي أرقام."));
|
|
150
|
+
if (requested < 1) return emptyRange();
|
|
121
151
|
if (requested > limit) {
|
|
122
152
|
return reply(
|
|
123
|
-
|
|
124
|
-
|
|
153
|
+
tr(
|
|
154
|
+
`❌ ${requested} repetitions is too many.\n` +
|
|
155
|
+
`The limit is ${limit} ${split ? "separate messages" : "repetitions in one message"}.`,
|
|
156
|
+
`❌ ${requested} تكرار كتير أوي.\n` +
|
|
157
|
+
`الحد الأقصى ${limit} ${split ? "رسالة منفصلة" : "تكرار في الرسالة الواحدة"}.`,
|
|
158
|
+
),
|
|
125
159
|
);
|
|
126
160
|
}
|
|
127
161
|
|
|
128
162
|
const numbers = buildNumbers(range, limit);
|
|
129
|
-
if (!numbers.length) return
|
|
163
|
+
if (!numbers.length) return emptyRange();
|
|
130
164
|
|
|
131
165
|
// A bare count with text repeats the text; a range without text prints the
|
|
132
166
|
// numbers. Either way {n}/{i} are substituted per line.
|
|
@@ -148,7 +182,7 @@ module.exports = {
|
|
|
148
182
|
let text = lines.map((line, i) => (numbered ? `${i + 1}. ${line}` : line)).join("\n");
|
|
149
183
|
|
|
150
184
|
if (text.length > MAX_OUTPUT_CHARS) {
|
|
151
|
-
text = `${text.slice(0, MAX_OUTPUT_CHARS)}\n…\
|
|
185
|
+
text = `${text.slice(0, MAX_OUTPUT_CHARS)}\n…\n${tr("_(cut short — too long)_", "_(اتقصت عشان طولها)_")}`;
|
|
152
186
|
}
|
|
153
187
|
|
|
154
188
|
return reply(text);
|
package/src/commands/memory.cjs
CHANGED
|
@@ -19,6 +19,7 @@ const {
|
|
|
19
19
|
isAdminInGroupSync,
|
|
20
20
|
} = require("../utils/permissions.cjs");
|
|
21
21
|
const logger = require("../utils/logger.cjs");
|
|
22
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
22
23
|
|
|
23
24
|
const GLOBAL_WORDS = new Set(["global", "-g", "--global", "عام", "العام", "الكل"]);
|
|
24
25
|
|
|
@@ -37,8 +38,15 @@ function extractScope(args) {
|
|
|
37
38
|
return { scope, rest };
|
|
38
39
|
}
|
|
39
40
|
|
|
41
|
+
// "the global memory" / "this chat's memory", in the reply language.
|
|
42
|
+
function scopeName(scope) {
|
|
43
|
+
return scope === "global"
|
|
44
|
+
? tr("the global memory", "الذاكرة العامة")
|
|
45
|
+
: tr("this chat's memory", "ذاكرة الشات");
|
|
46
|
+
}
|
|
47
|
+
|
|
40
48
|
function formatEntries(entries, { limit = 30 } = {}) {
|
|
41
|
-
if (!entries.length) return "_(فاضية)_";
|
|
49
|
+
if (!entries.length) return tr("_(empty)_", "_(فاضية)_");
|
|
42
50
|
const shown = entries.slice(-limit);
|
|
43
51
|
const lines = shown.map((entry, index) => {
|
|
44
52
|
const number = entries.length - shown.length + index + 1;
|
|
@@ -48,15 +56,24 @@ function formatEntries(entries, { limit = 30 } = {}) {
|
|
|
48
56
|
return `*${number}.* ${entry.content}${meta}`;
|
|
49
57
|
});
|
|
50
58
|
const skipped = entries.length - shown.length;
|
|
51
|
-
return (
|
|
59
|
+
return (
|
|
60
|
+
(skipped > 0
|
|
61
|
+
? tr(`_(+${skipped} older ones not shown)_\n\n`, `_(+${skipped} أقدم مش معروضين)_\n\n`)
|
|
62
|
+
: "") + lines.join("\n")
|
|
63
|
+
);
|
|
52
64
|
}
|
|
53
65
|
|
|
54
66
|
module.exports = {
|
|
55
67
|
name: "memory",
|
|
56
68
|
aliases: ["mem", "ذاكرة", "remember"],
|
|
57
|
-
description:
|
|
58
|
-
|
|
59
|
-
"
|
|
69
|
+
description: {
|
|
70
|
+
en: "The bot's long-term memory (.md files): add, list, search, forget, or export the file.",
|
|
71
|
+
ar: "الذاكرة الدائمة للبوت (ملفات .md): إضافة، أو عرض، أو بحث، أو حذف، أو تصدير الملف.",
|
|
72
|
+
},
|
|
73
|
+
usage: {
|
|
74
|
+
en: "memory\nmemory add <fact>\nmemory add global <fact>\nmemory search <word>\nmemory forget <number|part of the text>\nmemory clear [global]\nmemory file [global]",
|
|
75
|
+
ar: "memory\nmemory add <المعلومة>\nmemory add global <المعلومة>\nmemory search <كلمة>\nmemory forget <رقم|جزء من النص>\nmemory clear [global]\nmemory file [global]",
|
|
76
|
+
},
|
|
60
77
|
chat: "all",
|
|
61
78
|
|
|
62
79
|
async execute(sock, msg, args, body, groupMetadata) {
|
|
@@ -74,14 +91,25 @@ module.exports = {
|
|
|
74
91
|
const reply = (text, extra = {}) =>
|
|
75
92
|
sendBotMessage(sock, chatId, { text, ...extra }, { replyTo: msg });
|
|
76
93
|
|
|
77
|
-
const denied = () =>
|
|
94
|
+
const denied = () =>
|
|
95
|
+
reply(
|
|
96
|
+
tr(
|
|
97
|
+
"🚫 That's for admins and the owner only. Anyone can add to this chat's memory.",
|
|
98
|
+
"🚫 ده للمشرفين والمالك بس. تقدر تضيف معلومة لذاكرة الشات عادي.",
|
|
99
|
+
),
|
|
100
|
+
);
|
|
78
101
|
|
|
79
102
|
try {
|
|
80
103
|
// ---------------------------------------------------------------- add
|
|
81
104
|
if (["add", "save", "احفظ", "ضيف", "اضف"].includes(action)) {
|
|
82
105
|
const content = rest.join(" ").trim();
|
|
83
106
|
if (!content) {
|
|
84
|
-
return reply(
|
|
107
|
+
return reply(
|
|
108
|
+
tr(
|
|
109
|
+
"Write the fact after the command.\nExample: `!memory add the meeting is every Tuesday at 9`",
|
|
110
|
+
"اكتب المعلومة بعد الأمر.\nمثال: `!memory add الاجتماع كل تلات الساعة ٩`",
|
|
111
|
+
),
|
|
112
|
+
);
|
|
85
113
|
}
|
|
86
114
|
if (scope === "global" && !botPrivileged) return denied();
|
|
87
115
|
|
|
@@ -94,7 +122,7 @@ module.exports = {
|
|
|
94
122
|
});
|
|
95
123
|
|
|
96
124
|
return reply(
|
|
97
|
-
`🧠
|
|
125
|
+
tr(`🧠 Saved to *${scopeName(scope)}*.\n`, `🧠 اتحفظت في *${scopeName(scope)}*.\n`) +
|
|
98
126
|
`\`${entry.id}\` — ${content.length > 80 ? content.slice(0, 80) + "…" : content}`,
|
|
99
127
|
);
|
|
100
128
|
}
|
|
@@ -102,17 +130,23 @@ module.exports = {
|
|
|
102
130
|
// ------------------------------------------------------------- search
|
|
103
131
|
if (["search", "find", "بحث", "دور"].includes(action)) {
|
|
104
132
|
const query = rest.join(" ").trim();
|
|
105
|
-
if (!query)
|
|
133
|
+
if (!query) {
|
|
134
|
+
return reply(tr("Write the word you're looking for.", "اكتب الكلمة اللي بتدور عليها."));
|
|
135
|
+
}
|
|
106
136
|
const chatHits = memory.searchMemory(query, { scope: "chat", chatId });
|
|
107
137
|
const globalHits = memory.searchMemory(query, { scope: "global" });
|
|
108
138
|
|
|
109
139
|
if (!chatHits.length && !globalHits.length) {
|
|
110
|
-
return reply(
|
|
140
|
+
return reply(
|
|
141
|
+
tr(`🔍 Nothing is saved about "${query}".`, `🔍 مفيش حاجة متسجلة عن "${query}".`),
|
|
142
|
+
);
|
|
111
143
|
}
|
|
112
144
|
return reply(
|
|
113
|
-
`🔍 *نتايج البحث عن* "${query}"\n\n` +
|
|
114
|
-
|
|
115
|
-
|
|
145
|
+
tr(`🔍 *Results for* "${query}"\n\n`, `🔍 *نتايج البحث عن* "${query}"\n\n`) +
|
|
146
|
+
tr(`*This chat (${chatHits.length}):*\n`, `*ذاكرة الشات (${chatHits.length}):*\n`) +
|
|
147
|
+
`${formatEntries(chatHits, { limit: 10 })}\n\n` +
|
|
148
|
+
tr(`*Global (${globalHits.length}):*\n`, `*الذاكرة العامة (${globalHits.length}):*\n`) +
|
|
149
|
+
formatEntries(globalHits, { limit: 10 }),
|
|
116
150
|
);
|
|
117
151
|
}
|
|
118
152
|
|
|
@@ -122,16 +156,24 @@ module.exports = {
|
|
|
122
156
|
const ref = rest.join(" ").trim();
|
|
123
157
|
if (!ref) {
|
|
124
158
|
return reply(
|
|
125
|
-
|
|
159
|
+
tr(
|
|
160
|
+
"Say what to forget: its number from `!memory`, or part of its text.\nExample: `!memory forget 3`",
|
|
161
|
+
"حدد اللي عايز تمسحه: رقمه من `!memory` أو جزء من نصه.\n" +
|
|
162
|
+
"مثال: `!memory forget 3`",
|
|
163
|
+
),
|
|
126
164
|
);
|
|
127
165
|
}
|
|
128
166
|
const removed = memory.removeMemory({ scope, chatId, ref });
|
|
129
167
|
return reply(
|
|
130
168
|
removed
|
|
131
|
-
?
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
169
|
+
? tr(
|
|
170
|
+
`🗑️ Forgotten: ${removed.content.slice(0, 120)}`,
|
|
171
|
+
`🗑️ اتمسحت: ${removed.content.slice(0, 120)}`,
|
|
172
|
+
)
|
|
173
|
+
: tr(
|
|
174
|
+
`Nothing in ${scopeName(scope)} matches "${ref}".`,
|
|
175
|
+
`مالقيتش حاجة تطابق "${ref}" في ${scopeName(scope)}.`,
|
|
176
|
+
),
|
|
135
177
|
);
|
|
136
178
|
}
|
|
137
179
|
|
|
@@ -141,10 +183,11 @@ module.exports = {
|
|
|
141
183
|
const count = memory.clearMemory({ scope, chatId });
|
|
142
184
|
return reply(
|
|
143
185
|
count
|
|
144
|
-
?
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
186
|
+
? tr(
|
|
187
|
+
`🧹 Cleared *${count}* facts from ${scopeName(scope)}.`,
|
|
188
|
+
`🧹 اتمسحت *${count}* معلومة من ${scopeName(scope)}.`,
|
|
189
|
+
)
|
|
190
|
+
: tr("The memory was already empty.", "الذاكرة كانت فاضية أصلاً."),
|
|
148
191
|
);
|
|
149
192
|
}
|
|
150
193
|
|
|
@@ -153,7 +196,12 @@ module.exports = {
|
|
|
153
196
|
if (scope === "global" ? !botPrivileged : !botPrivileged && !groupAdmin) return denied();
|
|
154
197
|
const filePath = memory.memoryFilePath(scope, chatId);
|
|
155
198
|
if (!fs.existsSync(filePath)) {
|
|
156
|
-
return reply(
|
|
199
|
+
return reply(
|
|
200
|
+
tr(
|
|
201
|
+
"There is no memory file yet — start with `!memory add ...`.",
|
|
202
|
+
"مفيش ملف ذاكرة لسه — ابدأ بـ `!memory add ...`.",
|
|
203
|
+
),
|
|
204
|
+
);
|
|
157
205
|
}
|
|
158
206
|
return sendBotMessage(
|
|
159
207
|
sock,
|
|
@@ -162,7 +210,7 @@ module.exports = {
|
|
|
162
210
|
document: fs.readFileSync(filePath),
|
|
163
211
|
mimetype: "text/markdown",
|
|
164
212
|
fileName: scope === "global" ? "global.md" : `${chatId}.md`,
|
|
165
|
-
caption: `🧠
|
|
213
|
+
caption: tr(`🧠 The file for ${scopeName(scope)}`, `🧠 ملف ${scopeName(scope)}`),
|
|
166
214
|
},
|
|
167
215
|
{ replyTo: msg },
|
|
168
216
|
);
|
|
@@ -174,15 +222,27 @@ module.exports = {
|
|
|
174
222
|
const entries = memory.listMemory({ scope: target, chatId });
|
|
175
223
|
|
|
176
224
|
return reply(
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
225
|
+
tr(
|
|
226
|
+
`🧠 *${target === "global" ? "Global memory" : "This chat's memory"}* ` +
|
|
227
|
+
`(${entries.length} facts)\n\n` +
|
|
228
|
+
`${formatEntries(entries)}\n\n` +
|
|
229
|
+
`_Chat: ${stats.chatCount} · Global: ${stats.globalCount}_\n` +
|
|
230
|
+
"`!memory add <fact>` · `!memory add global <fact>` · `!memory forget <number>` · `!memory file`",
|
|
231
|
+
`🧠 *${target === "global" ? "الذاكرة العامة" : "ذاكرة المحادثة دي"}* ` +
|
|
232
|
+
`(${entries.length} معلومة)\n\n` +
|
|
233
|
+
`${formatEntries(entries)}\n\n` +
|
|
234
|
+
`_الشات: ${stats.chatCount} · العام: ${stats.globalCount}_\n` +
|
|
235
|
+
"`!memory add <معلومة>` · `!memory add global <معلومة>` · `!memory forget <رقم>` · `!memory file`",
|
|
236
|
+
),
|
|
182
237
|
);
|
|
183
238
|
} catch (error) {
|
|
184
239
|
logger.error({ err: error }, "[memory] command failed");
|
|
185
|
-
return reply(
|
|
240
|
+
return reply(
|
|
241
|
+
tr(
|
|
242
|
+
`❌ *Memory problem*\n\n*Details:* ${error.message || error}`,
|
|
243
|
+
`❌ *مشكلة في الذاكرة*\n\n*التفاصيل:* ${error.message || error}`,
|
|
244
|
+
),
|
|
245
|
+
);
|
|
186
246
|
}
|
|
187
247
|
},
|
|
188
248
|
};
|
package/src/commands/mod.cjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
const { getGroupSettings, saveGroupSettings } = require("../utils/storage.cjs");
|
|
4
4
|
const { isOwnerJidSync, isAdminInGroupSync } = require("../utils/permissions.cjs");
|
|
5
5
|
const { visibleText } = require("../utils/messageContent.cjs");
|
|
6
|
+
const { resolveGroupMetadata } = require("../utils/groupMetadataCache.cjs");
|
|
7
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
6
8
|
|
|
7
9
|
// الهيكل الافتراضي لإعدادات المراقبة
|
|
8
10
|
const defaultModSettings = {
|
|
@@ -48,9 +50,14 @@ function setFeatureEnabled(settings, key, enabled) {
|
|
|
48
50
|
module.exports = {
|
|
49
51
|
name: "mod",
|
|
50
52
|
aliases: ["moderation", "settings"],
|
|
51
|
-
description:
|
|
52
|
-
|
|
53
|
-
"
|
|
53
|
+
description: {
|
|
54
|
+
en: "Controls the group's moderation settings.",
|
|
55
|
+
ar: "يتحكم في إعدادات الإشراف على المجموعة.",
|
|
56
|
+
},
|
|
57
|
+
usage: {
|
|
58
|
+
en: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod words <add|remove> <word>\nmod words list",
|
|
59
|
+
ar: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod words <add|remove> <الكلمة>\nmod words list",
|
|
60
|
+
},
|
|
54
61
|
chat: "group", // يعمل في الجروبات فقط
|
|
55
62
|
botAdminRequired: false, // لا يتطلب أن يكون البوت مشرفًا لتغيير الإعدادات
|
|
56
63
|
|
|
@@ -64,7 +71,11 @@ module.exports = {
|
|
|
64
71
|
const senderIsAdmin = isAdminInGroupSync(groupMetadata, senderId);
|
|
65
72
|
const isOwner = msg.key.fromMe || isOwnerJidSync(senderId);
|
|
66
73
|
if (!senderIsAdmin && !isOwner) {
|
|
67
|
-
return sock.sendMessage(
|
|
74
|
+
return sock.sendMessage(
|
|
75
|
+
groupId,
|
|
76
|
+
{ text: tr("🚫 This command is for admins only.", "🚫 هذا الأمر للمشرفين فقط.") },
|
|
77
|
+
{ quoted: msg },
|
|
78
|
+
);
|
|
68
79
|
}
|
|
69
80
|
|
|
70
81
|
const command = args[0]?.toLowerCase();
|
|
@@ -79,7 +90,12 @@ module.exports = {
|
|
|
79
90
|
if (!feature) {
|
|
80
91
|
return sock.sendMessage(
|
|
81
92
|
groupId,
|
|
82
|
-
{
|
|
93
|
+
{
|
|
94
|
+
text: tr(
|
|
95
|
+
`⚠️ There is no feature called "${args[1] || ""}".`,
|
|
96
|
+
`⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
|
|
97
|
+
),
|
|
98
|
+
},
|
|
83
99
|
{ quoted: msg },
|
|
84
100
|
);
|
|
85
101
|
}
|
|
@@ -87,7 +103,7 @@ module.exports = {
|
|
|
87
103
|
saveGroupSettings(groupId, settings);
|
|
88
104
|
await sock.sendMessage(
|
|
89
105
|
groupId,
|
|
90
|
-
{ text: `✅ تم تفعيل ميزة *${feature}*.` },
|
|
106
|
+
{ text: tr(`✅ *${feature}* is on.`, `✅ تم تفعيل ميزة *${feature}*.`) },
|
|
91
107
|
{ quoted: msg },
|
|
92
108
|
);
|
|
93
109
|
break;
|
|
@@ -96,7 +112,12 @@ module.exports = {
|
|
|
96
112
|
if (!feature) {
|
|
97
113
|
return sock.sendMessage(
|
|
98
114
|
groupId,
|
|
99
|
-
{
|
|
115
|
+
{
|
|
116
|
+
text: tr(
|
|
117
|
+
`⚠️ There is no feature called "${args[1] || ""}".`,
|
|
118
|
+
`⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
|
|
119
|
+
),
|
|
120
|
+
},
|
|
100
121
|
{ quoted: msg },
|
|
101
122
|
);
|
|
102
123
|
}
|
|
@@ -104,18 +125,23 @@ module.exports = {
|
|
|
104
125
|
saveGroupSettings(groupId, settings);
|
|
105
126
|
await sock.sendMessage(
|
|
106
127
|
groupId,
|
|
107
|
-
{ text: `❌ تم تعطيل ميزة *${feature}*.` },
|
|
128
|
+
{ text: tr(`❌ *${feature}* is off.`, `❌ تم تعطيل ميزة *${feature}*.`) },
|
|
108
129
|
{ quoted: msg },
|
|
109
130
|
);
|
|
110
131
|
break;
|
|
111
132
|
|
|
112
133
|
case "status": {
|
|
113
|
-
let statusText = "📊 *حالة إعدادات المراقبة* 📊\n\n";
|
|
134
|
+
let statusText = tr("📊 *Moderation settings* 📊\n\n", "📊 *حالة إعدادات المراقبة* 📊\n\n");
|
|
114
135
|
for (const key of Object.values(FEATURE_KEYS)) {
|
|
115
|
-
const status = featureEnabled(settings, key)
|
|
136
|
+
const status = featureEnabled(settings, key)
|
|
137
|
+
? tr("✅ on", "✅ مفعل")
|
|
138
|
+
: tr("❌ off", "❌ معطل");
|
|
116
139
|
statusText += `› *${key}*: ${status}\n`;
|
|
117
140
|
}
|
|
118
|
-
statusText +=
|
|
141
|
+
statusText += tr(
|
|
142
|
+
`\n- To see the forbidden words, type: \`!mod words list\``,
|
|
143
|
+
`\n- لعرض قائمة الكلمات الممنوعة، اكتب: \`!mod words list\``,
|
|
144
|
+
);
|
|
119
145
|
await sock.sendMessage(groupId, { text: statusText }, { quoted: msg });
|
|
120
146
|
break;
|
|
121
147
|
}
|
|
@@ -127,31 +153,34 @@ module.exports = {
|
|
|
127
153
|
if (wordAction === "add") {
|
|
128
154
|
if (!word)
|
|
129
155
|
return sock.sendMessage(groupId, {
|
|
130
|
-
text: "الرجاء كتابة الكلمة التي تريد إضافتها.",
|
|
156
|
+
text: tr("Write the word you want to add.", "الرجاء كتابة الكلمة التي تريد إضافتها."),
|
|
131
157
|
});
|
|
132
158
|
if (!modSettings.forbiddenWords.list.includes(word)) {
|
|
133
159
|
modSettings.forbiddenWords.list.push(word.slice(0, 100));
|
|
134
160
|
}
|
|
135
161
|
saveGroupSettings(groupId, settings);
|
|
136
162
|
await sock.sendMessage(groupId, {
|
|
137
|
-
text:
|
|
163
|
+
text: tr(
|
|
164
|
+
`✅ Added "${word}" to the forbidden words.`,
|
|
165
|
+
`✅ تم إضافة "${word}" إلى قائمة الكلمات الممنوعة.`,
|
|
166
|
+
),
|
|
138
167
|
});
|
|
139
168
|
} else if (wordAction === "remove") {
|
|
140
169
|
if (!word)
|
|
141
170
|
return sock.sendMessage(groupId, {
|
|
142
|
-
text: "الرجاء كتابة الكلمة التي تريد إزالتها.",
|
|
171
|
+
text: tr("Write the word you want to remove.", "الرجاء كتابة الكلمة التي تريد إزالتها."),
|
|
143
172
|
});
|
|
144
173
|
modSettings.forbiddenWords.list = modSettings.forbiddenWords.list.filter(
|
|
145
174
|
(w) => w !== word,
|
|
146
175
|
);
|
|
147
176
|
saveGroupSettings(groupId, settings);
|
|
148
177
|
await sock.sendMessage(groupId, {
|
|
149
|
-
text: `🗑️ تم إزالة "${word}" من
|
|
178
|
+
text: tr(`🗑️ Removed "${word}" from the list.`, `🗑️ تم إزالة "${word}" من القائمة.`),
|
|
150
179
|
});
|
|
151
180
|
} else if (wordAction === "list") {
|
|
152
|
-
let listText = "🚫 *قائمة الكلمات الممنوعة* 🚫\n\n";
|
|
181
|
+
let listText = tr("🚫 *Forbidden words* 🚫\n\n", "🚫 *قائمة الكلمات الممنوعة* 🚫\n\n");
|
|
153
182
|
if (modSettings.forbiddenWords.list.length === 0) {
|
|
154
|
-
listText += "القائمة فارغة حاليًا.";
|
|
183
|
+
listText += tr("The list is empty.", "القائمة فارغة حاليًا.");
|
|
155
184
|
} else {
|
|
156
185
|
modSettings.forbiddenWords.list.forEach((w, i) => {
|
|
157
186
|
listText += `${i + 1}. ${w}\n`;
|
|
@@ -160,21 +189,32 @@ module.exports = {
|
|
|
160
189
|
await sock.sendMessage(groupId, { text: listText });
|
|
161
190
|
} else {
|
|
162
191
|
await sock.sendMessage(groupId, {
|
|
163
|
-
text:
|
|
192
|
+
text: tr(
|
|
193
|
+
"Wrong usage. Available: `add`, `remove`, `list`",
|
|
194
|
+
"استخدام خاطئ. الأوامر المتاحة: `add`, `remove`, `list`",
|
|
195
|
+
),
|
|
164
196
|
});
|
|
165
197
|
}
|
|
166
198
|
break;
|
|
167
199
|
}
|
|
168
200
|
|
|
169
201
|
default: {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
202
|
+
const helpText = tr(
|
|
203
|
+
"🤖 *Moderation commands*\n\n" +
|
|
204
|
+
"• `!mod enable <feature>`\nTurn a feature on (antilink, antispam, forbiddenwords)\n\n" +
|
|
205
|
+
"• `!mod disable <feature>`\nTurn a feature off.\n\n" +
|
|
206
|
+
"• `!mod status`\nShow which features are on.\n\n" +
|
|
207
|
+
"• `!mod words add <word>`\nAdd a forbidden word.\n\n" +
|
|
208
|
+
"• `!mod words remove <word>`\nRemove a forbidden word.\n\n" +
|
|
209
|
+
"• `!mod words list`\nList the forbidden words.",
|
|
210
|
+
"🤖 *أوامر التحكم في المراقبة*\n\n" +
|
|
211
|
+
"• `!mod enable <feature>`\nلتفعيل ميزة (antilink, antispam, forbiddenwords)\n\n" +
|
|
212
|
+
"• `!mod disable <feature>`\nلتعطيل ميزة.\n\n" +
|
|
213
|
+
"• `!mod status`\nلعرض حالة الميزات الحالية.\n\n" +
|
|
214
|
+
"• `!mod words add <word>`\nلإضافة كلمة ممنوعة.\n\n" +
|
|
215
|
+
"• `!mod words remove <word>`\nلإزالة كلمة ممنوعة.\n\n" +
|
|
216
|
+
"• `!mod words list`\nلعرض قائمة الكلمات الممنوعة.",
|
|
217
|
+
);
|
|
178
218
|
await sock.sendMessage(groupId, { text: helpText }, { quoted: msg });
|
|
179
219
|
break;
|
|
180
220
|
}
|
|
@@ -197,7 +237,8 @@ async function handleForbiddenWords(sock, msg) {
|
|
|
197
237
|
|
|
198
238
|
const senderId = msg.key.participant || msg.key.remoteJid;
|
|
199
239
|
const senderIds = [senderId, msg.key.participantAlt, msg.key.participantPn].filter(Boolean);
|
|
200
|
-
|
|
240
|
+
// Cache-first: this runs on every group message while forbidden words are on.
|
|
241
|
+
const groupMetadata = await resolveGroupMetadata(sock, groupId);
|
|
201
242
|
if (
|
|
202
243
|
msg.key.fromMe ||
|
|
203
244
|
senderIds.some(isOwnerJidSync) ||
|
|
@@ -208,7 +249,10 @@ async function handleForbiddenWords(sock, msg) {
|
|
|
208
249
|
|
|
209
250
|
await sock.sendMessage(groupId, { delete: msg.key });
|
|
210
251
|
await sock.sendMessage(groupId, {
|
|
211
|
-
text:
|
|
252
|
+
text: tr(
|
|
253
|
+
`🚫 @${senderId.split("@")[0]}, that message had a forbidden word in it.`,
|
|
254
|
+
`🚫 يا @${senderId.split("@")[0]}، الرسالة فيها كلمة ممنوعة.`,
|
|
255
|
+
),
|
|
212
256
|
mentions: [senderId],
|
|
213
257
|
});
|
|
214
258
|
return true;
|
package/src/commands/notes.cjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// file: /commands/notes.js
|
|
2
2
|
const { getAllNotes } = require("../utils/storage.cjs");
|
|
3
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
name: "notes",
|
|
6
|
-
description:
|
|
7
|
-
|
|
7
|
+
description: {
|
|
8
|
+
en: "Lists all saved note keywords for the group.",
|
|
9
|
+
ar: "يعرض الكلمات المفتاحية لكل الملاحظات المحفوظة في المجموعة.",
|
|
10
|
+
},
|
|
11
|
+
usage: {
|
|
12
|
+
en: "notes",
|
|
13
|
+
ar: "notes",
|
|
14
|
+
},
|
|
8
15
|
chat: "all",
|
|
9
16
|
|
|
10
17
|
async execute(sock, msg) {
|
|
@@ -15,13 +22,16 @@ module.exports = {
|
|
|
15
22
|
|
|
16
23
|
if (keywords.length === 0) {
|
|
17
24
|
return await sock.sendMessage(groupId, {
|
|
18
|
-
text: "لا توجد ملاحظات محفوظة في هذا الجروب.",
|
|
25
|
+
text: tr("This group has no saved notes.", "لا توجد ملاحظات محفوظة في هذا الجروب."),
|
|
19
26
|
});
|
|
20
27
|
}
|
|
21
28
|
|
|
22
|
-
let reply = "*🔑 الكلمات المفتاحية للملاحظات المحفوظة:*\n\n";
|
|
29
|
+
let reply = tr("*🔑 Saved note keywords:*\n\n", "*🔑 الكلمات المفتاحية للملاحظات المحفوظة:*\n\n");
|
|
23
30
|
reply += keywords.map((kw) => `\`#${kw}\``).join("\n");
|
|
24
|
-
reply +=
|
|
31
|
+
reply += tr(
|
|
32
|
+
"\n\nTo get a note, use: `!note #keyword`",
|
|
33
|
+
"\n\nللحصول على ملاحظة، استخدم: `!note #keyword`",
|
|
34
|
+
);
|
|
25
35
|
|
|
26
36
|
await sock.sendMessage(groupId, { text: reply });
|
|
27
37
|
},
|