levix-bot 4.9.1 → 5.0.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 (245) hide show
  1. package/README.md +57 -3
  2. package/SETUP.md +63 -7
  3. package/app.cjs +159 -46
  4. package/deploy/install.sh +10 -5
  5. package/package.json +9 -6
  6. package/public/dashboard/assets/40af6d88b63079a0-BZ8ojJNu.woff2 +0 -0
  7. package/public/dashboard/assets/481acf6760031cee-BypgxfGb.woff2 +0 -0
  8. package/public/dashboard/assets/6d3351fc535f8ef3-D2-eand5.woff2 +0 -0
  9. package/public/dashboard/assets/8ab0af53a3bda9d3-CyCXRvzh.woff2 +0 -0
  10. package/public/dashboard/assets/8f262393e9249e61-TQp-UTiE.woff2 +0 -0
  11. package/public/dashboard/assets/94d65887a83f1282-DmpS2jIq.woff2 +0 -0
  12. package/public/dashboard/assets/99e400330f36ae77-D3oMJlXt.woff2 +0 -0
  13. package/public/dashboard/assets/9d1f41b13e519d90-BVNSOH3d.woff2 +0 -0
  14. package/public/dashboard/assets/a005256cb957ecc7-CoYeBiSI.woff2 +0 -0
  15. package/public/dashboard/assets/b19c2080652a3c2b-DIC32ArD.woff2 +0 -0
  16. package/public/dashboard/assets/c4064400db3750ce-BehTv68k.woff2 +0 -0
  17. package/public/dashboard/assets/c69d345fa1068c2d-CmI34b-g.woff2 +0 -0
  18. package/public/dashboard/assets/cc27b30471250057-6fWv1k7M.woff2 +0 -0
  19. package/public/dashboard/assets/d8c30647abfeffe6-eXO_dkmS.woff2 +0 -0
  20. package/public/dashboard/assets/eb83d8d40af4411f-Buze_B52.woff2 +0 -0
  21. package/public/dashboard/assets/effc6711249e7349-qRpaaN48.woff2 +0 -0
  22. package/public/dashboard/assets/gateway-BDYet0pI.css +1 -0
  23. package/public/dashboard/assets/gateway-BYt6-s1O.js +1 -0
  24. package/public/dashboard/assets/index-B9wFpD_z.css +2 -0
  25. package/public/dashboard/assets/index-DWcQmu0_.js +124 -0
  26. package/public/dashboard/assets/index-Da-j89O-.js +458 -0
  27. package/public/dashboard/font-licenses/jetbrainsmono-OFL.txt +93 -0
  28. package/public/dashboard/font-licenses/plusjakartasans-OFL.txt +93 -0
  29. package/public/dashboard/font-licenses/tajawal-OFL.txt +93 -0
  30. package/public/dashboard/gateway.html +17 -0
  31. package/public/dashboard/index.html +3 -5
  32. package/public/ui-boot.js +33 -14
  33. package/scheduler.cjs +76 -23
  34. package/src/auth/auth-storage.cjs +54 -7
  35. package/src/auth/use-database-auth-state.js +70 -39
  36. package/src/automation/engine.js +412 -0
  37. package/src/automation/limits.cjs +6 -0
  38. package/src/automation/manage.js +290 -0
  39. package/src/automation/reactions.js +471 -0
  40. package/src/automation/rules.cjs +114 -0
  41. package/src/automation/status.cjs +76 -0
  42. package/src/backup/account.cjs +29 -0
  43. package/src/backup/activation.cjs +247 -0
  44. package/src/backup/content.cjs +36 -0
  45. package/src/backup/create.cjs +280 -0
  46. package/src/backup/extensions.cjs +101 -0
  47. package/src/backup/format.cjs +565 -0
  48. package/src/backup/jobs.cjs +111 -0
  49. package/src/backup/journal.cjs +41 -0
  50. package/src/backup/plan.cjs +223 -0
  51. package/src/backup/recovery.cjs +110 -0
  52. package/src/backup/restore.cjs +460 -0
  53. package/src/backup/uploads.cjs +146 -0
  54. package/src/bootstrap/core.js +50 -12
  55. package/src/bootstrap/panel.js +53 -2
  56. package/src/bootstrap/session-startup-policy.js +8 -1
  57. package/src/cli.js +163 -22
  58. package/src/commands/autodelete.cjs +41 -57
  59. package/src/commands/autoschedule.cjs +7 -33
  60. package/src/commands/blacklist.cjs +17 -35
  61. package/src/commands/block.cjs +4 -18
  62. package/src/commands/calc.cjs +22 -74
  63. package/src/commands/debt.cjs +28 -59
  64. package/src/commands/deleteschedule.cjs +7 -23
  65. package/src/commands/digit.cjs +5 -39
  66. package/src/commands/gemini.cjs +135 -218
  67. package/src/commands/group/add.cjs +28 -76
  68. package/src/commands/group/all.cjs +4 -15
  69. package/src/commands/group/antilink.cjs +28 -41
  70. package/src/commands/group/antispam.cjs +25 -35
  71. package/src/commands/group/approveall.cjs +7 -21
  72. package/src/commands/group/clearwarns.cjs +4 -18
  73. package/src/commands/group/deletenote.cjs +4 -18
  74. package/src/commands/group/demote.cjs +6 -23
  75. package/src/commands/group/flagged.cjs +10 -19
  76. package/src/commands/group/kick.cjs +26 -36
  77. package/src/commands/group/media.cjs +21 -36
  78. package/src/commands/group/members.cjs +16 -28
  79. package/src/commands/group/note.cjs +3 -14
  80. package/src/commands/group/policy.cjs +16 -37
  81. package/src/commands/group/promote.cjs +5 -22
  82. package/src/commands/group/removeall.cjs +6 -38
  83. package/src/commands/group/rules.cjs +4 -19
  84. package/src/commands/group/save.cjs +4 -18
  85. package/src/commands/group/setname.cjs +5 -19
  86. package/src/commands/group/setpp.cjs +8 -26
  87. package/src/commands/group/setrules.cjs +4 -15
  88. package/src/commands/group/setwarn.cjs +6 -23
  89. package/src/commands/group/tagadmins.cjs +5 -16
  90. package/src/commands/group/warn.cjs +5 -16
  91. package/src/commands/group/warns.cjs +12 -33
  92. package/src/commands/group/welcome.cjs +17 -34
  93. package/src/commands/group.cjs +91 -68
  94. package/src/commands/help.cjs +48 -89
  95. package/src/commands/lang.cjs +38 -97
  96. package/src/commands/listschedules.cjs +19 -30
  97. package/src/commands/loop.cjs +9 -55
  98. package/src/commands/md.cjs +2 -13
  99. package/src/commands/memory.cjs +53 -87
  100. package/src/commands/mod.cjs +40 -79
  101. package/src/commands/notes.cjs +4 -15
  102. package/src/commands/pack.cjs +26 -49
  103. package/src/commands/packs.cjs +8 -18
  104. package/src/commands/perm.cjs +48 -51
  105. package/src/commands/ping.cjs +2 -10
  106. package/src/commands/poll.cjs +5 -38
  107. package/src/commands/prayer.cjs +55 -36
  108. package/src/commands/qr.cjs +4 -18
  109. package/src/commands/rand.cjs +9 -58
  110. package/src/commands/restart.cjs +15 -33
  111. package/src/commands/schedule.cjs +5 -25
  112. package/src/commands/score.cjs +6 -27
  113. package/src/commands/send.cjs +4 -18
  114. package/src/commands/setprefix.cjs +11 -23
  115. package/src/commands/shortlink.cjs +13 -39
  116. package/src/commands/status.cjs +188 -76
  117. package/src/commands/sticker.cjs +5 -16
  118. package/src/commands/stickers.cjs +16 -20
  119. package/src/commands/stopbot.cjs +9 -25
  120. package/src/commands/stt.cjs +75 -107
  121. package/src/commands/todo.cjs +11 -31
  122. package/src/commands/toimage.cjs +11 -27
  123. package/src/commands/translate.cjs +53 -36
  124. package/src/commands/tts.cjs +46 -40
  125. package/src/commands/unblock.cjs +3 -17
  126. package/src/commands/update.cjs +23 -0
  127. package/src/commands/weather.cjs +40 -47
  128. package/src/config/ai-identity.cjs +14 -1
  129. package/src/config/baileys.config.js +16 -3
  130. package/src/config/data-dir.cjs +37 -0
  131. package/src/config/defaults.cjs +1 -0
  132. package/src/config/exit-codes.cjs +11 -0
  133. package/src/config/lock.cjs +55 -81
  134. package/src/config/official-links.cjs +61 -0
  135. package/src/config/paths.cjs +4 -33
  136. package/src/config/release.cjs +87 -0
  137. package/src/config/settings.cjs +199 -10
  138. package/src/core/connection.js +77 -9
  139. package/src/core/events.js +119 -33
  140. package/src/core/session.js +536 -84
  141. package/src/core/socket.js +81 -10
  142. package/src/db/copy.cjs +136 -0
  143. package/src/db/db.cjs +241 -36
  144. package/src/db/startup-guard.js +5 -0
  145. package/src/db/store.cjs +561 -54
  146. package/src/diagnostics/baileysLog.cjs +87 -0
  147. package/src/diagnostics/debugLog.cjs +16 -4
  148. package/src/diagnostics/device.cjs +4 -2
  149. package/src/diagnostics/nodeRuntime.cjs +131 -0
  150. package/src/diagnostics/signalSessionInspect.cjs +38 -0
  151. package/src/domain/command.js +24 -22
  152. package/src/extensions/autoReply.cjs +521 -0
  153. package/src/extensions/context.cjs +73 -0
  154. package/src/extensions/contract.cjs +69 -0
  155. package/src/extensions/entitlement/client.cjs +381 -0
  156. package/src/extensions/entitlement/index.cjs +629 -0
  157. package/src/extensions/entitlement/installation.cjs +117 -0
  158. package/src/extensions/entitlement/keys.cjs +72 -0
  159. package/src/extensions/entitlement/state.cjs +201 -0
  160. package/src/extensions/entitlement/target.cjs +7 -0
  161. package/src/extensions/entitlement/token.cjs +225 -0
  162. package/src/extensions/host.cjs +519 -0
  163. package/src/extensions/templateKeys.cjs +81 -0
  164. package/src/handlers/command.handler.js +191 -64
  165. package/src/handlers/group.handler.js +78 -18
  166. package/src/handlers/message.handler.js +56 -25
  167. package/src/i18n/catalog.generated.cjs +3537 -0
  168. package/src/index.js +51 -12
  169. package/src/legal/bundled/ar.json +102 -0
  170. package/src/legal/bundled/en.json +102 -0
  171. package/src/legal/bundled/es-419.json +102 -0
  172. package/src/legal/bundled/pt-BR.json +102 -0
  173. package/src/legal/cli.cjs +200 -0
  174. package/src/legal/consent.cjs +187 -0
  175. package/src/legal/document.cjs +156 -0
  176. package/src/legal/keys.cjs +100 -0
  177. package/src/legal/release.cjs +226 -0
  178. package/src/legal/remote.cjs +419 -0
  179. package/src/legal/terms.cjs +142 -0
  180. package/src/messaging/escape.cjs +31 -0
  181. package/src/messaging/health.cjs +65 -0
  182. package/src/messaging/identity.cjs +42 -0
  183. package/src/messaging/message.cjs +136 -0
  184. package/src/messaging/parser.cjs +88 -0
  185. package/src/messaging/router.cjs +217 -0
  186. package/src/middleware/permissions.middleware.js +34 -2
  187. package/src/panel/account-profile.cjs +489 -0
  188. package/src/panel/fallback-page.cjs +177 -0
  189. package/src/panel/password-reset.cjs +13 -14
  190. package/src/panel/recovery-email.cjs +3 -1
  191. package/src/routes/backup.api.esm.js +175 -0
  192. package/src/routes/dashboard.api.esm.js +183 -7
  193. package/src/routes/plus.api.esm.js +172 -0
  194. package/src/routes/reactions.api.esm.js +60 -0
  195. package/src/services/aiAgent.cjs +56 -43
  196. package/src/services/aiDocs.cjs +187 -0
  197. package/src/services/aiImage.cjs +183 -0
  198. package/src/services/aiMedia.cjs +146 -0
  199. package/src/services/aiProviders.cjs +76 -80
  200. package/src/services/aiRouter.cjs +2 -2
  201. package/src/services/aiToolAuth.cjs +76 -4
  202. package/src/services/aiTools.cjs +431 -105
  203. package/src/services/autoDelete.cjs +9 -1
  204. package/src/services/levix-docs.generated.json +2623 -0
  205. package/src/services/memoryPolicy.cjs +56 -0
  206. package/src/services/updateCheck.cjs +362 -0
  207. package/src/stickers/errors.cjs +53 -97
  208. package/src/stickers/library.cjs +13 -6
  209. package/src/stickers/owner.cjs +1 -1
  210. package/src/utils/commandContext.cjs +13 -0
  211. package/src/utils/commandDocs.cjs +42 -20
  212. package/src/utils/geminiHttpOptions.cjs +56 -0
  213. package/src/utils/geminiMedia.cjs +28 -3
  214. package/src/utils/groupMetadataCache.cjs +386 -21
  215. package/src/utils/httpsFetch.cjs +113 -0
  216. package/src/utils/i18n.cjs +117 -7
  217. package/src/utils/linkPreview.cjs +90 -0
  218. package/src/utils/logger.cjs +6 -0
  219. package/src/utils/markdownParser.cjs +3 -3
  220. package/src/utils/memory.cjs +375 -28
  221. package/src/utils/messageContent.cjs +7 -1
  222. package/src/utils/moderationAction.cjs +116 -73
  223. package/src/utils/moderationSummary.cjs +32 -56
  224. package/src/utils/permissionLevel.cjs +7 -28
  225. package/src/utils/permissions.cjs +23 -14
  226. package/src/utils/permissions.esm.js +99 -166
  227. package/src/utils/recentMessageCache.esm.js +241 -37
  228. package/src/utils/recurrence.cjs +78 -66
  229. package/src/utils/sendBotMessage.cjs +14 -29
  230. package/src/utils/sendBotMessage.esm.js +28 -13
  231. package/src/utils/statusMessage.cjs +94 -33
  232. package/src/utils/stickerBot.cjs +18 -16
  233. package/src/utils/storage.cjs +2 -0
  234. package/src/utils/storage.esm.js +2 -0
  235. package/src/utils/thumbnail.cjs +5 -21
  236. package/public/dashboard/assets/index-B1sOW2VX.js +0 -561
  237. package/public/dashboard/assets/index-CK8osB4o.css +0 -2
  238. package/public/dashboard.css +0 -3127
  239. package/public/dashboard.js +0 -1981
  240. package/public/gateway-i18n.js +0 -321
  241. package/public/gateway.js +0 -70
  242. package/views/dashboard.ejs +0 -775
  243. package/views/login.ejs +0 -408
  244. package/views/qr.ejs +0 -155
  245. package/views/setup.ejs +0 -118
@@ -2,18 +2,10 @@ const { scheduleNewJob, saveScheduledJob } = require("../../scheduler.cjs");
2
2
  const { randomUUID } = require("node:crypto");
3
3
  const logger = require("../utils/logger.cjs");
4
4
  const { parseRecurringArgs } = require("../utils/recurrence.cjs");
5
- const { tr } = require("../utils/i18n.cjs");
5
+ const { t } = require("../utils/i18n.cjs");
6
6
 
7
7
  module.exports = {
8
8
  name: "autoschedule",
9
- description: {
10
- en: "Schedules a recurring message (daily or weekly).",
11
- ar: "يجدول رسالة متكررة (يومية أو أسبوعية).",
12
- },
13
- usage: {
14
- en: "autoschedule daily <HH:mm> <message>\nautoschedule weekly <day> <HH:mm> <message>",
15
- ar: "autoschedule daily <HH:mm> <الرسالة>\nautoschedule weekly <اليوم> <HH:mm> <الرسالة>",
16
- },
17
9
  chat: "all",
18
10
 
19
11
  async execute(sock, msg, args) {
@@ -23,26 +15,11 @@ module.exports = {
23
15
 
24
16
  if (parsed.error) {
25
17
  const errors = {
26
- usage: tr(
27
- "Wrong format. Use:\n`!autoschedule daily HH:mm your message`\n`!autoschedule weekly day HH:mm your message`",
28
- "الصيغة غير صحيحة. استخدم:\n`!autoschedule daily HH:mm رسالتك`\n`!autoschedule weekly day HH:mm رسالتك`",
29
- ),
30
- type: tr(
31
- "Unsupported type. Use `daily` or `weekly`.",
32
- "النوع غير مدعوم. استخدم: `daily` أو `weekly`.",
33
- ),
34
- day: tr(
35
- "Invalid day. Use the day's name in English or Arabic, or a number from 0 to 7 (0 and 7 are Sunday).",
36
- "اليوم غير صالح. استخدم اسم اليوم بالعربية أو الإنجليزية، أو رقمًا من 0 إلى 7 (0 و7 للأحد).",
37
- ),
38
- time: tr(
39
- "Invalid time. Use `HH:mm` (for example `09:30`).",
40
- "الوقت غير صالح. استخدم صيغة `HH:mm` (مثال: `09:30`).",
41
- ),
42
- message: tr(
43
- "Write the message you want to schedule after the time.",
44
- "اكتب الرسالة التي تريد جدولتها بعد الوقت.",
45
- ),
18
+ usage: t("bot.schedules.autoschedule.usage"),
19
+ type: t("bot.schedules.autoschedule.type"),
20
+ day: t("bot.schedules.autoschedule.day"),
21
+ time: t("bot.schedules.autoschedule.time"),
22
+ message: t("bot.schedules.autoschedule.message"),
46
23
  };
47
24
  return await sock.sendMessage(creatorJid, {
48
25
  text: errors[parsed.error],
@@ -62,10 +39,7 @@ module.exports = {
62
39
  // الجدولة الأول: جوب مش قادرين نجدوله ما يتخزّنش في الملف أصلاً.
63
40
  if (!scheduleNewJob(sock, newJob)) {
64
41
  return await sock.sendMessage(creatorJid, {
65
- text: tr(
66
- "I couldn't schedule that message. Check the time and try again.",
67
- "تعذّرت جدولة هذه الرسالة. راجع الوقت وحاول مرة أخرى.",
68
- ),
42
+ text: t("bot.schedules.autoschedule.couldNotSchedule"),
69
43
  });
70
44
  }
71
45
 
@@ -3,7 +3,7 @@ const { getGroupSettings, saveGroupSettings } = require("../utils/storage.cjs");
3
3
  const logger = require("../utils/logger.cjs");
4
4
  const normalizeJid = require("../utils/normalizeJid.esm.js").default;
5
5
  const { isAdminInGroupSync, sameUserSync } = require("../utils/permissions.cjs");
6
- const { tr } = require("../utils/i18n.cjs");
6
+ const { t } = require("../utils/i18n.cjs");
7
7
 
8
8
  function sameIdentity(a, b) {
9
9
  return normalizeJid(a) === normalizeJid(b) || sameUserSync(a, b);
@@ -12,14 +12,6 @@ function sameIdentity(a, b) {
12
12
  module.exports = {
13
13
  name: "blacklist",
14
14
  aliases: ["unblacklist", "block", "unblock"], // We keep aliases here for a reason
15
- description: {
16
- en: "Manages the group's user blacklist.",
17
- ar: "يدير القائمة السوداء لأعضاء المجموعة.",
18
- },
19
- usage: {
20
- en: "blacklist [add|remove|list] [@member|number]",
21
- ar: "blacklist [add|remove|list] [@عضو|رقم]",
22
- },
23
15
  chat: "group",
24
16
  userAdminRequired: true,
25
17
 
@@ -51,13 +43,10 @@ module.exports = {
51
43
  if (action === "list") {
52
44
  if (settings.blacklist.length === 0)
53
45
  return await sock.sendMessage(groupId, {
54
- text: tr("The blacklist is empty.", "القائمة السوداء فارغة حاليًا."),
46
+ text: t("bot.moderation.blacklist.theBlacklistIsEmpty"),
55
47
  });
56
48
 
57
- let listReply = tr(
58
- "*🚫 Users blocked from the bot:*\n\n",
59
- "*🚫 قائمة المستخدمين المحظورين من البوت:*\n\n",
60
- );
49
+ let listReply = t("bot.moderation.blacklist.usersBlockedFromTheBot");
61
50
  settings.blacklist.forEach((jid) => {
62
51
  listReply += `» @${jid.split("@")[0]}\n`;
63
52
  });
@@ -74,10 +63,7 @@ module.exports = {
74
63
 
75
64
  if (!targetJid)
76
65
  return await sock.sendMessage(groupId, {
77
- text: tr(
78
- "Mention the member or type their number to do that.",
79
- "لتنفيذ هذا الإجراء، قم بعمل منشن للعضو أو كتابة رقمه.",
80
- ),
66
+ text: t("bot.moderation.blacklist.mentionTheMemberOrType"),
81
67
  });
82
68
 
83
69
  const normalizedTargetJid = normalizeJid(targetJid);
@@ -94,32 +80,29 @@ module.exports = {
94
80
  );
95
81
  if (targetIsAdmin)
96
82
  return await sock.sendMessage(groupId, {
97
- text: tr("Admins can't be blacklisted.", "لا يمكن حظر المشرفين."),
83
+ text: t("bot.moderation.blacklist.adminsCanTBeBlacklisted"),
98
84
  });
99
85
  if (settings.blacklist.some((jid) => sameIdentity(jid, normalizedTargetJid)))
100
86
  return await sock.sendMessage(groupId, {
101
- text: tr(
102
- `@${normalizedTargetJid.split("@")[0]} is already blacklisted.`,
103
- `العضو @${normalizedTargetJid.split("@")[0]} محظور بالفعل.`,
104
- ),
87
+ text: t("bot.moderation.blacklist.isAlreadyBlacklisted", {
88
+ member: normalizedTargetJid.split("@")[0],
89
+ }),
105
90
  mentions: [normalizedTargetJid],
106
91
  });
107
92
 
108
93
  settings.blacklist.push(normalizedTargetJid);
109
94
  await sock.sendMessage(groupId, {
110
- text: tr(
111
- `🚫 @${normalizedTargetJid.split("@")[0]} was added to the blacklist.`,
112
- `🚫 تم إضافة @${normalizedTargetJid.split("@")[0]} إلى القائمة السوداء بنجاح.`,
113
- ),
95
+ text: t("bot.moderation.blacklist.wasAddedToTheBlacklist", {
96
+ member: normalizedTargetJid.split("@")[0],
97
+ }),
114
98
  mentions: [normalizedTargetJid],
115
99
  });
116
100
  } else if (action === "remove") {
117
101
  if (!settings.blacklist.some((jid) => sameIdentity(jid, normalizedTargetJid)))
118
102
  return await sock.sendMessage(groupId, {
119
- text: tr(
120
- `@${normalizedTargetJid.split("@")[0]} isn't on the blacklist.`,
121
- `العضو @${normalizedTargetJid.split("@")[0]} ليس في القائمة السوداء بالفعل.`,
122
- ),
103
+ text: t("bot.moderation.blacklist.isnTOnTheBlacklist", {
104
+ member: normalizedTargetJid.split("@")[0],
105
+ }),
123
106
  mentions: [normalizedTargetJid],
124
107
  });
125
108
 
@@ -127,10 +110,9 @@ module.exports = {
127
110
  (jid) => !sameIdentity(jid, normalizedTargetJid),
128
111
  );
129
112
  await sock.sendMessage(groupId, {
130
- text: tr(
131
- `✅ @${normalizedTargetJid.split("@")[0]} was removed from the blacklist.`,
132
- `✅ تم إزالة @${normalizedTargetJid.split("@")[0]} من القائمة السوداء.`,
133
- ),
113
+ text: t("bot.moderation.blacklist.wasRemovedFromTheBlacklist", {
114
+ member: normalizedTargetJid.split("@")[0],
115
+ }),
134
116
  mentions: [normalizedTargetJid],
135
117
  });
136
118
  }
@@ -2,18 +2,10 @@
2
2
  const logger = require("../utils/logger.cjs");
3
3
  const { isOwnerJidSync } = require("../utils/permissions.cjs");
4
4
  const normalizeJid = require("../utils/normalizeJid.esm.js").default;
5
- const { tr } = require("../utils/i18n.cjs");
5
+ const { t } = require("../utils/i18n.cjs");
6
6
 
7
7
  module.exports = {
8
8
  name: "block",
9
- description: {
10
- en: "Blocks a user from contacting the bot on WhatsApp.",
11
- ar: "يحظر مستخدمًا من التواصل مع البوت على واتساب.",
12
- },
13
- usage: {
14
- en: "block [@member|number] (or reply to their message)",
15
- ar: "block [@عضو|رقم] (أو رد على رسالته)",
16
- },
17
9
  chat: "all",
18
10
 
19
11
  async execute(sock, msg, args) {
@@ -40,10 +32,7 @@ module.exports = {
40
32
  targetJid = `${numberArg.replace(/\D/g, "")}@s.whatsapp.net`;
41
33
  } else {
42
34
  return await sock.sendMessage(remoteJid, {
43
- text: tr(
44
- "Use this in a private chat with no arguments, or mention / reply to / type the number of the user.",
45
- "لكي يعمل هذا الأمر، استخدمه في شات خاص بدون وسائط، أو قم بعمل منشن/رد/كتابة رقم المستخدم.",
46
- ),
35
+ text: t("bot.moderation.block.useThisInAPrivate"),
47
36
  });
48
37
  }
49
38
  }
@@ -53,7 +42,7 @@ module.exports = {
53
42
  // Safety Check
54
43
  if (isOwnerJidSync(normalizedTargetJid)) {
55
44
  return await sock.sendMessage(remoteJid, {
56
- text: tr("You can't block the bot owner.", "لا يمكنك حظر مالك البوت."),
45
+ text: t("bot.moderation.block.youCanTBlockThe"),
57
46
  });
58
47
  }
59
48
 
@@ -71,10 +60,7 @@ module.exports = {
71
60
  } catch (error) {
72
61
  logger.error({ err: error, command: "block" }, "Error in !block command");
73
62
  await sock.sendMessage(remoteJid, {
74
- text: tr(
75
- "Something went wrong while blocking the user.",
76
- "حدث خطأ أثناء محاولة حظر المستخدم.",
77
- ),
63
+ text: t("bot.moderation.block.somethingWentWrongWhileBlocking"),
78
64
  });
79
65
  }
80
66
  },
@@ -10,7 +10,7 @@
10
10
  // FUNCTIONS.
11
11
 
12
12
  const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
13
- const { tr } = require("../utils/i18n.cjs");
13
+ const { t } = require("../utils/i18n.cjs");
14
14
 
15
15
  // ---------------------------------------------------------------------------
16
16
  // whitelist
@@ -62,10 +62,10 @@ const FUNCTIONS = {
62
62
  function factorial(n) {
63
63
  if (!Number.isInteger(n)) {
64
64
  throw new CalcError(
65
- tr("Factorial (!) only works on whole numbers", "يُحسب المضروب (!) للأعداد الصحيحة فقط"),
65
+ t("bot.tools.calc.factorialWholeNumbers"),
66
66
  );
67
67
  }
68
- if (n < 0) throw new CalcError(tr("Negative numbers have no factorial", "لا يُعرَّف المضروب للأعداد السالبة"));
68
+ if (n < 0) throw new CalcError(t("bot.tools.calc.factorialNegative"));
69
69
  if (n > 170) return Infinity; // beyond this a double is Infinity anyway
70
70
  let result = 1;
71
71
  for (let i = 2; i <= n; i++) result *= i;
@@ -135,7 +135,7 @@ function tokenize(text) {
135
135
  }
136
136
  const value = Number(raw);
137
137
  if (!Number.isFinite(value)) {
138
- throw new CalcError(tr(`Invalid number: \`${raw}\``, `رقم غير صالح: \`${raw}\``));
138
+ throw new CalcError(t("bot.tools.calc.invalidNumber", { raw }));
139
139
  }
140
140
  tokens.push({ type: "num", value });
141
141
  continue;
@@ -154,7 +154,7 @@ function tokenize(text) {
154
154
  continue;
155
155
  }
156
156
 
157
- throw new CalcError(tr(`Unknown symbol: \`${char}\``, `رمز غير معروف: \`${char}\``));
157
+ throw new CalcError(t("bot.tools.calc.unknownSymbol", { char }));
158
158
  }
159
159
 
160
160
  return tokens;
@@ -199,7 +199,7 @@ function parse(tokens) {
199
199
  } else if (eat("/")) {
200
200
  const right = parseUnary();
201
201
  if (right === 0) {
202
- throw new CalcError(tr("Division by zero isn't defined 😅", "القسمة على صفر ملهاش لازمة 😅"));
202
+ throw new CalcError(t("bot.tools.calc.divisionByZero"));
203
203
  }
204
204
  left /= right;
205
205
  } else if (peek()?.type === "%" && startsValue(peek(1))) {
@@ -207,7 +207,7 @@ function parse(tokens) {
207
207
  pos++;
208
208
  const right = parseUnary();
209
209
  if (right === 0) {
210
- throw new CalcError(tr("Modulo by zero isn't defined", "باقي القسمة على صفر غير معرّف"));
210
+ throw new CalcError(t("bot.tools.calc.moduloByZero"));
211
211
  }
212
212
  left %= right;
213
213
  } else if (startsValue(peek())) {
@@ -247,11 +247,11 @@ function parse(tokens) {
247
247
 
248
248
  function parsePrimary() {
249
249
  const token = peek();
250
- if (!token) throw new CalcError(tr("The expression is incomplete", "المعادلة ناقصة"));
250
+ if (!token) throw new CalcError(t("bot.tools.calc.emptyExpression"));
251
251
 
252
252
  if (eat("(")) {
253
253
  const value = parseExpression();
254
- expect(")", tr("A bracket was opened and never closed", "قوس مفتوح ومقفلش"));
254
+ expect(")", t("bot.tools.calc.unclosedBracket"));
255
255
  return value;
256
256
  }
257
257
 
@@ -268,28 +268,22 @@ function parse(tokens) {
268
268
  const spec = FUNCTIONS[name];
269
269
  expect(
270
270
  "(",
271
- tr(
272
- `The function \`${name}\` needs brackets, like \`${name}(9)\``,
273
- `الدالة \`${name}\` محتاجة أقواس، زي \`${name}(9)\``,
274
- ),
271
+ t("bot.tools.calc.needsBrackets", { name }),
275
272
  );
276
273
  const args = [];
277
274
  if (peek()?.type !== ")") {
278
275
  args.push(parseExpression());
279
276
  while (eat(",")) args.push(parseExpression());
280
277
  }
281
- expect(")", tr(`The bracket of \`${name}\` is never closed`, `قوس \`${name}\` مقفلش`));
278
+ expect(")", t("bot.tools.calc.unfinishedBracket", { name }));
282
279
  if (spec.arity !== -1 && args.length !== spec.arity) {
283
280
  throw new CalcError(
284
- tr(
285
- `The function \`${name}\` takes ${spec.arity} ${spec.arity === 1 ? "value" : "values"}`,
286
- `الدالة \`${name}\` بتاخد ${spec.arity} ${spec.arity === 1 ? "قيمة" : "قيم"}`,
287
- ),
281
+ t("bot.tools.calc.functionArity", { name, count: spec.arity }),
288
282
  );
289
283
  }
290
284
  if (!args.length) {
291
285
  throw new CalcError(
292
- tr(`The function \`${name}\` got no values`, `الدالة \`${name}\` من غير قيم`),
286
+ t("bot.tools.calc.functionNoValues", { name }),
293
287
  );
294
288
  }
295
289
  return spec.fn(...args);
@@ -297,18 +291,18 @@ function parse(tokens) {
297
291
 
298
292
  if (name in CONSTANTS) return CONSTANTS[name];
299
293
 
300
- throw new CalcError(tr(`I don't know what \`${name}\` is`, `لا أعرف معنى \`${name}\``));
294
+ throw new CalcError(t("bot.tools.calc.unknownName", { name }));
301
295
  }
302
296
 
303
297
  throw new CalcError(
304
- tr(`\`${token.type}\` is in the wrong place`, `مكان غلط للرمز \`${token.type}\``),
298
+ t("bot.tools.calc.wrongTokenPlace", { symbol: token.type }),
305
299
  );
306
300
  }
307
301
 
308
302
  const result = parseExpression();
309
303
  if (pos < tokens.length) {
310
304
  throw new CalcError(
311
- tr("There is something extra at the end of the expression", "في زيادة في آخر المعادلة"),
305
+ t("bot.tools.calc.trailingContent"),
312
306
  );
313
307
  }
314
308
  return result;
@@ -316,14 +310,14 @@ function parse(tokens) {
316
310
 
317
311
  function evaluate(expression) {
318
312
  const normalized = normalize(expression);
319
- if (!normalized) throw new CalcError(tr("Type an expression first", "اكتب معادلة الأول"));
313
+ if (!normalized) throw new CalcError(t("bot.tools.calc.typeExpression"));
320
314
  if (normalized.length > 300) {
321
- throw new CalcError(tr("The expression is too long", "التعبير الرياضي طويل جدًا"));
315
+ throw new CalcError(t("bot.tools.calc.expressionTooLong"));
322
316
  }
323
317
 
324
318
  const value = parse(tokenize(normalized));
325
319
  if (typeof value !== "number" || Number.isNaN(value)) {
326
- throw new CalcError(tr("The result isn't a valid number", "النتيجة ليست عددًا صالحًا"));
320
+ throw new CalcError(t("bot.tools.calc.invalidResult"));
327
321
  }
328
322
  return { normalized, value };
329
323
  }
@@ -348,54 +342,11 @@ function formatNumber(value) {
348
342
  return fraction ? `${grouped}.${fraction}` : grouped;
349
343
  }
350
344
 
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 =
372
- "🧮 *الآلة الحاسبة*\n\n" +
373
- "*الاستخدام:* `!calc <معادلة>`\n" +
374
- "أو رد على رسالة فيها معادلة واكتب `!calc`\n\n" +
375
- "*العمليات:* `+` `-` `*` `/` `%` (باقي القسمة) `^` (أُس) `!` (مضروب)\n" +
376
- "*النِّسب:* `15%` · `20% من 300`\n" +
377
- "*الثوابت:* `pi` · `e` · `tau`\n" +
378
- "*الدوال:* sqrt, cbrt, abs, round, floor, ceil, ln, log, log2, exp,\n" +
379
- "sin, cos, tan, sind, cosd, tand, asin, acos, atan, deg, rad,\n" +
380
- "pow, root, hypot, min, max, avg, sum, fact\n\n" +
381
- "*أمثلة:*\n" +
382
- "`!calc (12 + 8) * 3`\n" +
383
- "`!calc 2^10`\n" +
384
- "`!calc 25% من 480`\n" +
385
- "`!calc sqrt(144) + 5!`\n" +
386
- "`!calc max(3, 9, 4) * pi`";
345
+ const helpText = () => t("bot.tools.calc.help");
387
346
 
388
347
  module.exports = {
389
348
  name: "calc",
390
349
  aliases: ["calculate", "حساب", "احسب", "="],
391
- description: {
392
- en: "Calculator: arithmetic, percentages, powers and math functions.",
393
- ar: "آلة حاسبة: عمليات حسابية، ونِسب مئوية، وأُسس، ودوال رياضية.",
394
- },
395
- usage: {
396
- en: "calc <expression>",
397
- ar: "calc <معادلة>",
398
- },
399
350
  chat: "all",
400
351
 
401
352
  async execute(sock, msg, args) {
@@ -425,15 +376,12 @@ module.exports = {
425
376
  const reason =
426
377
  error instanceof CalcError
427
378
  ? error.message
428
- : tr("I couldn't understand that expression", "تعذّر فهم التعبير الرياضي");
379
+ : t("bot.tools.calc.unclearExpression");
429
380
  return sendBotMessage(
430
381
  sock,
431
382
  chatId,
432
383
  {
433
- text: tr(
434
- `❌ ${reason}\n\nSend \`!calc\` on its own to see examples.`,
435
- `❌ ${reason}\n\nاكتب \`!calc\` وحده لعرض الأمثلة.`,
436
- ),
384
+ text: t("bot.tools.calc.errorWithHint", { reason }),
437
385
  },
438
386
  { replyTo: msg },
439
387
  );
@@ -8,20 +8,12 @@ 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
+ const { t, intlTag } = require("../utils/i18n.cjs");
12
12
  const normalizeJid = require("../utils/normalizeJid.esm.js").default;
13
13
 
14
14
  module.exports = {
15
15
  name: "debt",
16
16
  aliases: ["دين", "owes"],
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
- },
25
17
  chat: "private",
26
18
 
27
19
  async execute(sock, msg, args) {
@@ -52,20 +44,7 @@ module.exports = {
52
44
 
53
45
  default:
54
46
  await sock.sendMessage(remote, {
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\``,
62
- `📊 *نظام الديون (خاص فقط)*\n\n` +
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
- ),
47
+ text: t("bot.tools.debt.help"),
69
48
  });
70
49
  }
71
50
  },
@@ -76,19 +55,16 @@ async function addDebt(sock, msg, args, creditorId, debtorId, chatKey) {
76
55
 
77
56
  if (args.length < 1) {
78
57
  return sock.sendMessage(remote, {
79
- text: tr(
80
- "❌ Usage: `!debt add <amount> [description]`",
81
- "❌ الاستخدام: `!debt add <amount> [description]`",
82
- ),
58
+ text: t("bot.tools.debt.addUsage"),
83
59
  });
84
60
  }
85
61
 
86
62
  const amount = parseFloat(args[0]);
87
- const description = args.slice(1).join(" ") || tr("No description", "بدون وصف");
63
+ const description = args.slice(1).join(" ") || t("bot.tools.debt.noDescription");
88
64
 
89
65
  if (isNaN(amount) || amount <= 0) {
90
66
  return sock.sendMessage(remote, {
91
- text: tr("❌ The amount must be a positive number", "❌ المبلغ يجب أن يكون رقم موجب"),
67
+ text: t("bot.tools.debt.amountInvalid"),
92
68
  });
93
69
  }
94
70
 
@@ -102,25 +78,18 @@ async function addDebt(sock, msg, args, creditorId, debtorId, chatKey) {
102
78
  });
103
79
 
104
80
  await sock.sendMessage(remote, {
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}`,
112
- `✅ *تم إضافة الدين*\n\n` +
113
- `المدين: ${debtorId.split("@")[0]}\n` +
114
- `الدائن: ${creditorId.split("@")[0]}\n` +
115
- `المبلغ: ${amount}\n` +
116
- `الوصف: ${description}\n` +
117
- `رقم السجل: #${debt.id}`,
118
- ),
81
+ text: t("bot.tools.debt.added", {
82
+ debtor: debtorId.split("@")[0],
83
+ creditor: creditorId.split("@")[0],
84
+ amount,
85
+ description,
86
+ id: debt.id,
87
+ }),
119
88
  });
120
89
  } catch (err) {
121
90
  logger.error(err, "[Debt] Add error:");
122
91
  await sock.sendMessage(remote, {
123
- text: tr("❌ Something went wrong while saving the debt", "❌ حدث خطأ أثناء تسجيل الدين"),
92
+ text: t("bot.tools.debt.saveError"),
124
93
  });
125
94
  }
126
95
  }
@@ -132,26 +101,26 @@ async function listDebts(sock, msg, creditorId, debtorId, chatKey) {
132
101
  const debts = storeListDebts(chatKey, { settled: false });
133
102
 
134
103
  if (debts.length === 0) {
135
- return sock.sendMessage(remote, { text: tr("No debts right now ✅", "لا توجد ديون حالياً ✅") });
104
+ return sock.sendMessage(remote, { text: t("bot.tools.debt.listEmpty") });
136
105
  }
137
106
 
138
- let text = tr("📋 *Debts:*\n\n", "📋 *قائمة الديون:*\n\n");
107
+ let text = t("bot.tools.debt.listHeader");
139
108
 
140
109
  debts.forEach((d) => {
141
- const date = new Date(d.created_at).toLocaleDateString(tr("en-GB", "ar-EG"));
110
+ const date = new Date(d.created_at).toLocaleDateString(intlTag());
142
111
  text += `*#${d.id}*\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`;
112
+ text += `${t("bot.tools.debt.debtorLabel")}: ${d.debtor_id.split("@")[0]}\n`;
113
+ text += `${t("bot.tools.debt.creditorLabel")}: ${d.creditor_id.split("@")[0]}\n`;
114
+ text += `${t("bot.tools.debt.amountLabel")}: ${d.amount}\n`;
115
+ text += `${t("bot.tools.debt.descriptionLabel")}: ${d.description}\n`;
116
+ text += `${t("bot.tools.debt.dateLabel")}: ${date}\n\n`;
148
117
  });
149
118
 
150
119
  await sock.sendMessage(remote, { text });
151
120
  } catch (err) {
152
121
  logger.error(err, "[Debt] List error:");
153
122
  await sock.sendMessage(remote, {
154
- text: tr("❌ Something went wrong while listing debts", "❌ حدث خطأ أثناء عرض الديون"),
123
+ text: t("bot.tools.debt.listError"),
155
124
  });
156
125
  }
157
126
  }
@@ -161,14 +130,14 @@ async function deleteDebt(sock, msg, args, creditorId, debtorId, chatKey) {
161
130
 
162
131
  if (args.length < 1) {
163
132
  return sock.sendMessage(remote, {
164
- text: tr("❌ Usage: `!debt del <id>`", "❌ الاستخدام: `!debt del <id>`"),
133
+ text: t("bot.tools.debt.delUsage"),
165
134
  });
166
135
  }
167
136
 
168
137
  const id = parseInt(args[0]);
169
138
  if (isNaN(id)) {
170
139
  return sock.sendMessage(remote, {
171
- text: tr("❌ Invalid record number", "❌ رقم السجل غير صحيح"),
140
+ text: t("bot.tools.debt.invalidRecord"),
172
141
  });
173
142
  }
174
143
 
@@ -177,25 +146,25 @@ async function deleteDebt(sock, msg, args, creditorId, debtorId, chatKey) {
177
146
 
178
147
  if (!debt) {
179
148
  return sock.sendMessage(remote, {
180
- text: tr("❌ That debt wasn't found", "❌ لم يتم العثور على الدين"),
149
+ text: t("bot.tools.debt.notFound"),
181
150
  });
182
151
  }
183
152
 
184
153
  if (debt.group_id !== chatKey) {
185
154
  return sock.sendMessage(remote, {
186
- text: tr("❌ That debt belongs to another chat", "❌ هذا الدين لا يخص هذه المحادثة"),
155
+ text: t("bot.tools.debt.wrongChat"),
187
156
  });
188
157
  }
189
158
 
190
159
  storeDeleteDebt(id);
191
160
 
192
161
  await sock.sendMessage(remote, {
193
- text: tr(`🗑️ Deleted debt #${id}`, `🗑️ تم حذف الدين رقم #${id} بنجاح`),
162
+ text: t("bot.tools.debt.deleted", { id }),
194
163
  });
195
164
  } catch (err) {
196
165
  logger.error(err, "[Debt] Del error:");
197
166
  await sock.sendMessage(remote, {
198
- text: tr("❌ Something went wrong while deleting the debt", "❌ حدث خطأ أثناء حذف الدين"),
167
+ text: t("bot.tools.debt.deleteError"),
199
168
  });
200
169
  }
201
170
  }