levix-bot 4.1.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/dashboard/assets/{index-DngAcp-o.js → index-4AuqfnH5.js} +80 -80
- package/public/dashboard/index.html +1 -1
- package/scheduler.cjs +6 -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 +217 -87
- 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 +36 -18
- 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 +31 -12
- 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 -135
- 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 +69 -27
- 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 +40 -9
- 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 +163 -108
- package/src/commands/todo.cjs +31 -9
- package/src/commands/tts.cjs +25 -7
- package/src/commands/unblock.cjs +17 -4
- package/src/commands/weather.cjs +55 -17
- package/src/config/settings.cjs +1 -1
- package/src/handlers/command.handler.js +50 -10
- package/src/handlers/group.handler.js +5 -1
- package/src/handlers/message.handler.js +9 -0
- package/src/middleware/antispam.middleware.js +9 -2
- package/src/services/aiAgent.cjs +40 -39
- package/src/services/aiProviders.cjs +46 -19
- package/src/services/aiRouter.cjs +2 -1
- package/src/services/aiTools.cjs +2 -1
- package/src/utils/commandDocs.cjs +58 -0
- package/src/utils/geminiMedia.cjs +168 -0
- package/src/utils/i18n.cjs +113 -0
- package/src/utils/markdownParser.cjs +4 -2
- package/src/utils/memory.cjs +2 -1
- package/src/utils/permissionLevel.cjs +34 -6
- package/src/utils/providerUrl.cjs +29 -2
- package/src/utils/sendBotMessage.cjs +7 -3
- package/src/utils/sendBotMessage.esm.js +13 -3
- package/src/utils/statusMessage.cjs +11 -4
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
|
@@ -4,6 +4,7 @@ const { getGroupSettings, saveGroupSettings } = require("../utils/storage.cjs");
|
|
|
4
4
|
const { isOwnerJidSync, isAdminInGroupSync } = require("../utils/permissions.cjs");
|
|
5
5
|
const { visibleText } = require("../utils/messageContent.cjs");
|
|
6
6
|
const { resolveGroupMetadata } = require("../utils/groupMetadataCache.cjs");
|
|
7
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
7
8
|
|
|
8
9
|
// الهيكل الافتراضي لإعدادات المراقبة
|
|
9
10
|
const defaultModSettings = {
|
|
@@ -49,9 +50,14 @@ function setFeatureEnabled(settings, key, enabled) {
|
|
|
49
50
|
module.exports = {
|
|
50
51
|
name: "mod",
|
|
51
52
|
aliases: ["moderation", "settings"],
|
|
52
|
-
description:
|
|
53
|
-
|
|
54
|
-
"
|
|
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
|
+
},
|
|
55
61
|
chat: "group", // يعمل في الجروبات فقط
|
|
56
62
|
botAdminRequired: false, // لا يتطلب أن يكون البوت مشرفًا لتغيير الإعدادات
|
|
57
63
|
|
|
@@ -65,7 +71,11 @@ module.exports = {
|
|
|
65
71
|
const senderIsAdmin = isAdminInGroupSync(groupMetadata, senderId);
|
|
66
72
|
const isOwner = msg.key.fromMe || isOwnerJidSync(senderId);
|
|
67
73
|
if (!senderIsAdmin && !isOwner) {
|
|
68
|
-
return sock.sendMessage(
|
|
74
|
+
return sock.sendMessage(
|
|
75
|
+
groupId,
|
|
76
|
+
{ text: tr("🚫 This command is for admins only.", "🚫 هذا الأمر للمشرفين فقط.") },
|
|
77
|
+
{ quoted: msg },
|
|
78
|
+
);
|
|
69
79
|
}
|
|
70
80
|
|
|
71
81
|
const command = args[0]?.toLowerCase();
|
|
@@ -80,7 +90,12 @@ module.exports = {
|
|
|
80
90
|
if (!feature) {
|
|
81
91
|
return sock.sendMessage(
|
|
82
92
|
groupId,
|
|
83
|
-
{
|
|
93
|
+
{
|
|
94
|
+
text: tr(
|
|
95
|
+
`⚠️ There is no feature called "${args[1] || ""}".`,
|
|
96
|
+
`⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
|
|
97
|
+
),
|
|
98
|
+
},
|
|
84
99
|
{ quoted: msg },
|
|
85
100
|
);
|
|
86
101
|
}
|
|
@@ -88,7 +103,7 @@ module.exports = {
|
|
|
88
103
|
saveGroupSettings(groupId, settings);
|
|
89
104
|
await sock.sendMessage(
|
|
90
105
|
groupId,
|
|
91
|
-
{ text: `✅ تم تفعيل ميزة *${feature}*.` },
|
|
106
|
+
{ text: tr(`✅ *${feature}* is on.`, `✅ تم تفعيل ميزة *${feature}*.`) },
|
|
92
107
|
{ quoted: msg },
|
|
93
108
|
);
|
|
94
109
|
break;
|
|
@@ -97,7 +112,12 @@ module.exports = {
|
|
|
97
112
|
if (!feature) {
|
|
98
113
|
return sock.sendMessage(
|
|
99
114
|
groupId,
|
|
100
|
-
{
|
|
115
|
+
{
|
|
116
|
+
text: tr(
|
|
117
|
+
`⚠️ There is no feature called "${args[1] || ""}".`,
|
|
118
|
+
`⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
|
|
119
|
+
),
|
|
120
|
+
},
|
|
101
121
|
{ quoted: msg },
|
|
102
122
|
);
|
|
103
123
|
}
|
|
@@ -105,18 +125,23 @@ module.exports = {
|
|
|
105
125
|
saveGroupSettings(groupId, settings);
|
|
106
126
|
await sock.sendMessage(
|
|
107
127
|
groupId,
|
|
108
|
-
{ text: `❌ تم تعطيل ميزة *${feature}*.` },
|
|
128
|
+
{ text: tr(`❌ *${feature}* is off.`, `❌ تم تعطيل ميزة *${feature}*.`) },
|
|
109
129
|
{ quoted: msg },
|
|
110
130
|
);
|
|
111
131
|
break;
|
|
112
132
|
|
|
113
133
|
case "status": {
|
|
114
|
-
let statusText = "📊 *حالة إعدادات المراقبة* 📊\n\n";
|
|
134
|
+
let statusText = tr("📊 *Moderation settings* 📊\n\n", "📊 *حالة إعدادات المراقبة* 📊\n\n");
|
|
115
135
|
for (const key of Object.values(FEATURE_KEYS)) {
|
|
116
|
-
const status = featureEnabled(settings, key)
|
|
136
|
+
const status = featureEnabled(settings, key)
|
|
137
|
+
? tr("✅ on", "✅ مفعل")
|
|
138
|
+
: tr("❌ off", "❌ معطل");
|
|
117
139
|
statusText += `› *${key}*: ${status}\n`;
|
|
118
140
|
}
|
|
119
|
-
statusText +=
|
|
141
|
+
statusText += tr(
|
|
142
|
+
`\n- To see the forbidden words, type: \`!mod words list\``,
|
|
143
|
+
`\n- لعرض قائمة الكلمات الممنوعة، اكتب: \`!mod words list\``,
|
|
144
|
+
);
|
|
120
145
|
await sock.sendMessage(groupId, { text: statusText }, { quoted: msg });
|
|
121
146
|
break;
|
|
122
147
|
}
|
|
@@ -128,31 +153,34 @@ module.exports = {
|
|
|
128
153
|
if (wordAction === "add") {
|
|
129
154
|
if (!word)
|
|
130
155
|
return sock.sendMessage(groupId, {
|
|
131
|
-
text: "الرجاء كتابة الكلمة التي تريد إضافتها.",
|
|
156
|
+
text: tr("Write the word you want to add.", "الرجاء كتابة الكلمة التي تريد إضافتها."),
|
|
132
157
|
});
|
|
133
158
|
if (!modSettings.forbiddenWords.list.includes(word)) {
|
|
134
159
|
modSettings.forbiddenWords.list.push(word.slice(0, 100));
|
|
135
160
|
}
|
|
136
161
|
saveGroupSettings(groupId, settings);
|
|
137
162
|
await sock.sendMessage(groupId, {
|
|
138
|
-
text:
|
|
163
|
+
text: tr(
|
|
164
|
+
`✅ Added "${word}" to the forbidden words.`,
|
|
165
|
+
`✅ تم إضافة "${word}" إلى قائمة الكلمات الممنوعة.`,
|
|
166
|
+
),
|
|
139
167
|
});
|
|
140
168
|
} else if (wordAction === "remove") {
|
|
141
169
|
if (!word)
|
|
142
170
|
return sock.sendMessage(groupId, {
|
|
143
|
-
text: "الرجاء كتابة الكلمة التي تريد إزالتها.",
|
|
171
|
+
text: tr("Write the word you want to remove.", "الرجاء كتابة الكلمة التي تريد إزالتها."),
|
|
144
172
|
});
|
|
145
173
|
modSettings.forbiddenWords.list = modSettings.forbiddenWords.list.filter(
|
|
146
174
|
(w) => w !== word,
|
|
147
175
|
);
|
|
148
176
|
saveGroupSettings(groupId, settings);
|
|
149
177
|
await sock.sendMessage(groupId, {
|
|
150
|
-
text: `🗑️ تم إزالة "${word}" من
|
|
178
|
+
text: tr(`🗑️ Removed "${word}" from the list.`, `🗑️ تم إزالة "${word}" من القائمة.`),
|
|
151
179
|
});
|
|
152
180
|
} else if (wordAction === "list") {
|
|
153
|
-
let listText = "🚫 *قائمة الكلمات الممنوعة* 🚫\n\n";
|
|
181
|
+
let listText = tr("🚫 *Forbidden words* 🚫\n\n", "🚫 *قائمة الكلمات الممنوعة* 🚫\n\n");
|
|
154
182
|
if (modSettings.forbiddenWords.list.length === 0) {
|
|
155
|
-
listText += "القائمة فارغة حاليًا.";
|
|
183
|
+
listText += tr("The list is empty.", "القائمة فارغة حاليًا.");
|
|
156
184
|
} else {
|
|
157
185
|
modSettings.forbiddenWords.list.forEach((w, i) => {
|
|
158
186
|
listText += `${i + 1}. ${w}\n`;
|
|
@@ -161,21 +189,32 @@ module.exports = {
|
|
|
161
189
|
await sock.sendMessage(groupId, { text: listText });
|
|
162
190
|
} else {
|
|
163
191
|
await sock.sendMessage(groupId, {
|
|
164
|
-
text:
|
|
192
|
+
text: tr(
|
|
193
|
+
"Wrong usage. Available: `add`, `remove`, `list`",
|
|
194
|
+
"استخدام خاطئ. الأوامر المتاحة: `add`, `remove`, `list`",
|
|
195
|
+
),
|
|
165
196
|
});
|
|
166
197
|
}
|
|
167
198
|
break;
|
|
168
199
|
}
|
|
169
200
|
|
|
170
201
|
default: {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
);
|
|
179
218
|
await sock.sendMessage(groupId, { text: helpText }, { quoted: msg });
|
|
180
219
|
break;
|
|
181
220
|
}
|
|
@@ -210,7 +249,10 @@ async function handleForbiddenWords(sock, msg) {
|
|
|
210
249
|
|
|
211
250
|
await sock.sendMessage(groupId, { delete: msg.key });
|
|
212
251
|
await sock.sendMessage(groupId, {
|
|
213
|
-
text:
|
|
252
|
+
text: tr(
|
|
253
|
+
`🚫 @${senderId.split("@")[0]}, that message had a forbidden word in it.`,
|
|
254
|
+
`🚫 يا @${senderId.split("@")[0]}، الرسالة فيها كلمة ممنوعة.`,
|
|
255
|
+
),
|
|
214
256
|
mentions: [senderId],
|
|
215
257
|
});
|
|
216
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
|
},
|