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
@@ -16,6 +16,7 @@ const { grantRole, revokeRole, listRoles, isOwnerJidSync } = require("../utils/p
16
16
  const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
17
17
  const normalizeJid = require("../utils/normalizeJid.cjs");
18
18
  const logger = require("../utils/logger.cjs");
19
+ const { tr } = require("../utils/i18n.cjs");
19
20
 
20
21
  const ROLE_WORDS = {
21
22
  owner: "owner",
@@ -75,20 +76,28 @@ function labelFor(user) {
75
76
  // is async — awaiting them is not optional.
76
77
  async function rolesReport() {
77
78
  const { owners, admins, bootstrapOwners, bootstrapAdmins } = await listRoles();
78
- const lines = ["*🔑 صلاحيات البوت*", ""];
79
+ const none = tr("• (none)", "• (مفيش)");
80
+ const lines = [tr("*🔑 Bot roles*", "*🔑 صلاحيات البوت*"), ""];
79
81
 
80
- lines.push(`*👑 المالكين (${owners.length}):*`);
81
- lines.push(owners.length ? owners.map((o) => `• ${labelFor(o)}`).join("\n") : "• (مفيش)");
82
+ lines.push(tr(`*👑 Owners (${owners.length}):*`, `*👑 المالكين (${owners.length}):*`));
83
+ lines.push(owners.length ? owners.map((o) => `• ${labelFor(o)}`).join("\n") : none);
82
84
 
83
- lines.push("", `*🛡️ الأدمنز (${admins.length}):*`);
84
- lines.push(admins.length ? admins.map((a) => `• ${labelFor(a)}`).join("\n") : "• (مفيش)");
85
+ lines.push("", tr(`*🛡️ Admins (${admins.length}):*`, `*🛡️ الأدمنز (${admins.length}):*`));
86
+ lines.push(admins.length ? admins.map((a) => `• ${labelFor(a)}`).join("\n") : none);
85
87
 
86
88
  const envOnly = [
87
89
  ...bootstrapOwners.filter((jid) => !owners.some((o) => o.jid === jid || o.lid === jid)),
88
90
  ...bootstrapAdmins.filter((jid) => !admins.some((a) => a.jid === jid || a.lid === jid)),
89
91
  ];
90
92
  if (envOnly.length) {
91
- lines.push("", `_من الإعدادات (env/config): ${[...new Set(envOnly)].length} إدخال._`);
93
+ const count = [...new Set(envOnly)].length;
94
+ lines.push(
95
+ "",
96
+ tr(
97
+ `_From settings (env/config): ${count} entries._`,
98
+ `_من الإعدادات (env/config): ${count} إدخال._`,
99
+ ),
100
+ );
92
101
  }
93
102
 
94
103
  return lines.join("\n");
@@ -97,9 +106,17 @@ async function rolesReport() {
97
106
  module.exports = {
98
107
  name: "perm",
99
108
  aliases: ["perms", "owner", "admin", "role", "roles", "صلاحيات"],
100
- description: "إدارة صلاحيات البوت: إضافة/إزالة مالك أو أدمن، وعرض القائمة الحالية.",
101
- usage: "perm list\nperm add admin @عضو\nperm add owner <رقم>\nperm remove admin @عضو",
109
+ description: {
110
+ en: "Manages bot roles: add or remove an owner or admin, and list the current ones.",
111
+ ar: "يدير صلاحيات البوت: إضافة مالك أو أدمن أو إزالته، وعرض القائمة الحالية.",
112
+ },
113
+ usage: {
114
+ en: "perm list\nperm add admin @member\nperm add owner <number>\nperm remove admin @member",
115
+ ar: "perm list\nperm add admin @عضو\nperm add owner <رقم>\nperm remove admin @عضو",
116
+ },
102
117
  chat: "all",
118
+ // Accepted but not in the usage — syntax, not English (see utils/i18n.cjs).
119
+ keywords: [...ADD_WORDS, ...DEL_WORDS, ...LIST_WORDS, ...Object.keys(ROLE_WORDS), "me"],
103
120
 
104
121
  async execute(sock, msg, args) {
105
122
  const jid = msg.key.remoteJid;
@@ -116,12 +133,18 @@ module.exports = {
116
133
  sock,
117
134
  jid,
118
135
  {
119
- text:
136
+ text: tr(
137
+ "Wrong usage.\n\n" +
138
+ "`!perm list` — the current roles\n" +
139
+ "`!perm add admin @member` — make an admin\n" +
140
+ "`!perm add owner <number>` — make an owner\n" +
141
+ "`!perm remove admin @member` — take the role away",
120
142
  "استخدام غير صحيح.\n\n" +
121
- "`!perm list` — القائمة الحالية\n" +
122
- "`!perm add admin @عضو` — تعيين أدمن\n" +
123
- "`!perm add owner <رقم>` — تعيين مالك\n" +
124
- "`!perm remove admin @عضو` — سحب الصلاحية",
143
+ "`!perm list` — القائمة الحالية\n" +
144
+ "`!perm add admin @عضو` — تعيين أدمن\n" +
145
+ "`!perm add owner <رقم>` — تعيين مالك\n" +
146
+ "`!perm remove admin @عضو` — سحب الصلاحية",
147
+ ),
125
148
  },
126
149
  { replyTo: msg },
127
150
  );
@@ -144,9 +167,12 @@ module.exports = {
144
167
  sock,
145
168
  jid,
146
169
  {
147
- text:
170
+ text: tr(
171
+ "Say who: mention them (@), reply to their message, or type their number.\n" +
172
+ "Example: `!perm add admin @member`",
148
173
  "محتاج تحدد الشخص: منشن (@) أو رد على رسالته أو اكتب رقمه.\n" +
149
- "مثال: `!perm add admin @عضو`",
174
+ "مثال: `!perm add admin @عضو`",
175
+ ),
150
176
  },
151
177
  { replyTo: msg },
152
178
  );
@@ -160,7 +186,7 @@ module.exports = {
160
186
  return sendBotMessage(
161
187
  sock,
162
188
  jid,
163
- { text: "🚫 تعيين مالك جديد للمالك فقط." },
189
+ { text: tr("🚫 Only an owner can make a new owner.", "🚫 تعيين مالك جديد للمالك فقط.") },
164
190
  { replyTo: msg },
165
191
  );
166
192
  }
@@ -168,7 +194,7 @@ module.exports = {
168
194
  try {
169
195
  const record = isAdd ? await grantRole(target, role) : await revokeRole(target, role);
170
196
  const who = record ? labelFor(record) : target;
171
- const roleLabel = role === "owner" ? "مالك 👑" : "أدمن 🛡️";
197
+ const roleLabel = role === "owner" ? tr("owner 👑", "مالك 👑") : tr("admin 🛡️", "أدمن 🛡️");
172
198
 
173
199
  logger.info({ target, role, granted: isAdd, by: sender }, "[perm] role change");
174
200
 
@@ -177,8 +203,11 @@ module.exports = {
177
203
  jid,
178
204
  {
179
205
  text: isAdd
180
- ? `✅ تم تعيين *${who}* كـ *${roleLabel}*.`
181
- : `✅ تم سحب صلاحية *${roleLabel}* من *${who}*.`,
206
+ ? tr(`✅ *${who}* is now *${roleLabel}*.`, `✅ تم تعيين *${who}* كـ *${roleLabel}*.`)
207
+ : tr(
208
+ `✅ *${who}* is no longer *${roleLabel}*.`,
209
+ `✅ تم سحب صلاحية *${roleLabel}* من *${who}*.`,
210
+ ),
182
211
  mentions: target.includes("@") ? [target] : undefined,
183
212
  },
184
213
  { replyTo: msg },
@@ -189,7 +218,10 @@ module.exports = {
189
218
  sock,
190
219
  jid,
191
220
  {
192
- text: `❌ *مقدرتش أعدّل الصلاحية*\n\n*التفاصيل:* ${error.message}`,
221
+ text: tr(
222
+ `❌ *I couldn't change the role*\n\n*Details:* ${error.message}`,
223
+ `❌ *مقدرتش أعدّل الصلاحية*\n\n*التفاصيل:* ${error.message}`,
224
+ ),
193
225
  },
194
226
  { replyTo: msg },
195
227
  );
@@ -1,13 +1,25 @@
1
+ const { tr } = require("../utils/i18n.cjs");
2
+
1
3
  // file: /commands/ping.js
2
4
 
3
5
  module.exports = {
4
6
  name: "ping",
5
- description: "A simple command to check if the bot is responsive.",
6
- usage: "ping",
7
+ description: {
8
+ en: "Checks that the bot is responding.",
9
+ ar: "يتحقق من أن البوت يستجيب.",
10
+ },
11
+ usage: {
12
+ en: "ping",
13
+ ar: "ping",
14
+ },
7
15
  chat: "all", // <-- الخاصية الجديدة. يمكن أن تكون 'group' أو 'private'
8
16
 
9
17
  async execute(sock, msg) {
10
18
  // The bot will reply with "Pong!" and quote the original message
11
- await sock.sendMessage(msg.key.remoteJid, { text: "Pong! 🏓" }, { quoted: msg });
19
+ await sock.sendMessage(
20
+ msg.key.remoteJid,
21
+ { text: tr("Pong! 🏓", "بونج! 🏓") },
22
+ { quoted: msg },
23
+ );
12
24
  },
13
25
  };
@@ -7,6 +7,7 @@
7
7
  // and WhatsApp counts the results.
8
8
 
9
9
  const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
10
+ const { tr } = require("../utils/i18n.cjs");
10
11
 
11
12
  const MIN_OPTIONS = 2;
12
13
  const MAX_OPTIONS = 12; // WhatsApp's own ceiling
@@ -15,7 +16,20 @@ const MAX_OPTION_CHARS = 100;
15
16
 
16
17
  const MULTI_FLAGS = new Set(["--multi", "-m", "متعدد"]);
17
18
 
18
- const HELP_TEXT =
19
+ const helpText = () =>
20
+ tr(
21
+ "📊 *Poll*\n\n" +
22
+ "*Usage:*\n" +
23
+ "`!poll <question> | <option> | <option> ...`\n\n" +
24
+ "*Options:*\n" +
25
+ "`--multi` allows more than one answer\n\n" +
26
+ "*Example:*\n" +
27
+ "`!poll Where to? | Cinema | Beach | Home`\n\n" +
28
+ `_${MIN_OPTIONS} to ${MAX_OPTIONS} options._`,
29
+ HELP_TEXT_AR,
30
+ );
31
+
32
+ const HELP_TEXT_AR =
19
33
  "📊 *استفتاء*\n\n" +
20
34
  "*الاستخدام:*\n" +
21
35
  "`!poll <السؤال> | <خيار> | <خيار> ...`\n\n" +
@@ -25,12 +39,54 @@ const HELP_TEXT =
25
39
  "`!poll نروح فين؟ | السينما | البحر | البيت`\n\n" +
26
40
  `_من ${MIN_OPTIONS} لـ ${MAX_OPTIONS} خيارات._`;
27
41
 
42
+ /**
43
+ * Validate question/options and build the exact `sendMessage` content for a
44
+ * native poll — shared by the !poll command and the AI agent's `create_poll`
45
+ * tool so both doors enforce the same WhatsApp limits. Throws with a message
46
+ * in the reply language on any violation; returns the `{ poll: ... }` content
47
+ * object.
48
+ */
49
+ function buildPollContent(question, options, { multi = false } = {}) {
50
+ const name = String(question || "").trim().slice(0, MAX_QUESTION_CHARS);
51
+ const values = [...new Set((options || []).map((o) => String(o || "").trim().slice(0, MAX_OPTION_CHARS)).filter(Boolean))];
52
+
53
+ if (!name) throw new Error(tr("A question is required.", "السؤال مطلوب."));
54
+ if (values.length < MIN_OPTIONS) {
55
+ throw new Error(
56
+ tr("At least two different options are needed.", "محتاج خيارين مختلفين على الأقل."),
57
+ );
58
+ }
59
+ if (values.length > MAX_OPTIONS) {
60
+ throw new Error(
61
+ tr(
62
+ `${MAX_OPTIONS} options at most (got ${values.length}).`,
63
+ `الحد الأقصى ${MAX_OPTIONS} خيار (اتعطى ${values.length}).`,
64
+ ),
65
+ );
66
+ }
67
+
68
+ return {
69
+ poll: {
70
+ name,
71
+ values,
72
+ selectableCount: multi ? values.length : 1,
73
+ },
74
+ };
75
+ }
76
+
28
77
  module.exports = {
29
78
  name: "poll",
30
79
  aliases: ["vote", "استفتاء", "تصويت"],
31
- description: "ينشئ استفتاء (تصويت) داخل الشات.",
32
- usage: "poll <السؤال> | <خيار1> | <خيار2> [| ...] [--multi]",
80
+ description: {
81
+ en: "Creates a poll in the chat.",
82
+ ar: "ينشئ استفتاءً (تصويتًا) داخل المحادثة.",
83
+ },
84
+ usage: {
85
+ en: "poll <question> | <option 1> | <option 2> [| ...] [--multi]",
86
+ ar: "poll <السؤال> | <خيار1> | <خيار2> [| ...] [--multi]",
87
+ },
33
88
  chat: "all",
89
+ keywords: [...MULTI_FLAGS],
34
90
 
35
91
  async execute(sock, msg, args) {
36
92
  const chatId = msg.key.remoteJid;
@@ -51,30 +107,21 @@ module.exports = {
51
107
  .map((part) => part.trim())
52
108
  .filter(Boolean);
53
109
 
54
- if (parts.length < MIN_OPTIONS + 1) return reply(HELP_TEXT);
110
+ if (parts.length < MIN_OPTIONS + 1) return reply(helpText());
55
111
 
56
- const question = parts[0].slice(0, MAX_QUESTION_CHARS);
57
- // WhatsApp rejects a poll with duplicate options.
58
- const options = [...new Set(parts.slice(1).map((o) => o.slice(0, MAX_OPTION_CHARS)))];
112
+ const question = parts[0];
113
+ const options = parts.slice(1);
59
114
 
60
- if (options.length < MIN_OPTIONS) {
61
- return reply("❌ محتاج خيارين مختلفين على الأقل.");
62
- }
63
- if (options.length > MAX_OPTIONS) {
64
- return reply(`❌ الحد الأقصى ${MAX_OPTIONS} خيار (انت كاتب ${options.length}).`);
115
+ let content;
116
+ try {
117
+ content = buildPollContent(question, options, { multi });
118
+ } catch (err) {
119
+ return reply(`❌ ${err.message}`);
65
120
  }
66
121
 
67
- return sendBotMessage(
68
- sock,
69
- chatId,
70
- {
71
- poll: {
72
- name: question,
73
- values: options,
74
- selectableCount: multi ? options.length : 1,
75
- },
76
- },
77
- { replyTo: msg },
78
- );
122
+ return sendBotMessage(sock, chatId, content, { replyTo: msg });
79
123
  },
124
+
125
+ // exported for the AI agent's `create_poll` tool — one builder, two doors
126
+ _buildPollContent: buildPollContent,
80
127
  };
@@ -9,18 +9,31 @@ function formatTime12Hour(time24) {
9
9
 
10
10
  const axios = require("axios");
11
11
  const logger = require("../utils/logger.cjs");
12
+ const { tr } = require("../utils/i18n.cjs");
12
13
 
13
14
  module.exports = {
14
15
  name: "prayer",
15
- description: "Gets prayer times for a specific city.",
16
- usage: "prayer <المدينة بالإنجليزية>",
16
+ description: {
17
+ en: "Shows prayer times for a city.",
18
+ ar: "يعرض مواقيت الصلاة لمدينة معيّنة.",
19
+ },
20
+ usage: {
21
+ en: "prayer <city in English>",
22
+ ar: "prayer <اسم المدينة بالإنجليزية>",
23
+ },
17
24
  chat: "all", // This command can be used anywhere
25
+ // The city is asked for in English whatever language you speak, so it says
26
+ // nothing about which language to answer in (see utils/i18n.cjs).
27
+ neutralArgs: true,
18
28
 
19
29
  async execute(sock, msg, args) {
20
30
  // 2. Check if the user provided a city name
21
31
  if (!args || args.length === 0) {
22
32
  return await sock.sendMessage(msg.key.remoteJid, {
23
- text: "يرجى تقديم اسم المدينة باللغة الانجليزية.\n\nمثال:* `!prayer cairo`",
33
+ text: tr(
34
+ "Give the city's name in English.\n\n*Example:* `!prayer cairo`",
35
+ "يرجى تقديم اسم المدينة باللغة الانجليزية.\n\nمثال:* `!prayer cairo`",
36
+ ),
24
37
  });
25
38
  }
26
39
 
@@ -32,7 +45,7 @@ module.exports = {
32
45
 
33
46
  try {
34
47
  await sock.sendMessage(msg.key.remoteJid, {
35
- text: "يتم جلب البيانات...",
48
+ text: tr("Fetching the times...", "يتم جلب البيانات..."),
36
49
  });
37
50
  // 5. We will make the API call using axios
38
51
  const response = await axios.get(API_URL);
@@ -41,13 +54,13 @@ module.exports = {
41
54
 
42
55
  // 7. We will format the reply message
43
56
  const reply =
44
- `*مواقيت الصلاة لمدينة ${city}:*\n\n` +
45
- `الفجر: ${formatTime12Hour(timings.Fajr)}\n` +
46
- `الشروق: ${formatTime12Hour(timings.Sunrise)}\n` +
47
- `الظهر: ${formatTime12Hour(timings.Dhuhr)}\n` +
48
- `العصر: ${formatTime12Hour(timings.Asr)}\n` +
49
- `المغرب: ${formatTime12Hour(timings.Maghrib)}\n` +
50
- `العشاء: ${formatTime12Hour(timings.Isha)}`;
57
+ tr(`*Prayer times for ${city}:*\n\n`, `*مواقيت الصلاة لمدينة ${city}:*\n\n`) +
58
+ `${tr("Fajr", "الفجر")}: ${formatTime12Hour(timings.Fajr)}\n` +
59
+ `${tr("Sunrise", "الشروق")}: ${formatTime12Hour(timings.Sunrise)}\n` +
60
+ `${tr("Dhuhr", "الظهر")}: ${formatTime12Hour(timings.Dhuhr)}\n` +
61
+ `${tr("Asr", "العصر")}: ${formatTime12Hour(timings.Asr)}\n` +
62
+ `${tr("Maghrib", "المغرب")}: ${formatTime12Hour(timings.Maghrib)}\n` +
63
+ `${tr("Isha", "العشاء")}: ${formatTime12Hour(timings.Isha)}`;
51
64
 
52
65
  // 8. Send the formatted message
53
66
  await sock.sendMessage(msg.key.remoteJid, {
@@ -57,7 +70,10 @@ module.exports = {
57
70
  logger.error(error.message, "[Error] in Prayer API:");
58
71
  // 9. Handle errors, like city not found or API failure
59
72
  await sock.sendMessage(msg.key.remoteJid, {
60
- text: `عذراً، لم أتمكن من العثور على وقت الصلاة في "${city}". يرجى التحقق من اسم المدينة ومحاولة مرة أخرى.`,
73
+ text: tr(
74
+ `Sorry, I couldn't find prayer times for "${city}". Check the city's name and try again.`,
75
+ `عذراً، لم أتمكن من العثور على وقت الصلاة في "${city}". يرجى التحقق من اسم المدينة ومحاولة مرة أخرى.`,
76
+ ),
61
77
  });
62
78
  }
63
79
  },
@@ -1,12 +1,21 @@
1
1
  // file: /commands/qr.js
2
2
  const qrcode = require("qrcode");
3
3
  const logger = require("../utils/logger.cjs");
4
+ const { tr } = require("../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "qr",
7
- description: "Generates a QR code from text.",
8
- usage: "qr <نص|رابط>",
8
+ description: {
9
+ en: "Generates a QR code from text.",
10
+ ar: "ينشئ رمز QR من نص.",
11
+ },
12
+ usage: {
13
+ en: "qr <text|link>",
14
+ ar: "qr <نص|رابط>",
15
+ },
9
16
  chat: "all",
17
+ // What goes in the code is data, not the language you are talking in.
18
+ neutralArgs: true,
10
19
 
11
20
  async execute(sock, msg, args) {
12
21
  const remoteJid = msg.key.remoteJid;
@@ -14,7 +23,10 @@ module.exports = {
14
23
 
15
24
  if (!textToEncode) {
16
25
  return await sock.sendMessage(remoteJid, {
17
- text: "يرجى كتابة النص أو الرابط الذي تريد تحويله بعد الأمر.\n*مثال:*\n`!qr https://google.com`",
26
+ text: tr(
27
+ "Write the text or link to encode after the command.\n*Example:*\n`!qr https://google.com`",
28
+ "يرجى كتابة النص أو الرابط الذي تريد تحويله بعد الأمر.\n*مثال:*\n`!qr https://google.com`",
29
+ ),
18
30
  });
19
31
  }
20
32
 
@@ -27,12 +39,15 @@ module.exports = {
27
39
  // Send the image buffer as a photo
28
40
  await sock.sendMessage(remoteJid, {
29
41
  image: qrImageBuffer,
30
- caption: `*QR Code for:*\n\`\`\`${textToEncode}\`\`\``,
42
+ caption: tr(
43
+ `*QR code for:*\n\`\`\`${textToEncode}\`\`\``,
44
+ `*رمز QR لـ:*\n\`\`\`${textToEncode}\`\`\``,
45
+ ),
31
46
  });
32
47
  } catch (error) {
33
48
  logger.error({ err: error }, "Failed to generate QR code");
34
49
  await sock.sendMessage(remoteJid, {
35
- text: "حدث خطأ أثناء إنشاء QR code.",
50
+ text: tr("Something went wrong while making the QR code.", "حدث خطأ أثناء إنشاء QR code."),
36
51
  });
37
52
  }
38
53
  },
@@ -11,6 +11,7 @@
11
11
  // Used for settling arguments in the group. No dependencies, no state.
12
12
 
13
13
  const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
14
+ const { tr } = require("../utils/i18n.cjs");
14
15
 
15
16
  const MAX_DICE = 20;
16
17
  const MAX_SIDES = 1000;
@@ -29,7 +30,19 @@ function toNumber(token) {
29
30
  return Number.isFinite(value) ? Math.trunc(value) : null;
30
31
  }
31
32
 
32
- const HELP_TEXT =
33
+ const helpText = () =>
34
+ tr(
35
+ "🎲 *Random*\n\n" +
36
+ "`!rand` a number from 1 to 100\n" +
37
+ "`!rand <max>` a number from 1 to that number\n" +
38
+ "`!rand <min> <max>` a number between the two\n" +
39
+ "`!rand dice [count d sides]` dice — e.g. `!rand dice 2d6`\n" +
40
+ "`!rand coin` heads or tails\n" +
41
+ "`!rand pick option | option | option` picks one",
42
+ HELP_TEXT_AR,
43
+ );
44
+
45
+ const HELP_TEXT_AR =
33
46
  "🎲 *عشوائي*\n\n" +
34
47
  "`!rand` رقم من 1 لـ 100\n" +
35
48
  "`!rand <أقصى>` رقم من 1 للرقم ده\n" +
@@ -47,9 +60,12 @@ function rollDice(spec) {
47
60
 
48
61
  if (!match || count < 1 || count > MAX_DICE || sides < 2 || sides > MAX_SIDES) {
49
62
  return {
50
- error:
63
+ error: tr(
64
+ `❌ Wrong dice format. Use \`<count>d<sides>\` — e.g. \`2d6\`.\n` +
65
+ `(at most ${MAX_DICE} dice and ${MAX_SIDES} sides)`,
51
66
  `❌ صيغة النرد غلط. استخدم \`عددdأوجه\` — مثال \`2d6\`.\n` +
52
- `(حد أقصى ${MAX_DICE} نرد و ${MAX_SIDES} وجه)`,
67
+ `(حد أقصى ${MAX_DICE} نرد و ${MAX_SIDES} وجه)`,
68
+ ),
53
69
  };
54
70
  }
55
71
 
@@ -61,8 +77,14 @@ function rollDice(spec) {
61
77
  module.exports = {
62
78
  name: "rand",
63
79
  aliases: ["random", "roll", "عشوائي", "قرعة"],
64
- description: "أرقام عشوائية، نرد، عملة، أو اختيار من قائمة.",
65
- usage: "rand [<أقصى> | <أدنى> <أقصى> | dice [2d6] | coin | pick أ | ب | ج]",
80
+ description: {
81
+ en: "Random numbers, dice, a coin flip, or a pick from a list.",
82
+ ar: "أرقام عشوائية، أو نرد، أو رمي عملة، أو اختيار من قائمة.",
83
+ },
84
+ usage: {
85
+ en: "rand [<max> | <min> <max> | dice [2d6] | coin | pick a | b | c]",
86
+ ar: "rand [<أقصى> | <أدنى> <أقصى> | dice [2d6] | coin | pick أ | ب | ج]",
87
+ },
66
88
  chat: "all",
67
89
 
68
90
  async execute(sock, msg, args) {
@@ -71,11 +93,11 @@ module.exports = {
71
93
 
72
94
  const mode = (args[0] || "").toLowerCase();
73
95
 
74
- if (["help", "?", "مساعدة"].includes(mode)) return reply(HELP_TEXT);
96
+ if (["help", "?", "مساعدة"].includes(mode)) return reply(helpText());
75
97
 
76
98
  if (["coin", "flip", "عملة", "معملة"].includes(mode)) {
77
99
  const heads = Math.random() < 0.5;
78
- return reply(`🪙 *${heads ? "ملك 👑" : "كتابة ✍️"}*`);
100
+ return reply(`🪙 *${heads ? tr("Heads 👑", "ملك 👑") : tr("Tails ✍️", "كتابة ✍️")}*`);
79
101
  }
80
102
 
81
103
  if (["dice", "die", "نرد", "زهر"].includes(mode)) {
@@ -94,21 +116,36 @@ module.exports = {
94
116
  .filter(Boolean);
95
117
 
96
118
  if (choices.length < 2) {
97
- return reply("❌ اديني خيارين على الأقل مفصولين بـ `|`.\nمثال: `!rand pick شاي | قهوة`");
119
+ return reply(
120
+ tr(
121
+ "❌ Give me at least two options separated by `|`.\nExample: `!rand pick tea | coffee`",
122
+ "❌ اديني خيارين على الأقل مفصولين بـ `|`.\nمثال: `!rand pick شاي | قهوة`",
123
+ ),
124
+ );
98
125
  }
99
126
  if (choices.length > MAX_CHOICES) {
100
- return reply(`❌ الخيارات كتير أوي (الحد ${MAX_CHOICES}).`);
127
+ return reply(
128
+ tr(
129
+ `❌ Too many options (the limit is ${MAX_CHOICES}).`,
130
+ `❌ الخيارات كتير أوي (الحد ${MAX_CHOICES}).`,
131
+ ),
132
+ );
101
133
  }
102
134
 
103
135
  const winner = choices[randomInt(0, choices.length - 1)];
104
- return reply(`🎯 اخترت: *${winner}*\n_(من ${choices.length} خيارات)_`);
136
+ return reply(
137
+ tr(
138
+ `🎯 I picked: *${winner}*\n_(out of ${choices.length} options)_`,
139
+ `🎯 اخترت: *${winner}*\n_(من ${choices.length} خيارات)_`,
140
+ ),
141
+ );
105
142
  }
106
143
 
107
144
  // Plain number forms: !rand · !rand 6 · !rand 10 50
108
145
  const first = toNumber(args[0]);
109
146
  const second = toNumber(args[1]);
110
147
 
111
- if (args[0] && first === null) return reply(HELP_TEXT);
148
+ if (args[0] && first === null) return reply(helpText());
112
149
 
113
150
  let min = 1;
114
151
  let max = 100;
@@ -122,6 +159,11 @@ module.exports = {
122
159
 
123
160
  if (min === max) return reply(`🎲 *${min}*`);
124
161
 
125
- return reply(`🎲 *${randomInt(min, max)}*\n_(بين ${min} و ${max})_`);
162
+ return reply(
163
+ tr(
164
+ `🎲 *${randomInt(min, max)}*\n_(between ${min} and ${max})_`,
165
+ `🎲 *${randomInt(min, max)}*\n_(بين ${min} و ${max})_`,
166
+ ),
167
+ );
126
168
  },
127
169
  };
@@ -1,11 +1,18 @@
1
1
  // file: /commands/restart.js
2
2
  const { delay } = require("@whiskeysockets/baileys");
3
3
  const logger = require("../utils/logger.cjs");
4
+ const { tr } = require("../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "restart",
7
- description: "Restarts the bot.",
8
- usage: "restart",
8
+ description: {
9
+ en: "Restarts the bot.",
10
+ ar: "يعيد تشغيل البوت.",
11
+ },
12
+ usage: {
13
+ en: "restart",
14
+ ar: "restart",
15
+ },
9
16
  chat: "all",
10
17
 
11
18
  async execute(sock, msg) {
@@ -13,7 +20,10 @@ module.exports = {
13
20
 
14
21
  // Send a confirmation message before exiting
15
22
  await sock.sendMessage(msg.key.remoteJid, {
16
- text: "✅ جاري إعادة تشغيل البوت... سأعود بعد لحظات.",
23
+ text: tr(
24
+ "✅ Restarting the bot... back in a moment.",
25
+ "✅ جاري إعادة تشغيل البوت... سأعود بعد لحظات.",
26
+ ),
17
27
  });
18
28
 
19
29
  // A small delay to ensure the message is sent before the process exits