levix-bot 4.1.0 → 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-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 +159 -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 +44 -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 +99 -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/help.cjs
CHANGED
|
@@ -1,51 +1,70 @@
|
|
|
1
|
+
// !help — every command, or one command, in Arabic or English.
|
|
2
|
+
//
|
|
3
|
+
// help the list, in the bot's language
|
|
4
|
+
// help ar | help en the list, in that language
|
|
5
|
+
// help <command> one command, in the bot's language
|
|
6
|
+
// help <command> ar one command, in that language (`help ar <command>` too)
|
|
7
|
+
//
|
|
8
|
+
// "The bot's language" is the language every reply uses (utils/i18n.cjs): the
|
|
9
|
+
// `bot_language` setting, and in "auto" the language the message is written
|
|
10
|
+
// in — with command names counted as syntax, so `!help kick` is not English.
|
|
11
|
+
// Each command carries its own description and usage as `{ en, ar }`.
|
|
12
|
+
|
|
1
13
|
const fs = require("fs");
|
|
2
14
|
const path = require("path");
|
|
3
15
|
const logger = require("../utils/logger.cjs");
|
|
4
16
|
const brand = require("../config/brand.cjs");
|
|
5
17
|
const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
|
|
6
18
|
const runtimeConfig = require("../config/runtime-config.cjs");
|
|
19
|
+
const { parseLang, localize } = require("../utils/commandDocs.cjs");
|
|
20
|
+
const { detectLang, syntaxWords } = require("../utils/i18n.cjs");
|
|
21
|
+
|
|
22
|
+
// Every command module, the way the loader finds them: from the generated
|
|
23
|
+
// manifest in a packaged build (there is no directory to read inside an
|
|
24
|
+
// executable), else from the directory.
|
|
25
|
+
function commandModules() {
|
|
26
|
+
try {
|
|
27
|
+
const manifest = require("./_manifest.cjs");
|
|
28
|
+
if (Array.isArray(manifest)) {
|
|
29
|
+
return manifest.map((entry) => ({ module: entry.module, category: entry.category }));
|
|
30
|
+
}
|
|
31
|
+
} catch (error) {
|
|
32
|
+
if (error?.code !== "MODULE_NOT_FOUND") {
|
|
33
|
+
logger.error({ err: error }, "[help] command manifest failed to load");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
7
36
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
37
|
+
const found = [];
|
|
38
|
+
for (const entry of fs.readdirSync(__dirname, { withFileTypes: true })) {
|
|
39
|
+
if (entry.isDirectory()) {
|
|
40
|
+
for (const file of fs.readdirSync(path.join(__dirname, entry.name))) {
|
|
41
|
+
if (!file.endsWith(".cjs") || file.startsWith("_")) continue;
|
|
42
|
+
found.push({ file: path.join(__dirname, entry.name, file), category: entry.name });
|
|
43
|
+
}
|
|
44
|
+
} else if (entry.name.endsWith(".cjs") && !entry.name.startsWith("_")) {
|
|
45
|
+
found.push({ file: path.join(__dirname, entry.name), category: null });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return found.map(({ file, category }) => {
|
|
49
|
+
try {
|
|
50
|
+
return { module: require(file), category };
|
|
51
|
+
} catch (error) {
|
|
52
|
+
logger.error(error, `Could not load command from ${file}:`);
|
|
53
|
+
return { module: null, category };
|
|
18
54
|
}
|
|
19
55
|
});
|
|
20
|
-
|
|
21
|
-
return fileList;
|
|
22
56
|
}
|
|
23
57
|
|
|
24
58
|
// Cache the loaded command modules so we don't re-require on every invocation.
|
|
25
59
|
let cached = null;
|
|
26
60
|
function loadAllCommands() {
|
|
27
61
|
if (cached) return cached;
|
|
28
|
-
const commandsPath = path.join(__dirname);
|
|
29
|
-
const files = getAllCommandFiles(commandsPath).filter(
|
|
30
|
-
(file) => path.basename(file) !== "help.cjs" && path.basename(file) !== "help.js",
|
|
31
|
-
);
|
|
32
62
|
|
|
33
63
|
const commands = { general: [], group: [] };
|
|
34
|
-
for (const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (!command?.name || !command?.description) continue;
|
|
38
|
-
const relativePath = path.relative(commandsPath, file);
|
|
39
|
-
if (path.dirname(relativePath) === "group") {
|
|
40
|
-
commands.group.push(command);
|
|
41
|
-
} else {
|
|
42
|
-
commands.general.push(command);
|
|
43
|
-
}
|
|
44
|
-
} catch (error) {
|
|
45
|
-
logger.error(error, `Could not load command from ${file}:`);
|
|
46
|
-
}
|
|
64
|
+
for (const { module: command, category } of commandModules()) {
|
|
65
|
+
if (!command?.name || !command?.description || command === module.exports) continue;
|
|
66
|
+
(category === "group" ? commands.group : commands.general).push(command);
|
|
47
67
|
}
|
|
48
|
-
|
|
49
68
|
commands.general.push(module.exports);
|
|
50
69
|
|
|
51
70
|
// Build alias index for inverse lookup.
|
|
@@ -63,6 +82,15 @@ function loadAllCommands() {
|
|
|
63
82
|
return cached;
|
|
64
83
|
}
|
|
65
84
|
|
|
85
|
+
/** Every command's name, aliases and keywords — what may follow !help. */
|
|
86
|
+
function helpSyntax(commands) {
|
|
87
|
+
const words = new Set();
|
|
88
|
+
for (const cmd of [...commands.general, ...commands.group]) {
|
|
89
|
+
for (const word of syntaxWords(cmd, aliasesOf(cmd))) words.add(word);
|
|
90
|
+
}
|
|
91
|
+
return words;
|
|
92
|
+
}
|
|
93
|
+
|
|
66
94
|
function findCommand(query, commands, aliasIndex) {
|
|
67
95
|
const q = query.toLowerCase();
|
|
68
96
|
const all = [...commands.general, ...commands.group];
|
|
@@ -84,11 +112,11 @@ function aliasesOf(command) {
|
|
|
84
112
|
}
|
|
85
113
|
|
|
86
114
|
/**
|
|
87
|
-
* `usage` is authored WITHOUT the prefix ("kick @
|
|
115
|
+
* `usage` is authored WITHOUT the prefix ("kick @member [reason]") and may hold
|
|
88
116
|
* several variants separated by newlines. Render each one with the live prefix.
|
|
89
117
|
*/
|
|
90
|
-
function usageLines(command, prefix) {
|
|
91
|
-
const raw = command.usage || command.name;
|
|
118
|
+
function usageLines(command, prefix, lang) {
|
|
119
|
+
const raw = localize(command.usage, lang) || command.name;
|
|
92
120
|
return String(raw)
|
|
93
121
|
.split("\n")
|
|
94
122
|
.map((line) => line.trim())
|
|
@@ -96,135 +124,242 @@ function usageLines(command, prefix) {
|
|
|
96
124
|
.map((line) => `${prefix}${line}`);
|
|
97
125
|
}
|
|
98
126
|
|
|
127
|
+
function examplesOf(command, lang) {
|
|
128
|
+
const examples = command.examples;
|
|
129
|
+
if (Array.isArray(examples)) return examples;
|
|
130
|
+
const picked = examples && (examples[lang] || examples.en || examples.ar);
|
|
131
|
+
return Array.isArray(picked) ? picked : [];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Everything !help itself says, in both languages.
|
|
135
|
+
const TEXT = {
|
|
136
|
+
en: {
|
|
137
|
+
title: `🤖 ${brand.name} Commands`,
|
|
138
|
+
general: "General Commands",
|
|
139
|
+
group: "Group Commands",
|
|
140
|
+
legendTitle: "Legend",
|
|
141
|
+
legend: "`<...>` required · `[...]` optional · `a|b` pick one",
|
|
142
|
+
languageTitle: "Language",
|
|
143
|
+
footer: (p) => `Type *${p}help <command>* for details`,
|
|
144
|
+
detailTitle: "Command Details",
|
|
145
|
+
command: "Command:",
|
|
146
|
+
aliases: "Aliases:",
|
|
147
|
+
description: "Description:",
|
|
148
|
+
usage: "Usage:",
|
|
149
|
+
examples: "Examples:",
|
|
150
|
+
where: "Where:",
|
|
151
|
+
permission: "Permission:",
|
|
152
|
+
userAdmin: "⚠️ You must be a group admin",
|
|
153
|
+
botAdmin: "⚠️ The bot must be a group admin",
|
|
154
|
+
detailLegend: "`<...>` required · `[...]` optional",
|
|
155
|
+
notFound: (query, p) =>
|
|
156
|
+
`❌ Command "*${query}*" not found.\nType \`${p}help\` to list every command.`,
|
|
157
|
+
permissions: {
|
|
158
|
+
MEMBERS: "Everyone",
|
|
159
|
+
ALL: "Everyone",
|
|
160
|
+
ADMINS_ONLY: "Group admins only",
|
|
161
|
+
ADMINS_OWNER: "Group admins and the owner",
|
|
162
|
+
OWNER_ONLY: "Owner only",
|
|
163
|
+
},
|
|
164
|
+
chats: {
|
|
165
|
+
all: "All chats",
|
|
166
|
+
group: "Groups only",
|
|
167
|
+
private: "Private chats only",
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
ar: {
|
|
171
|
+
title: `🤖 أوامر ${brand.name}`,
|
|
172
|
+
general: "الأوامر العامة",
|
|
173
|
+
group: "أوامر المجموعات",
|
|
174
|
+
legendTitle: "الرموز",
|
|
175
|
+
legend: "`<...>` مطلوب · `[...]` اختياري · `a|b` اختر واحدًا",
|
|
176
|
+
languageTitle: "اللغة",
|
|
177
|
+
footer: (p) => `اكتب *${p}help <أمر>* لمزيد من التفاصيل`,
|
|
178
|
+
detailTitle: "تفاصيل الأمر",
|
|
179
|
+
command: "الأمر:",
|
|
180
|
+
aliases: "الاختصارات:",
|
|
181
|
+
description: "الوصف:",
|
|
182
|
+
usage: "الاستخدام:",
|
|
183
|
+
examples: "أمثلة:",
|
|
184
|
+
where: "المكان:",
|
|
185
|
+
permission: "الصلاحية:",
|
|
186
|
+
userAdmin: "⚠️ يجب أن تكون مشرفًا",
|
|
187
|
+
botAdmin: "⚠️ يجب أن يكون البوت مشرفًا",
|
|
188
|
+
detailLegend: "`<...>` مطلوب · `[...]` اختياري",
|
|
189
|
+
notFound: (query, p) => `❌ الأمر "*${query}*" غير موجود.\nاكتب \`${p}help\` لعرض كل الأوامر.`,
|
|
190
|
+
permissions: {
|
|
191
|
+
MEMBERS: "الجميع",
|
|
192
|
+
ALL: "الجميع",
|
|
193
|
+
ADMINS_ONLY: "المشرفون فقط",
|
|
194
|
+
ADMINS_OWNER: "المشرفون والمالك",
|
|
195
|
+
OWNER_ONLY: "المالك فقط",
|
|
196
|
+
},
|
|
197
|
+
chats: {
|
|
198
|
+
all: "كل المحادثات",
|
|
199
|
+
group: "المجموعات فقط",
|
|
200
|
+
private: "المحادثات الخاصة فقط",
|
|
201
|
+
},
|
|
202
|
+
},
|
|
203
|
+
};
|
|
204
|
+
|
|
99
205
|
// Permission level as configured for this command (group sub-commands live in
|
|
100
206
|
// their own map). Shown in the detail view so members know why a command is
|
|
101
207
|
// refusing them.
|
|
102
|
-
|
|
103
|
-
MEMBERS: "الكل",
|
|
104
|
-
ALL: "الكل",
|
|
105
|
-
ADMINS_ONLY: "المشرفين فقط",
|
|
106
|
-
ADMINS_OWNER: "المشرفين والمالك",
|
|
107
|
-
OWNER_ONLY: "المالك فقط",
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
function permissionFor(command, isGroupCommand) {
|
|
208
|
+
function permissionFor(command, isGroupCommand, t) {
|
|
111
209
|
const level = runtimeConfig.getPermission(
|
|
112
210
|
isGroupCommand ? `group:${command.name}` : command.name,
|
|
113
211
|
);
|
|
114
|
-
return
|
|
212
|
+
return t.permissions[level] || level;
|
|
115
213
|
}
|
|
116
214
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
215
|
+
/** A language word may sit anywhere after !help; whatever is left is the command. */
|
|
216
|
+
function parseArgs(args = []) {
|
|
217
|
+
let lang = null;
|
|
218
|
+
const rest = [];
|
|
219
|
+
for (const arg of args) {
|
|
220
|
+
const picked = lang ? null : parseLang(arg);
|
|
221
|
+
if (picked) lang = picked;
|
|
222
|
+
else rest.push(arg);
|
|
223
|
+
}
|
|
224
|
+
return { lang, query: rest[0] || null };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function renderList(commands, prefix, lang) {
|
|
228
|
+
const t = TEXT[lang];
|
|
229
|
+
const section = (title, list) => {
|
|
230
|
+
let text = `├─ *${title}*\n`;
|
|
231
|
+
list.forEach((cmd) => {
|
|
232
|
+
const aliases = aliasesOf(cmd);
|
|
233
|
+
const aliasSnippet = aliases.length
|
|
234
|
+
? ` _(${aliases.map((a) => prefix + a).join(", ")})_`
|
|
235
|
+
: "";
|
|
236
|
+
// The description goes on its own line UNDER the command, never
|
|
237
|
+
// beside it: WhatsApp lays a line out by its first strong character,
|
|
238
|
+
// and an Arabic description next to an LTR command name gets its
|
|
239
|
+
// words reordered into unreadability. The colon ends the name line.
|
|
240
|
+
text += `│ ◦ *${prefix}${cmd.name}*${aliasSnippet}:\n`;
|
|
241
|
+
text += `│ ${localize(cmd.description, lang)}\n`;
|
|
242
|
+
// The parameters are the whole point of a help list — show them.
|
|
243
|
+
usageLines(cmd, prefix, lang).forEach((line) => {
|
|
244
|
+
text += `│ ⌨️ \`${line}\`\n`;
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
return `${text}│\n`;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// A command switched off from the dashboard can't run, so it has no
|
|
251
|
+
// business in the menu.
|
|
252
|
+
const live = (list) => list.filter((cmd) => !runtimeConfig.isDisabled(cmd.name));
|
|
253
|
+
const general = live(commands.general);
|
|
254
|
+
const group = live(commands.group);
|
|
255
|
+
|
|
256
|
+
let text = `╭───「 *${t.title}* 」\n│\n`;
|
|
257
|
+
if (general.length) text += section(t.general, general);
|
|
258
|
+
if (group.length) text += section(t.group, group);
|
|
259
|
+
|
|
260
|
+
text += `├─ *${t.legendTitle}*\n`;
|
|
261
|
+
text += `│ ${t.legend}\n│\n`;
|
|
262
|
+
// Starts with the LTR command, so the line lays out left-to-right in both
|
|
263
|
+
// menus and each language name stays next to its own command.
|
|
264
|
+
text += `├─ *${t.languageTitle}*\n`;
|
|
265
|
+
text += `│ \`${prefix}help ar\` — العربية · \`${prefix}help en\` — English\n│\n`;
|
|
266
|
+
text += `╰───「 ${t.footer(prefix)} 」`;
|
|
267
|
+
return text;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function renderDetail(command, isGroupCommand, prefix, lang) {
|
|
271
|
+
const t = TEXT[lang];
|
|
272
|
+
// Same bidi rule as the list: a label ends its own line and the value
|
|
273
|
+
// starts the next one, so no line mixes RTL and LTR content.
|
|
274
|
+
let text = `╭───「 *${t.detailTitle}* 」\n│\n`;
|
|
275
|
+
text += `├─ *${t.command}*\n│ ${prefix}${command.name}\n`;
|
|
276
|
+
|
|
277
|
+
const commandAliases = aliasesOf(command);
|
|
278
|
+
if (commandAliases.length) {
|
|
279
|
+
text += `├─ *${t.aliases}*\n│ ${commandAliases.map((a) => `${prefix}${a}`).join(", ")}\n`;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const description = localize(command.description, lang);
|
|
283
|
+
if (description) {
|
|
284
|
+
text += `├─ *${t.description}*\n│ ${description}\n`;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
text += `├─ *${t.usage}*\n`;
|
|
288
|
+
usageLines(command, prefix, lang).forEach((line) => {
|
|
289
|
+
text += `│ \`${line}\`\n`;
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
const examples = examplesOf(command, lang);
|
|
293
|
+
if (examples.length) {
|
|
294
|
+
text += `├─ *${t.examples}*\n`;
|
|
295
|
+
examples.forEach((example) => {
|
|
296
|
+
text += `│ \`${prefix}${example}\`\n`;
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
text += `├─ *${t.where}*\n│ ${t.chats[command.chat] || command.chat || t.chats.all}\n`;
|
|
301
|
+
text += `├─ *${t.permission}*\n│ ${permissionFor(command, isGroupCommand, t)}\n`;
|
|
302
|
+
|
|
303
|
+
if (command.userAdminRequired) text += `├─ ${t.userAdmin}\n`;
|
|
304
|
+
if (command.botAdminRequired) text += `├─ ${t.botAdmin}\n`;
|
|
305
|
+
|
|
306
|
+
text += `│\n├─ ${t.detailLegend}\n`;
|
|
307
|
+
text += `│\n╰───「 ${brand.name} 」`;
|
|
308
|
+
return text;
|
|
309
|
+
}
|
|
122
310
|
|
|
123
311
|
module.exports = {
|
|
124
312
|
name: "help",
|
|
125
|
-
aliases: ["menu", "commands", "h"],
|
|
126
|
-
description:
|
|
127
|
-
|
|
313
|
+
aliases: ["menu", "commands", "h", "مساعدة", "الاوامر", "اوامر"],
|
|
314
|
+
description: {
|
|
315
|
+
en: "Lists every command, or shows the details of one — in Arabic or English.",
|
|
316
|
+
ar: "يعرض كل الأوامر أو تفاصيل أمر واحد — بالعربية أو الإنجليزية.",
|
|
317
|
+
},
|
|
318
|
+
usage: {
|
|
319
|
+
en: "help [ar|en]\nhelp <command> [ar|en]",
|
|
320
|
+
ar: "help [ar|en]\nhelp <اسم الأمر> [ar|en]",
|
|
321
|
+
},
|
|
128
322
|
chat: "all",
|
|
129
323
|
|
|
130
|
-
async execute(sock, msg, args) {
|
|
324
|
+
async execute(sock, msg, args = [], _body = "", _groupMetadata = null, ctx = {}) {
|
|
131
325
|
const prefix = currentPrefix();
|
|
132
326
|
const { commands, aliasIndex } = loadAllCommands();
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
text += `│ ${cmd.description}\n`;
|
|
148
|
-
// The parameters are the whole point of a help list — show them.
|
|
149
|
-
usageLines(cmd, prefix).forEach((line) => {
|
|
150
|
-
text += `│ ⌨️ \`${line}\`\n`;
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
return `${text}│\n`;
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
// A command switched off from the dashboard can't run, so it has no
|
|
157
|
-
// business in the menu.
|
|
158
|
-
const live = (list) => list.filter((cmd) => !runtimeConfig.isDisabled(cmd.name));
|
|
159
|
-
|
|
160
|
-
const general = live(commands.general);
|
|
161
|
-
const group = live(commands.group);
|
|
162
|
-
|
|
163
|
-
let helpText = `╭───「 *🤖 ${brand.name} Commands* 」\n│\n`;
|
|
164
|
-
if (general.length) helpText += section("General Commands", general);
|
|
165
|
-
if (group.length) helpText += section("Group Commands", group);
|
|
166
|
-
|
|
167
|
-
helpText += `├─ *الرموز*\n`;
|
|
168
|
-
helpText += `│ \`<...>\` مطلوب · \`[...]\` اختياري · \`a|b\` اختر واحد\n│\n`;
|
|
169
|
-
helpText += `╰───「 اكتب *${prefix}help <أمر>* لتفاصيل أكتر 」`;
|
|
170
|
-
|
|
171
|
-
return sendBotMessage(sock, msg.key.remoteJid, { text: helpText }, { replyTo: msg });
|
|
327
|
+
const parsed = parseArgs(args);
|
|
328
|
+
// Command names after !help are syntax, not English: `!help kick` on an
|
|
329
|
+
// auto bot is answered like any bare command.
|
|
330
|
+
const lang =
|
|
331
|
+
parsed.lang ||
|
|
332
|
+
detectLang(`${ctx?.invokedName || ""} ${args.join(" ")}`, { syntax: helpSyntax(commands) });
|
|
333
|
+
|
|
334
|
+
if (!parsed.query) {
|
|
335
|
+
return sendBotMessage(
|
|
336
|
+
sock,
|
|
337
|
+
msg.key.remoteJid,
|
|
338
|
+
{ text: renderList(commands, prefix, lang) },
|
|
339
|
+
{ replyTo: msg },
|
|
340
|
+
);
|
|
172
341
|
}
|
|
173
342
|
|
|
174
|
-
const query =
|
|
343
|
+
const query = parsed.query.startsWith(prefix)
|
|
344
|
+
? parsed.query.slice(prefix.length)
|
|
345
|
+
: parsed.query;
|
|
175
346
|
const command = findCommand(query, commands, aliasIndex);
|
|
176
347
|
|
|
177
348
|
if (!command) {
|
|
178
349
|
return sendBotMessage(
|
|
179
350
|
sock,
|
|
180
351
|
msg.key.remoteJid,
|
|
181
|
-
{
|
|
182
|
-
text: `❌ الأمر "*${args[0]}*" غير موجود.\n` + `اكتب \`${prefix}help\` لعرض كل الأوامر.`,
|
|
183
|
-
},
|
|
352
|
+
{ text: TEXT[lang].notFound(parsed.query, prefix) },
|
|
184
353
|
{ replyTo: msg },
|
|
185
354
|
);
|
|
186
355
|
}
|
|
187
356
|
|
|
188
|
-
// Same bidi rule as the list: an Arabic label ends its own line and the
|
|
189
|
-
// value starts the next one, so no line mixes RTL and LTR content.
|
|
190
|
-
let usageText = `╭───「 *Command Details* 」\n│\n`;
|
|
191
|
-
usageText += `├─ *الأمر:*\n│ ${prefix}${command.name}\n`;
|
|
192
|
-
|
|
193
|
-
const commandAliases = aliasesOf(command);
|
|
194
|
-
if (commandAliases.length) {
|
|
195
|
-
usageText += `├─ *اختصارات:*\n│ ${commandAliases.map((a) => `${prefix}${a}`).join(", ")}\n`;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if (command.description) {
|
|
199
|
-
usageText += `├─ *الوصف:*\n│ ${command.description}\n`;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
usageText += `├─ *الاستخدام:*\n`;
|
|
203
|
-
usageLines(command, prefix).forEach((line) => {
|
|
204
|
-
usageText += `│ \`${line}\`\n`;
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
if (command.examples?.length) {
|
|
208
|
-
usageText += `├─ *أمثلة:*\n`;
|
|
209
|
-
command.examples.forEach((example) => {
|
|
210
|
-
usageText += `│ \`${prefix}${example}\`\n`;
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
usageText += `├─ *المكان:*\n│ ${CHAT_LABELS[command.chat] || command.chat || "كل المحادثات"}\n`;
|
|
215
357
|
const isGroupCommand = commands.group.includes(command);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
usageText += `├─ ⚠️ لازم البوت يكون مشرف\n`;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
usageText += `│\n├─ \`<...>\` مطلوب · \`[...]\` اختياري\n`;
|
|
226
|
-
usageText += `│\n╰───「 ${brand.name} 」`;
|
|
227
|
-
|
|
228
|
-
return sendBotMessage(sock, msg.key.remoteJid, { text: usageText }, { replyTo: msg });
|
|
358
|
+
return sendBotMessage(
|
|
359
|
+
sock,
|
|
360
|
+
msg.key.remoteJid,
|
|
361
|
+
{ text: renderDetail(command, isGroupCommand, prefix, lang) },
|
|
362
|
+
{ replyTo: msg },
|
|
363
|
+
);
|
|
229
364
|
},
|
|
230
365
|
};
|
package/src/commands/lang.cjs
CHANGED
|
@@ -3,12 +3,19 @@ const logger = require("../utils/logger.cjs");
|
|
|
3
3
|
const settings = require("../config/settings.cjs");
|
|
4
4
|
const runtimeConfig = require("../config/runtime-config.cjs");
|
|
5
5
|
const { isOwnerJidSync, isBotAdminUserSync } = require("../utils/permissions.cjs");
|
|
6
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
6
7
|
|
|
7
8
|
module.exports = {
|
|
8
9
|
name: "lang",
|
|
9
10
|
aliases: ["language", "لغة"],
|
|
10
|
-
description:
|
|
11
|
-
|
|
11
|
+
description: {
|
|
12
|
+
en: "Shows or changes the bot's language.",
|
|
13
|
+
ar: "يعرض لغة البوت أو يغيّرها.",
|
|
14
|
+
},
|
|
15
|
+
usage: {
|
|
16
|
+
en: "lang [en|ar|auto]",
|
|
17
|
+
ar: "lang [en|ar|auto]",
|
|
18
|
+
},
|
|
12
19
|
chat: "all",
|
|
13
20
|
|
|
14
21
|
async execute(sock, msg, args) {
|
|
@@ -21,18 +28,32 @@ module.exports = {
|
|
|
21
28
|
|
|
22
29
|
if (!args || args.length === 0) {
|
|
23
30
|
const labels = {
|
|
24
|
-
auto: "تلقائي (حسب لغة رسالتك)
|
|
25
|
-
ar: "العربية الفصحى
|
|
26
|
-
en: "English
|
|
31
|
+
auto: tr("Auto (follows each message)", "تلقائي (حسب لغة رسالتك)"),
|
|
32
|
+
ar: tr("Arabic", "العربية الفصحى"),
|
|
33
|
+
en: tr("English", "الإنجليزية"),
|
|
27
34
|
};
|
|
28
|
-
const text =
|
|
35
|
+
const text = tr(
|
|
36
|
+
`🌐 *Bot language*
|
|
37
|
+
|
|
38
|
+
⚙️ *Current:* \`${labels[currentLang] || currentLang}\`
|
|
39
|
+
• \`${prefix}lang ar\` — العربية الفصحى دائماً
|
|
40
|
+
• \`${prefix}lang en\` — English always
|
|
41
|
+
• \`${prefix}lang auto\` — follow the language of each message
|
|
42
|
+
|
|
43
|
+
Commands, !help and the AI all answer in it.
|
|
44
|
+
|
|
45
|
+
🔢 *To convert digits* use \`${prefix}digit\` — e.g. \`${prefix}digit 12345\``,
|
|
46
|
+
`🌐 *لغة البوت*
|
|
29
47
|
|
|
30
48
|
⚙️ *اللغة الحالية:* \`${labels[currentLang] || currentLang}\`
|
|
31
49
|
• \`${prefix}lang ar\` — العربية الفصحى دائماً
|
|
32
50
|
• \`${prefix}lang en\` — English always
|
|
33
51
|
• \`${prefix}lang auto\` — تلقائي حسب لغة الرسالة
|
|
34
52
|
|
|
35
|
-
|
|
53
|
+
الأوامر و!help والذكاء الاصطناعي كلهم بيردوا بيها.
|
|
54
|
+
|
|
55
|
+
🔢 *لتحويل الأرقام* استخدم \`${prefix}digit\` — مثال: \`${prefix}digit 12345\``,
|
|
56
|
+
);
|
|
36
57
|
await sock.sendMessage(chatId, { text }, { quoted: msg });
|
|
37
58
|
return;
|
|
38
59
|
}
|
|
@@ -42,7 +63,10 @@ module.exports = {
|
|
|
42
63
|
await sock.sendMessage(
|
|
43
64
|
chatId,
|
|
44
65
|
{
|
|
45
|
-
text:
|
|
66
|
+
text: tr(
|
|
67
|
+
`🔢 To convert digits, use \`${prefix}digit\`:\n• \`${prefix}digit ${firstArg} ${args.slice(1).join(" ")}\`\n• or \`${prefix}digit ${args.slice(1).join(" ")}\` to detect the direction.`,
|
|
68
|
+
`🔢 لتحويل الأرقام استخدم \`${prefix}digit\`:\n• \`${prefix}digit ${firstArg} ${args.slice(1).join(" ")}\`\n• أو \`${prefix}digit ${args.slice(1).join(" ")}\` للتحويل التلقائي.`,
|
|
69
|
+
),
|
|
46
70
|
},
|
|
47
71
|
{ quoted: msg },
|
|
48
72
|
);
|
|
@@ -55,7 +79,10 @@ module.exports = {
|
|
|
55
79
|
await sock.sendMessage(
|
|
56
80
|
chatId,
|
|
57
81
|
{
|
|
58
|
-
text:
|
|
82
|
+
text: tr(
|
|
83
|
+
`⚠️ Sorry, only the bot owner and admins can change the bot's language.\n_To convert digits, use \`${prefix}digit\`._`,
|
|
84
|
+
`⚠️ عذراً، تغيير لغة البوت متاح لمالك البوت والمسؤولين فقط.\n_لتحويل الأرقام استخدم \`${prefix}digit\`._`,
|
|
85
|
+
),
|
|
59
86
|
},
|
|
60
87
|
{ quoted: msg },
|
|
61
88
|
);
|
|
@@ -69,7 +96,7 @@ module.exports = {
|
|
|
69
96
|
await sock.sendMessage(
|
|
70
97
|
chatId,
|
|
71
98
|
{
|
|
72
|
-
text: "✅ تم ضبط لغة البوت على *العربية الفصحى*.
|
|
99
|
+
text: "✅ تم ضبط لغة البوت على *العربية الفصحى*. الأوامر والذكاء الاصطناعي هيردوا بالعربي دائماً.",
|
|
73
100
|
},
|
|
74
101
|
{ quoted: msg },
|
|
75
102
|
);
|
|
@@ -77,7 +104,7 @@ module.exports = {
|
|
|
77
104
|
await sock.sendMessage(
|
|
78
105
|
chatId,
|
|
79
106
|
{
|
|
80
|
-
text: "✅ Bot language set to *English*.
|
|
107
|
+
text: "✅ Bot language set to *English*. Commands and the AI assistant will now always answer in English.",
|
|
81
108
|
},
|
|
82
109
|
{ quoted: msg },
|
|
83
110
|
);
|
|
@@ -85,7 +112,10 @@ module.exports = {
|
|
|
85
112
|
await sock.sendMessage(
|
|
86
113
|
chatId,
|
|
87
114
|
{
|
|
88
|
-
text:
|
|
115
|
+
text: tr(
|
|
116
|
+
"✅ Language set to *Auto*. The bot will answer each message in the language it is written in.",
|
|
117
|
+
"✅ تم ضبط اللغة على *التلقائي (Auto)*. سيرد البوت بحسب لغة كل رسالة ترسلها له تلقائياً.",
|
|
118
|
+
),
|
|
89
119
|
},
|
|
90
120
|
{ quoted: msg },
|
|
91
121
|
);
|
|
@@ -96,7 +126,10 @@ module.exports = {
|
|
|
96
126
|
await sock.sendMessage(
|
|
97
127
|
chatId,
|
|
98
128
|
{
|
|
99
|
-
text:
|
|
129
|
+
text: tr(
|
|
130
|
+
`❌ Unknown option.\nUse:\n• \`${prefix}lang ar\` / \`${prefix}lang en\` / \`${prefix}lang auto\` for the bot's language\n• \`${prefix}digit 12345\` to convert digits`,
|
|
131
|
+
`❌ خيار غير صحيح.\nاستخدم:\n• \`${prefix}lang ar\` / \`${prefix}lang en\` / \`${prefix}lang auto\` للغة البوت\n• \`${prefix}digit 12345\` لتحويل الأرقام`,
|
|
132
|
+
),
|
|
100
133
|
},
|
|
101
134
|
{ quoted: msg },
|
|
102
135
|
);
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
// file: /commands/listschedules.js
|
|
2
2
|
const { getScheduledJobs } = require("../../scheduler.cjs");
|
|
3
|
+
const { tr } = require("../utils/i18n.cjs");
|
|
3
4
|
|
|
4
5
|
module.exports = {
|
|
5
6
|
name: "listschedules",
|
|
6
|
-
description:
|
|
7
|
-
|
|
7
|
+
description: {
|
|
8
|
+
en: "Lists all active and pending scheduled messages.",
|
|
9
|
+
ar: "يعرض كل الرسائل المجدولة النشطة والمعلّقة.",
|
|
10
|
+
},
|
|
11
|
+
usage: {
|
|
12
|
+
en: "listschedules",
|
|
13
|
+
ar: "listschedules",
|
|
14
|
+
},
|
|
8
15
|
chat: "all",
|
|
9
16
|
userAdminRequired: true,
|
|
10
17
|
|
|
@@ -14,29 +21,39 @@ module.exports = {
|
|
|
14
21
|
|
|
15
22
|
if (activeJobs.length === 0) {
|
|
16
23
|
return await sock.sendMessage(msg.key.remoteJid, {
|
|
17
|
-
text: "لا توجد مهام مجدولة حاليًا.",
|
|
24
|
+
text: tr("There are no scheduled messages.", "لا توجد مهام مجدولة حاليًا."),
|
|
18
25
|
});
|
|
19
26
|
}
|
|
20
27
|
|
|
21
|
-
let reply = "*⏰ المهام المجدولة النشطة:*\n\n";
|
|
28
|
+
let reply = tr("*⏰ Active scheduled messages:*\n\n", "*⏰ المهام المجدولة النشطة:*\n\n");
|
|
22
29
|
|
|
23
30
|
activeJobs.forEach((job, index) => {
|
|
24
|
-
reply += `*${index + 1}. المهمة:*\n
|
|
31
|
+
reply += tr(`*${index + 1}. Job:*\n`, `*${index + 1}. المهمة:*\n`);
|
|
25
32
|
reply += `*ID:* \`${job.id}\`\n`;
|
|
26
|
-
reply += `*الرسالة:* "${job.message}"\n
|
|
33
|
+
reply += tr(`*Message:* "${job.message}"\n`, `*الرسالة:* "${job.message}"\n`);
|
|
27
34
|
|
|
28
35
|
if (job.type === "recurring") {
|
|
29
|
-
reply +=
|
|
36
|
+
reply += tr(
|
|
37
|
+
`*Repeats:* ${job.cronString} (daily/weekly)\n`,
|
|
38
|
+
`*التكرار:* ${job.cronString} (يوميًا/أسبوعيًا)\n`,
|
|
39
|
+
);
|
|
30
40
|
} else {
|
|
31
|
-
const jobDate = new Date(job.date).toLocaleString("ar-EG", {
|
|
41
|
+
const jobDate = new Date(job.date).toLocaleString(tr("en-GB", "ar-EG"), {
|
|
32
42
|
timeZone: "Africa/Cairo",
|
|
33
43
|
});
|
|
34
|
-
reply += `*الوقت المحدد:* ${jobDate}\n
|
|
44
|
+
reply += tr(`*When:* ${jobDate}\n`, `*الوقت المحدد:* ${jobDate}\n`);
|
|
35
45
|
}
|
|
36
|
-
|
|
46
|
+
const inGroup = job.targetJid.endsWith("@g.us");
|
|
47
|
+
reply += tr(
|
|
48
|
+
`*Where:* ${inGroup ? "this group" : "a private chat"}\n\n`,
|
|
49
|
+
`*الوجهة:* ${inGroup ? "هذا الجروب" : "محادثة خاصة"}\n\n`,
|
|
50
|
+
);
|
|
37
51
|
});
|
|
38
52
|
|
|
39
|
-
reply +=
|
|
53
|
+
reply += tr(
|
|
54
|
+
"*To delete one, use:*\n`!deleteschedule <ID>`",
|
|
55
|
+
"*لحذف مهمة، استخدم:*\n`!deleteschedule <ID>`",
|
|
56
|
+
);
|
|
40
57
|
|
|
41
58
|
await sock.sendMessage(msg.key.remoteJid, { text: reply });
|
|
42
59
|
},
|