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
@@ -10,6 +10,7 @@
10
10
  // FUNCTIONS.
11
11
 
12
12
  const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
13
+ const { tr } = require("../utils/i18n.cjs");
13
14
 
14
15
  // ---------------------------------------------------------------------------
15
16
  // whitelist
@@ -59,8 +60,12 @@ const FUNCTIONS = {
59
60
  };
60
61
 
61
62
  function factorial(n) {
62
- if (!Number.isInteger(n)) throw new CalcError("المضروب (!) يشتغل على أرقام صحيحة بس");
63
- if (n < 0) throw new CalcError("مفيش مضروب لرقم سالب");
63
+ if (!Number.isInteger(n)) {
64
+ throw new CalcError(
65
+ tr("Factorial (!) only works on whole numbers", "المضروب (!) يشتغل على أرقام صحيحة بس"),
66
+ );
67
+ }
68
+ if (n < 0) throw new CalcError(tr("Negative numbers have no factorial", "مفيش مضروب لرقم سالب"));
64
69
  if (n > 170) return Infinity; // beyond this a double is Infinity anyway
65
70
  let result = 1;
66
71
  for (let i = 2; i <= n; i++) result *= i;
@@ -129,7 +134,9 @@ function tokenize(text) {
129
134
  while (i < text.length && /[0-9]/.test(text[i])) raw += text[i++];
130
135
  }
131
136
  const value = Number(raw);
132
- if (!Number.isFinite(value)) throw new CalcError(`رقم غير صالح: \`${raw}\``);
137
+ if (!Number.isFinite(value)) {
138
+ throw new CalcError(tr(`Invalid number: \`${raw}\``, `رقم غير صالح: \`${raw}\``));
139
+ }
133
140
  tokens.push({ type: "num", value });
134
141
  continue;
135
142
  }
@@ -147,7 +154,7 @@ function tokenize(text) {
147
154
  continue;
148
155
  }
149
156
 
150
- throw new CalcError(`رمز مش مفهوم: \`${char}\``);
157
+ throw new CalcError(tr(`Unknown symbol: \`${char}\``, `رمز مش مفهوم: \`${char}\``));
151
158
  }
152
159
 
153
160
  return tokens;
@@ -191,13 +198,17 @@ function parse(tokens) {
191
198
  left *= parseUnary();
192
199
  } else if (eat("/")) {
193
200
  const right = parseUnary();
194
- if (right === 0) throw new CalcError("القسمة على صفر ملهاش لازمة 😅");
201
+ if (right === 0) {
202
+ throw new CalcError(tr("Division by zero isn't defined 😅", "القسمة على صفر ملهاش لازمة 😅"));
203
+ }
195
204
  left /= right;
196
205
  } else if (peek()?.type === "%" && startsValue(peek(1))) {
197
206
  // infix `%` is modulo; the postfix «15%» form is handled in parsePostfix
198
207
  pos++;
199
208
  const right = parseUnary();
200
- if (right === 0) throw new CalcError("باقي القسمة على صفر مش معرّف");
209
+ if (right === 0) {
210
+ throw new CalcError(tr("Modulo by zero isn't defined", "باقي القسمة على صفر مش معرّف"));
211
+ }
201
212
  left %= right;
202
213
  } else if (startsValue(peek())) {
203
214
  // implicit multiplication: 2(3+4), 3pi, 2sqrt(9)
@@ -236,11 +247,11 @@ function parse(tokens) {
236
247
 
237
248
  function parsePrimary() {
238
249
  const token = peek();
239
- if (!token) throw new CalcError("المعادلة ناقصة");
250
+ if (!token) throw new CalcError(tr("The expression is incomplete", "المعادلة ناقصة"));
240
251
 
241
252
  if (eat("(")) {
242
253
  const value = parseExpression();
243
- expect(")", "قوس مفتوح ومقفلش");
254
+ expect(")", tr("A bracket was opened and never closed", "قوس مفتوح ومقفلش"));
244
255
  return value;
245
256
  }
246
257
 
@@ -255,43 +266,64 @@ function parse(tokens) {
255
266
 
256
267
  if (FUNCTIONS[name]) {
257
268
  const spec = FUNCTIONS[name];
258
- expect("(", `الدالة \`${name}\` محتاجة أقواس، زي \`${name}(9)\``);
269
+ expect(
270
+ "(",
271
+ tr(
272
+ `The function \`${name}\` needs brackets, like \`${name}(9)\``,
273
+ `الدالة \`${name}\` محتاجة أقواس، زي \`${name}(9)\``,
274
+ ),
275
+ );
259
276
  const args = [];
260
277
  if (peek()?.type !== ")") {
261
278
  args.push(parseExpression());
262
279
  while (eat(",")) args.push(parseExpression());
263
280
  }
264
- expect(")", `قوس \`${name}\` مقفلش`);
281
+ expect(")", tr(`The bracket of \`${name}\` is never closed`, `قوس \`${name}\` مقفلش`));
265
282
  if (spec.arity !== -1 && args.length !== spec.arity) {
266
283
  throw new CalcError(
267
- `الدالة \`${name}\` بتاخد ${spec.arity} ${spec.arity === 1 ? "قيمة" : "قيم"}`,
284
+ tr(
285
+ `The function \`${name}\` takes ${spec.arity} ${spec.arity === 1 ? "value" : "values"}`,
286
+ `الدالة \`${name}\` بتاخد ${spec.arity} ${spec.arity === 1 ? "قيمة" : "قيم"}`,
287
+ ),
288
+ );
289
+ }
290
+ if (!args.length) {
291
+ throw new CalcError(
292
+ tr(`The function \`${name}\` got no values`, `الدالة \`${name}\` من غير قيم`),
268
293
  );
269
294
  }
270
- if (!args.length) throw new CalcError(`الدالة \`${name}\` من غير قيم`);
271
295
  return spec.fn(...args);
272
296
  }
273
297
 
274
298
  if (name in CONSTANTS) return CONSTANTS[name];
275
299
 
276
- throw new CalcError(`مش عارف يعني إيه \`${name}\``);
300
+ throw new CalcError(tr(`I don't know what \`${name}\` is`, `مش عارف يعني إيه \`${name}\``));
277
301
  }
278
302
 
279
- throw new CalcError(`مكان غلط للرمز \`${token.type}\``);
303
+ throw new CalcError(
304
+ tr(`\`${token.type}\` is in the wrong place`, `مكان غلط للرمز \`${token.type}\``),
305
+ );
280
306
  }
281
307
 
282
308
  const result = parseExpression();
283
- if (pos < tokens.length) throw new CalcError("في زيادة في آخر المعادلة");
309
+ if (pos < tokens.length) {
310
+ throw new CalcError(
311
+ tr("There is something extra at the end of the expression", "في زيادة في آخر المعادلة"),
312
+ );
313
+ }
284
314
  return result;
285
315
  }
286
316
 
287
317
  function evaluate(expression) {
288
318
  const normalized = normalize(expression);
289
- if (!normalized) throw new CalcError("اكتب معادلة الأول");
290
- if (normalized.length > 300) throw new CalcError("المعادلة طويلة أوي");
319
+ if (!normalized) throw new CalcError(tr("Type an expression first", "اكتب معادلة الأول"));
320
+ if (normalized.length > 300) {
321
+ throw new CalcError(tr("The expression is too long", "المعادلة طويلة أوي"));
322
+ }
291
323
 
292
324
  const value = parse(tokenize(normalized));
293
325
  if (typeof value !== "number" || Number.isNaN(value)) {
294
- throw new CalcError("النتيجة مش رقم صالح");
326
+ throw new CalcError(tr("The result isn't a valid number", "النتيجة مش رقم صالح"));
295
327
  }
296
328
  return { normalized, value };
297
329
  }
@@ -316,7 +348,27 @@ function formatNumber(value) {
316
348
  return fraction ? `${grouped}.${fraction}` : grouped;
317
349
  }
318
350
 
319
- const HELP_TEXT =
351
+ const helpText = () =>
352
+ tr(
353
+ "🧮 *Calculator*\n\n" +
354
+ "*Usage:* `!calc <expression>`\n" +
355
+ "or reply to a message containing an expression with `!calc`\n\n" +
356
+ "*Operators:* `+` `-` `*` `/` `%` (modulo) `^` (power) `!` (factorial)\n" +
357
+ "*Percentages:* `15%` · `20% of 300`\n" +
358
+ "*Constants:* `pi` · `e` · `tau`\n" +
359
+ "*Functions:* sqrt, cbrt, abs, round, floor, ceil, ln, log, log2, exp,\n" +
360
+ "sin, cos, tan, sind, cosd, tand, asin, acos, atan, deg, rad,\n" +
361
+ "pow, root, hypot, min, max, avg, sum, fact\n\n" +
362
+ "*Examples:*\n" +
363
+ "`!calc (12 + 8) * 3`\n" +
364
+ "`!calc 2^10`\n" +
365
+ "`!calc 25% of 480`\n" +
366
+ "`!calc sqrt(144) + 5!`\n" +
367
+ "`!calc max(3, 9, 4) * pi`",
368
+ HELP_TEXT_AR,
369
+ );
370
+
371
+ const HELP_TEXT_AR =
320
372
  "🧮 *الآلة الحاسبة*\n\n" +
321
373
  "*الاستخدام:* `!calc <معادلة>`\n" +
322
374
  "أو رد على رسالة فيها معادلة واكتب `!calc`\n\n" +
@@ -336,8 +388,14 @@ const HELP_TEXT =
336
388
  module.exports = {
337
389
  name: "calc",
338
390
  aliases: ["calculate", "حساب", "احسب", "="],
339
- description: "آلة حاسبة: عمليات حسابية، نِسب، أُسس، ودوال رياضية.",
340
- usage: "calc <معادلة>",
391
+ description: {
392
+ en: "Calculator: arithmetic, percentages, powers and math functions.",
393
+ ar: "آلة حاسبة: عمليات حسابية، ونِسب مئوية، وأُسس، ودوال رياضية.",
394
+ },
395
+ usage: {
396
+ en: "calc <expression>",
397
+ ar: "calc <معادلة>",
398
+ },
341
399
  chat: "all",
342
400
 
343
401
  async execute(sock, msg, args) {
@@ -350,7 +408,7 @@ module.exports = {
350
408
  const expression = args.join(" ").trim() || quotedText.trim();
351
409
 
352
410
  if (!expression) {
353
- return sendBotMessage(sock, chatId, { text: HELP_TEXT }, { replyTo: msg });
411
+ return sendBotMessage(sock, chatId, { text: helpText() }, { replyTo: msg });
354
412
  }
355
413
 
356
414
  try {
@@ -364,11 +422,19 @@ module.exports = {
364
422
  { replyTo: msg },
365
423
  );
366
424
  } catch (error) {
367
- const reason = error instanceof CalcError ? error.message : "المعادلة مش مفهومة";
425
+ const reason =
426
+ error instanceof CalcError
427
+ ? error.message
428
+ : tr("I couldn't understand that expression", "المعادلة مش مفهومة");
368
429
  return sendBotMessage(
369
430
  sock,
370
431
  chatId,
371
- { text: `❌ ${reason}\n\nاكتب \`!calc\` لوحده عشان تشوف الأمثلة.` },
432
+ {
433
+ text: tr(
434
+ `❌ ${reason}\n\nSend \`!calc\` on its own to see examples.`,
435
+ `❌ ${reason}\n\nاكتب \`!calc\` لوحده عشان تشوف الأمثلة.`,
436
+ ),
437
+ },
372
438
  { replyTo: msg },
373
439
  );
374
440
  }
@@ -8,13 +8,20 @@ const {
8
8
  listDebts: storeListDebts,
9
9
  } = require("../utils/storage.cjs");
10
10
  const logger = require("../utils/logger.cjs");
11
+ const { tr } = require("../utils/i18n.cjs");
11
12
  const normalizeJid = require("../utils/normalizeJid.esm.js").default;
12
13
 
13
14
  module.exports = {
14
15
  name: "debt",
15
16
  aliases: ["دين", "owes"],
16
- description: "Private debt tracking system",
17
- usage: "debt add <المبلغ> [الوصف]\ndebt del <id>\ndebt list",
17
+ description: {
18
+ en: "Private debt tracker.",
19
+ ar: "نظام خاص لتتبّع الديون.",
20
+ },
21
+ usage: {
22
+ en: "debt add <amount> [description]\ndebt del <id>\ndebt list",
23
+ ar: "debt add <المبلغ> [الوصف]\ndebt del <id>\ndebt list",
24
+ },
18
25
  chat: "private",
19
26
 
20
27
  async execute(sock, msg, args) {
@@ -45,13 +52,20 @@ module.exports = {
45
52
 
46
53
  default:
47
54
  await sock.sendMessage(remote, {
48
- text:
55
+ text: tr(
56
+ `📊 *Debt tracker (private chats only)*\n\n` +
57
+ `Commands:\n\n` +
58
+ `• \`!debt add <amount> [description]\` — add a debt\n` +
59
+ `• \`!debt list\` — list debts\n` +
60
+ `• \`!debt del <id>\` — delete a debt\n\n` +
61
+ `Example:\n\`!debt add 50 lunch\``,
49
62
  `📊 *نظام الديون (خاص فقط)*\n\n` +
50
- `الأوامر:\n\n` +
51
- `• \`!debt add <amount> [description]\` — إضافة دين\n` +
52
- `• \`!debt list\` — عرض الديون\n` +
53
- `• \`!debt del <id>\` — حذف دين\n\n` +
54
- `مثال:\n\`!debt add 50 غداء\``,
63
+ `الأوامر:\n\n` +
64
+ `• \`!debt add <amount> [description]\` — إضافة دين\n` +
65
+ `• \`!debt list\` — عرض الديون\n` +
66
+ `• \`!debt del <id>\` — حذف دين\n\n` +
67
+ `مثال:\n\`!debt add 50 غداء\``,
68
+ ),
55
69
  });
56
70
  }
57
71
  },
@@ -62,16 +76,19 @@ async function addDebt(sock, msg, args, creditorId, debtorId, chatKey) {
62
76
 
63
77
  if (args.length < 1) {
64
78
  return sock.sendMessage(remote, {
65
- text: "❌ الاستخدام: `!debt add <amount> [description]`",
79
+ text: tr(
80
+ "❌ Usage: `!debt add <amount> [description]`",
81
+ "❌ الاستخدام: `!debt add <amount> [description]`",
82
+ ),
66
83
  });
67
84
  }
68
85
 
69
86
  const amount = parseFloat(args[0]);
70
- const description = args.slice(1).join(" ") || "بدون وصف";
87
+ const description = args.slice(1).join(" ") || tr("No description", "بدون وصف");
71
88
 
72
89
  if (isNaN(amount) || amount <= 0) {
73
90
  return sock.sendMessage(remote, {
74
- text: "❌ المبلغ يجب أن يكون رقم موجب",
91
+ text: tr("❌ The amount must be a positive number", "❌ المبلغ يجب أن يكون رقم موجب"),
75
92
  });
76
93
  }
77
94
 
@@ -85,18 +102,25 @@ async function addDebt(sock, msg, args, creditorId, debtorId, chatKey) {
85
102
  });
86
103
 
87
104
  await sock.sendMessage(remote, {
88
- text:
105
+ text: tr(
106
+ `✅ *Debt added*\n\n` +
107
+ `Debtor: ${debtorId.split("@")[0]}\n` +
108
+ `Creditor: ${creditorId.split("@")[0]}\n` +
109
+ `Amount: ${amount}\n` +
110
+ `Description: ${description}\n` +
111
+ `Record: #${debt.id}`,
89
112
  `✅ *تم إضافة الدين*\n\n` +
90
- `المدين: ${debtorId.split("@")[0]}\n` +
91
- `الدائن: ${creditorId.split("@")[0]}\n` +
92
- `المبلغ: ${amount}\n` +
93
- `الوصف: ${description}\n` +
94
- `رقم السجل: #${debt.id}`,
113
+ `المدين: ${debtorId.split("@")[0]}\n` +
114
+ `الدائن: ${creditorId.split("@")[0]}\n` +
115
+ `المبلغ: ${amount}\n` +
116
+ `الوصف: ${description}\n` +
117
+ `رقم السجل: #${debt.id}`,
118
+ ),
95
119
  });
96
120
  } catch (err) {
97
121
  logger.error(err, "[Debt] Add error:");
98
122
  await sock.sendMessage(remote, {
99
- text: "❌ حدث خطأ أثناء تسجيل الدين",
123
+ text: tr("❌ Something went wrong while saving the debt", "❌ حدث خطأ أثناء تسجيل الدين"),
100
124
  });
101
125
  }
102
126
  }
@@ -108,26 +132,26 @@ async function listDebts(sock, msg, creditorId, debtorId, chatKey) {
108
132
  const debts = storeListDebts(chatKey, { settled: false });
109
133
 
110
134
  if (debts.length === 0) {
111
- return sock.sendMessage(remote, { text: "لا توجد ديون حالياً ✅" });
135
+ return sock.sendMessage(remote, { text: tr("No debts right now ✅", "لا توجد ديون حالياً ✅") });
112
136
  }
113
137
 
114
- let text = "📋 *قائمة الديون:*\n\n";
138
+ let text = tr("📋 *Debts:*\n\n", "📋 *قائمة الديون:*\n\n");
115
139
 
116
140
  debts.forEach((d) => {
117
- const date = new Date(d.created_at).toLocaleDateString("ar-EG");
141
+ const date = new Date(d.created_at).toLocaleDateString(tr("en-GB", "ar-EG"));
118
142
  text += `*#${d.id}*\n`;
119
- text += `المدين: ${d.debtor_id.split("@")[0]}\n`;
120
- text += `الدائن: ${d.creditor_id.split("@")[0]}\n`;
121
- text += `المبلغ: ${d.amount}\n`;
122
- text += `الوصف: ${d.description}\n`;
123
- text += `التاريخ: ${date}\n\n`;
143
+ text += `${tr("Debtor", "المدين")}: ${d.debtor_id.split("@")[0]}\n`;
144
+ text += `${tr("Creditor", "الدائن")}: ${d.creditor_id.split("@")[0]}\n`;
145
+ text += `${tr("Amount", "المبلغ")}: ${d.amount}\n`;
146
+ text += `${tr("Description", "الوصف")}: ${d.description}\n`;
147
+ text += `${tr("Date", "التاريخ")}: ${date}\n\n`;
124
148
  });
125
149
 
126
150
  await sock.sendMessage(remote, { text });
127
151
  } catch (err) {
128
152
  logger.error(err, "[Debt] List error:");
129
153
  await sock.sendMessage(remote, {
130
- text: "❌ حدث خطأ أثناء عرض الديون",
154
+ text: tr("❌ Something went wrong while listing debts", "❌ حدث خطأ أثناء عرض الديون"),
131
155
  });
132
156
  }
133
157
  }
@@ -137,14 +161,14 @@ async function deleteDebt(sock, msg, args, creditorId, debtorId, chatKey) {
137
161
 
138
162
  if (args.length < 1) {
139
163
  return sock.sendMessage(remote, {
140
- text: "❌ الاستخدام: `!debt del <id>`",
164
+ text: tr("❌ Usage: `!debt del <id>`", "❌ الاستخدام: `!debt del <id>`"),
141
165
  });
142
166
  }
143
167
 
144
168
  const id = parseInt(args[0]);
145
169
  if (isNaN(id)) {
146
170
  return sock.sendMessage(remote, {
147
- text: "❌ رقم السجل غير صحيح",
171
+ text: tr("❌ Invalid record number", "❌ رقم السجل غير صحيح"),
148
172
  });
149
173
  }
150
174
 
@@ -152,24 +176,26 @@ async function deleteDebt(sock, msg, args, creditorId, debtorId, chatKey) {
152
176
  const debt = storeGetDebt(id);
153
177
 
154
178
  if (!debt) {
155
- return sock.sendMessage(remote, { text: "❌ لم يتم العثور على الدين" });
179
+ return sock.sendMessage(remote, {
180
+ text: tr("❌ That debt wasn't found", "❌ لم يتم العثور على الدين"),
181
+ });
156
182
  }
157
183
 
158
184
  if (debt.group_id !== chatKey) {
159
185
  return sock.sendMessage(remote, {
160
- text: "❌ هذا الدين لا يخص هذه المحادثة",
186
+ text: tr("❌ That debt belongs to another chat", "❌ هذا الدين لا يخص هذه المحادثة"),
161
187
  });
162
188
  }
163
189
 
164
190
  storeDeleteDebt(id);
165
191
 
166
192
  await sock.sendMessage(remote, {
167
- text: `🗑️ تم حذف الدين رقم #${id} بنجاح`,
193
+ text: tr(`🗑️ Deleted debt #${id}`, `🗑️ تم حذف الدين رقم #${id} بنجاح`),
168
194
  });
169
195
  } catch (err) {
170
196
  logger.error(err, "[Debt] Del error:");
171
197
  await sock.sendMessage(remote, {
172
- text: "❌ حدث خطأ أثناء حذف الدين",
198
+ text: tr("❌ Something went wrong while deleting the debt", "❌ حدث خطأ أثناء حذف الدين"),
173
199
  });
174
200
  }
175
201
  }
@@ -1,10 +1,17 @@
1
1
  // file: /commands/deleteschedule.js
2
2
  const { deleteScheduledJob, getScheduledJobs } = require("../../scheduler.cjs");
3
+ const { tr } = require("../utils/i18n.cjs");
3
4
 
4
5
  module.exports = {
5
6
  name: "deleteschedule",
6
- description: "Deletes a scheduled job by its ID.",
7
- usage: "deleteschedule <id>",
7
+ description: {
8
+ en: "Deletes a scheduled message by its ID.",
9
+ ar: "يحذف رسالة مجدولة برقمها التعريفي (ID).",
10
+ },
11
+ usage: {
12
+ en: "deleteschedule <id>",
13
+ ar: "deleteschedule <id>",
14
+ },
8
15
  chat: "all",
9
16
  userAdminRequired: true,
10
17
 
@@ -13,7 +20,10 @@ module.exports = {
13
20
 
14
21
  if (!jobIdToDelete) {
15
22
  return await sock.sendMessage(msg.key.remoteJid, {
16
- text: "يرجى تحديد ID المهمة التي تريد حذفها. يمكنك الحصول على الـ ID باستخدام أمر `!listschedules`.",
23
+ text: tr(
24
+ "Give the ID of the scheduled message to delete. `!listschedules` shows the IDs.",
25
+ "يرجى تحديد ID المهمة التي تريد حذفها. يمكنك الحصول على الـ ID باستخدام أمر `!listschedules`.",
26
+ ),
17
27
  });
18
28
  }
19
29
 
@@ -22,7 +32,10 @@ module.exports = {
22
32
 
23
33
  if (!jobExists) {
24
34
  return await sock.sendMessage(msg.key.remoteJid, {
25
- text: `⚠️ لم يتم العثور على مهمة بهذا الـ ID: \`${jobIdToDelete}\``,
35
+ text: tr(
36
+ `⚠️ No scheduled message has the ID \`${jobIdToDelete}\``,
37
+ `⚠️ لم يتم العثور على مهمة بهذا الـ ID: \`${jobIdToDelete}\``,
38
+ ),
26
39
  });
27
40
  }
28
41
 
@@ -30,7 +43,10 @@ module.exports = {
30
43
  deleteScheduledJob(jobIdToDelete);
31
44
 
32
45
  await sock.sendMessage(msg.key.remoteJid, {
33
- text: `✅ تم حذف المهمة المجدولة بالـ ID: \`${jobIdToDelete}\` بنجاح.`,
46
+ text: tr(
47
+ `✅ Deleted the scheduled message \`${jobIdToDelete}\`.`,
48
+ `✅ تم حذف المهمة المجدولة بالـ ID: \`${jobIdToDelete}\` بنجاح.`,
49
+ ),
34
50
  });
35
51
  },
36
52
  };
@@ -8,27 +8,47 @@ const {
8
8
  isExplicitEn,
9
9
  oppositeNumeralLang,
10
10
  } = require("../utils/numerals.cjs");
11
+ const { tr } = require("../utils/i18n.cjs");
11
12
 
12
13
  function mixedDigitsNotice(prefix) {
13
- return `⚠️ الأرقام مختلطة (عربي وإنجليزي). حدد الاتجاه:\n\`${prefix}digit ar ...\` أو \`${prefix}digit en ...\`.\nDigits are mixed Arabic and English. Specify \`${prefix}digit ar\` or \`${prefix}digit en\`.`;
14
+ return tr(
15
+ `⚠️ The digits are mixed (Arabic and English). Say which way:\n\`${prefix}digit ar ...\` or \`${prefix}digit en ...\`.`,
16
+ `⚠️ الأرقام مختلطة (عربي وإنجليزي). حدد الاتجاه:\n\`${prefix}digit ar ...\` أو \`${prefix}digit en ...\`.`,
17
+ );
14
18
  }
15
19
 
16
20
  function helpText(prefix) {
17
- return `🔢 *تحويل الأرقام / Digit converter*
21
+ return tr(
22
+ `🔢 *Digit converter*
18
23
 
19
- • \`${prefix}digit 12345\` ➔ ١٢٣٤٥ (يُكتشف تلقائياً / auto-detected)
24
+ • \`${prefix}digit 12345\` ➔ ١٢٣٤٥ (auto-detected)
25
+ • \`${prefix}digit ١٢٣٤٥\` ➔ 12345
26
+ • \`${prefix}digit ar 12345\` ➔ ١٢٣٤٥
27
+ • \`${prefix}digit en ١٢٣٤٥\` ➔ 12345
28
+ _Or reply to a message with digits in it using \`${prefix}digit\` — it converts the other way._
29
+ _When Arabic and English digits are mixed, say which way: \`${prefix}digit ar\` or \`${prefix}digit en\`._`,
30
+ `🔢 *تحويل الأرقام*
31
+
32
+ • \`${prefix}digit 12345\` ➔ ١٢٣٤٥ (يُكتشف تلقائياً)
20
33
  • \`${prefix}digit ١٢٣٤٥\` ➔ 12345
21
34
  • \`${prefix}digit ar 12345\` ➔ ١٢٣٤٥
22
35
  • \`${prefix}digit en ١٢٣٤٥\` ➔ 12345
23
36
  _أو رد على رسالة فيها أرقام بـ \`${prefix}digit\` — يحوّل للاتجاه المعاكس._
24
- _إذا اختلطت الأرقام العربية والإنجليزية يجب تحديد الاتجاه: \`${prefix}digit ar\` أو \`${prefix}digit en\`._`;
37
+ _إذا اختلطت الأرقام العربية والإنجليزية يجب تحديد الاتجاه: \`${prefix}digit ar\` أو \`${prefix}digit en\`._`,
38
+ );
25
39
  }
26
40
 
27
41
  module.exports = {
28
42
  name: "digit",
29
43
  aliases: ["digits", "num", "numbers", "numeral", "ارقام", "رقم"],
30
- description: "Convert numbers between Arabic and English digits",
31
- usage: "digit [en|ar] [number/text] (or reply to a message)",
44
+ description: {
45
+ en: "Converts numbers between Arabic-Indic (٠١٢) and English (012) digits.",
46
+ ar: "يحوّل الأرقام بين الأرقام العربية (٠١٢) والإنجليزية (012).",
47
+ },
48
+ usage: {
49
+ en: "digit [en|ar] [number/text] (or reply to a message)",
50
+ ar: "digit [en|ar] [رقم/نص] (أو رد على رسالة)",
51
+ },
32
52
  chat: "all",
33
53
 
34
54
  async execute(sock, msg, args) {
@@ -62,7 +82,10 @@ module.exports = {
62
82
  await sock.sendMessage(
63
83
  chatId,
64
84
  {
65
- text: `❌ اكتب رقماً بعد الأمر، أو رد على رسالة.\nType a number after the command, or reply to a message.\nمثال: \`${prefix}digit 12345\` أو \`${prefix}digit ar 12345\``,
85
+ text: tr(
86
+ `❌ Type a number after the command, or reply to a message.\nExample: \`${prefix}digit 12345\` or \`${prefix}digit ar 12345\``,
87
+ `❌ اكتب رقماً بعد الأمر، أو رد على رسالة.\nمثال: \`${prefix}digit 12345\` أو \`${prefix}digit ar 12345\``,
88
+ ),
66
89
  },
67
90
  { quoted: msg },
68
91
  );
@@ -84,7 +107,10 @@ module.exports = {
84
107
  await sock.sendMessage(
85
108
  chatId,
86
109
  {
87
- text: `❌ لا توجد أرقام للتحويل.\nNo digits found to convert.\nاستخدم:\n• \`${prefix}digit 12345\`\n• \`${prefix}digit ar\` / \`${prefix}digit en\` مع النص أو بالرد على رسالة.`,
110
+ text: tr(
111
+ `❌ No digits to convert.\nUse:\n• \`${prefix}digit 12345\`\n• \`${prefix}digit ar\` / \`${prefix}digit en\` with text, or as a reply to a message.`,
112
+ `❌ لا توجد أرقام للتحويل.\nاستخدم:\n• \`${prefix}digit 12345\`\n• \`${prefix}digit ar\` / \`${prefix}digit en\` مع النص أو بالرد على رسالة.`,
113
+ ),
88
114
  },
89
115
  { quoted: msg },
90
116
  );