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.
Files changed (96) hide show
  1. package/package.json +1 -1
  2. package/public/dashboard/assets/index-4AuqfnH5.js +431 -0
  3. package/public/dashboard/assets/index-LvfJ8ybs.css +2 -0
  4. package/public/dashboard/index.html +2 -2
  5. package/scheduler.cjs +25 -1
  6. package/src/commands/autoschedule.cjs +40 -10
  7. package/src/commands/blacklist.cjs +35 -10
  8. package/src/commands/block.cjs +18 -5
  9. package/src/commands/calc.cjs +90 -24
  10. package/src/commands/debt.cjs +59 -33
  11. package/src/commands/deleteschedule.cjs +21 -5
  12. package/src/commands/digit.cjs +34 -8
  13. package/src/commands/gemini.cjs +235 -108
  14. package/src/commands/group/add.cjs +46 -13
  15. package/src/commands/group/all.cjs +15 -5
  16. package/src/commands/group/antiSpam.cjs +11 -4
  17. package/src/commands/group/antilink.cjs +39 -19
  18. package/src/commands/group/approveall.cjs +22 -7
  19. package/src/commands/group/clearwarns.cjs +18 -5
  20. package/src/commands/group/deletenote.cjs +18 -5
  21. package/src/commands/group/demote.cjs +25 -7
  22. package/src/commands/group/kick.cjs +28 -12
  23. package/src/commands/group/media.cjs +34 -13
  24. package/src/commands/group/members.cjs +21 -6
  25. package/src/commands/group/note.cjs +14 -4
  26. package/src/commands/group/promote.cjs +22 -6
  27. package/src/commands/group/removeall.cjs +13 -3
  28. package/src/commands/group/rules.cjs +20 -5
  29. package/src/commands/group/save.cjs +20 -5
  30. package/src/commands/group/setname.cjs +19 -6
  31. package/src/commands/group/setpp.cjs +21 -6
  32. package/src/commands/group/setrules.cjs +17 -5
  33. package/src/commands/group/setwarn.cjs +23 -7
  34. package/src/commands/group/tagadmins.cjs +16 -6
  35. package/src/commands/group/warn.cjs +35 -15
  36. package/src/commands/group/warns.cjs +33 -13
  37. package/src/commands/group/welcome.cjs +34 -16
  38. package/src/commands/group.cjs +96 -70
  39. package/src/commands/help.cjs +270 -129
  40. package/src/commands/lang.cjs +46 -13
  41. package/src/commands/listschedules.cjs +28 -11
  42. package/src/commands/loop.cjs +43 -9
  43. package/src/commands/memory.cjs +90 -30
  44. package/src/commands/mod.cjs +72 -28
  45. package/src/commands/notes.cjs +15 -5
  46. package/src/commands/perm.cjs +52 -20
  47. package/src/commands/ping.cjs +15 -3
  48. package/src/commands/poll.cjs +71 -24
  49. package/src/commands/prayer.cjs +28 -12
  50. package/src/commands/qr.cjs +20 -5
  51. package/src/commands/rand.cjs +54 -12
  52. package/src/commands/restart.cjs +13 -3
  53. package/src/commands/schedule.cjs +32 -9
  54. package/src/commands/score.cjs +26 -10
  55. package/src/commands/setprefix.cjs +27 -5
  56. package/src/commands/shortlink.cjs +36 -10
  57. package/src/commands/shutdown.cjs +13 -3
  58. package/src/commands/status.cjs +32 -11
  59. package/src/commands/sticker.cjs +34 -7
  60. package/src/commands/stt.cjs +159 -107
  61. package/src/commands/todo.cjs +31 -9
  62. package/src/commands/tts.cjs +61 -36
  63. package/src/commands/unblock.cjs +17 -4
  64. package/src/commands/weather.cjs +55 -17
  65. package/src/config/baileys.config.js +5 -1
  66. package/src/config/settings.cjs +11 -3
  67. package/src/core/connection.js +21 -2
  68. package/src/core/socket.js +31 -7
  69. package/src/db/store.cjs +24 -0
  70. package/src/handlers/command.handler.js +55 -13
  71. package/src/handlers/group.handler.js +5 -1
  72. package/src/handlers/message.handler.js +9 -0
  73. package/src/middleware/antispam.middleware.js +13 -3
  74. package/src/middleware/blacklist.middleware.js +4 -1
  75. package/src/middleware/permissions.middleware.js +38 -51
  76. package/src/routes/dashboard.api.esm.js +91 -10
  77. package/src/services/aiAgent.cjs +51 -41
  78. package/src/services/aiProviders.cjs +46 -19
  79. package/src/services/aiRouter.cjs +11 -3
  80. package/src/services/aiToolAuth.cjs +114 -0
  81. package/src/services/aiTools.cjs +492 -56
  82. package/src/services/modelRegistry.cjs +20 -5
  83. package/src/utils/commandDocs.cjs +58 -0
  84. package/src/utils/geminiMedia.cjs +99 -0
  85. package/src/utils/groupMetadataCache.cjs +83 -0
  86. package/src/utils/i18n.cjs +113 -0
  87. package/src/utils/markdownParser.cjs +4 -2
  88. package/src/utils/memory.cjs +37 -21
  89. package/src/utils/permissionLevel.cjs +83 -0
  90. package/src/utils/providerUrl.cjs +29 -2
  91. package/src/utils/sendBotMessage.cjs +7 -3
  92. package/src/utils/sendBotMessage.esm.js +27 -3
  93. package/src/utils/statusMessage.cjs +11 -4
  94. package/src/utils/storage-hub.cjs +21 -0
  95. package/public/dashboard/assets/index-BnJbz8iW.css +0 -2
  96. package/public/dashboard/assets/index-Dn8ZyzsW.js +0 -426
@@ -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
- // Recursive function to get all command files
9
- function getAllCommandFiles(dirPath, fileList = []) {
10
- const files = fs.readdirSync(dirPath);
11
-
12
- files.forEach((file) => {
13
- const filePath = path.join(dirPath, file);
14
- if (fs.statSync(filePath).isDirectory()) {
15
- fileList = getAllCommandFiles(filePath, fileList);
16
- } else if (file.endsWith(".cjs") || file.endsWith(".js")) {
17
- fileList.push(filePath);
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 file of files) {
35
- try {
36
- const command = require(file);
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 @user [reason]") and may hold
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,129 +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
- const PERMISSION_LABELS = {
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 PERMISSION_LABELS[level] || level;
212
+ return t.permissions[level] || level;
115
213
  }
116
214
 
117
- const CHAT_LABELS = {
118
- all: "كل المحادثات",
119
- group: "المجموعات فقط",
120
- private: "الخاص فقط",
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: "Shows a list of all commands or info about a specific command.",
127
- usage: "help [اسم الأمر]",
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
- if (!args[0]) {
135
- const section = (title, list) => {
136
- let text = `├─ *${title}*\n`;
137
- list.forEach((cmd) => {
138
- const aliases = aliasesOf(cmd);
139
- const aliasSnippet = aliases.length
140
- ? ` _(${aliases.map((a) => prefix + a).join(", ")})_`
141
- : "";
142
- text += `│ ◦ *${prefix}${cmd.name}*${aliasSnippet}\n`;
143
- text += `│ ${cmd.description}\n`;
144
- // The parameters are the whole point of a help list — show them.
145
- usageLines(cmd, prefix).forEach((line) => {
146
- text += `│ ⌨️ \`${line}\`\n`;
147
- });
148
- });
149
- return `${text}│\n`;
150
- };
151
-
152
- // A command switched off from the dashboard can't run, so it has no
153
- // business in the menu.
154
- const live = (list) => list.filter((cmd) => !runtimeConfig.isDisabled(cmd.name));
155
-
156
- const general = live(commands.general);
157
- const group = live(commands.group);
158
-
159
- let helpText = `╭───「 *🤖 ${brand.name} Commands* 」\n│\n`;
160
- if (general.length) helpText += section("General Commands", general);
161
- if (group.length) helpText += section("Group Commands", group);
162
-
163
- helpText += `├─ *الرموز*\n`;
164
- helpText += `│ \`<...>\` مطلوب · \`[...]\` اختياري · \`a|b\` اختر واحد\n│\n`;
165
- helpText += `╰───「 اكتب *${prefix}help <أمر>* لتفاصيل أكتر 」`;
166
-
167
- 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
+ );
168
341
  }
169
342
 
170
- const query = args[0].startsWith(prefix) ? args[0].slice(prefix.length) : args[0];
343
+ const query = parsed.query.startsWith(prefix)
344
+ ? parsed.query.slice(prefix.length)
345
+ : parsed.query;
171
346
  const command = findCommand(query, commands, aliasIndex);
172
347
 
173
348
  if (!command) {
174
349
  return sendBotMessage(
175
350
  sock,
176
351
  msg.key.remoteJid,
177
- {
178
- text: `❌ الأمر "*${args[0]}*" غير موجود.\n` + `اكتب \`${prefix}help\` لعرض كل الأوامر.`,
179
- },
352
+ { text: TEXT[lang].notFound(parsed.query, prefix) },
180
353
  { replyTo: msg },
181
354
  );
182
355
  }
183
356
 
184
- let usageText = `╭───「 *Command Details* 」\n│\n`;
185
- usageText += `├─ *الأمر:* ${prefix}${command.name}\n`;
186
-
187
- const commandAliases = aliasesOf(command);
188
- if (commandAliases.length) {
189
- usageText += `├─ *اختصارات:* ${commandAliases.map((a) => `${prefix}${a}`).join(", ")}\n`;
190
- }
191
-
192
- if (command.description) {
193
- usageText += `├─ *الوصف:* ${command.description}\n`;
194
- }
195
-
196
- usageText += `├─ *الاستخدام:*\n`;
197
- usageLines(command, prefix).forEach((line) => {
198
- usageText += `│ \`${line}\`\n`;
199
- });
200
-
201
- if (command.examples?.length) {
202
- usageText += `├─ *أمثلة:*\n`;
203
- command.examples.forEach((example) => {
204
- usageText += `│ \`${prefix}${example}\`\n`;
205
- });
206
- }
207
-
208
- usageText += `├─ *المكان:* ${CHAT_LABELS[command.chat] || command.chat || "كل المحادثات"}\n`;
209
357
  const isGroupCommand = commands.group.includes(command);
210
- usageText += `├─ *الصلاحية:* ${permissionFor(command, isGroupCommand)}\n`;
211
-
212
- if (command.userAdminRequired) {
213
- usageText += `├─ ⚠️ لازم تكون مشرف\n`;
214
- }
215
- if (command.botAdminRequired) {
216
- usageText += `├─ ⚠️ لازم البوت يكون مشرف\n`;
217
- }
218
-
219
- usageText += `│\n├─ \`<...>\` مطلوب · \`[...]\` اختياري\n`;
220
- usageText += `│\n╰───「 ${brand.name} 」`;
221
-
222
- 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
+ );
223
364
  },
224
365
  };
@@ -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: "View or change the bot response language",
11
- usage: "lang [en|ar|auto]",
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: "تلقائي (حسب لغة رسالتك) / Auto-detect",
25
- ar: "العربية الفصحى (Modern Standard Arabic)",
26
- en: "English (الإنجليزية)",
31
+ auto: tr("Auto (follows each message)", "تلقائي (حسب لغة رسالتك)"),
32
+ ar: tr("Arabic", "العربية الفصحى"),
33
+ en: tr("English", "الإنجليزية"),
27
34
  };
28
- const text = `🌐 *لغة البوت / Bot language*
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
- 🔢 *لتحويل الأرقام* استخدم \`${prefix}digit\` — مثال: \`${prefix}digit 12345\``;
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: `🔢 لتحويل الأرقام استخدم \`${prefix}digit\`:\n• \`${prefix}digit ${firstArg} ${args.slice(1).join(" ")}\`\n• أو \`${prefix}digit ${args.slice(1).join(" ")}\` للتحويل التلقائي.\nTo convert digits, use \`${prefix}digit\`.`,
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: `⚠️ عذراً، تغيير لغة البوت متاح لمالك البوت والمسؤولين فقط.\nSorry, only bot owner and admins can change bot language.\n_لتحويل الأرقام استخدم \`${prefix}digit\`._`,
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*. The AI assistant will now always respond in 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: "✅ تم ضبط اللغة على *التلقائي (Auto)*. سيرد البوت بحسب لغة كل رسالة ترسلها له تلقائياً.",
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: `❌ خيار غير صحيح.\nاستخدم:\n• \`${prefix}lang ar\` / \`${prefix}lang en\` / \`${prefix}lang auto\` للغة البوت\n• \`${prefix}digit 12345\` لتحويل الأرقام`,
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: "Lists all active and pending scheduled jobs.",
7
- usage: "listschedules",
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 += `*التكرار:* ${job.cronString} (يوميًا/أسبوعيًا)\n`;
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
- reply += `*الوجهة:* ${job.targetJid.endsWith("@g.us") ? "هذا الجروب" : "محادثة خاصة"}\n\n`;
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 += "*لحذف مهمة، استخدم:*\n`!deleteschedule <ID>`";
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
  },