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
@@ -10,9 +10,17 @@ const {
10
10
  normalizeFeatureAction,
11
11
  policyFromFeatureAction,
12
12
  } = require("../utils/moderationSummary.cjs");
13
- const { tr } = require("../utils/i18n.cjs");
13
+ const { t, currentLang } = require("../utils/i18n.cjs");
14
14
  const { applyModerationPolicy } = require("../services/moderationPolicy.cjs");
15
15
 
16
+ // The validator's detail is English only. Other languages get a generic line.
17
+ // A catalog value of "{detail}" is rejected: placeholder sets must match.
18
+ function actionNotAllowed(error) {
19
+ const generic = t("bot.moderation.actionNotAllowed");
20
+ const detail = error.errors?.[0]?.message;
21
+ return currentLang() === "en" ? detail || generic : generic;
22
+ }
23
+
16
24
  // الهيكل الافتراضي لإعدادات المراقبة
17
25
  const defaultModSettings = {
18
26
  antiLink: { enabled: false },
@@ -57,30 +65,26 @@ function setFeatureEnabled(settings, key, enabled) {
57
65
  module.exports = {
58
66
  name: "mod",
59
67
  aliases: ["moderation", "settings"],
60
- description: {
61
- en: "Controls the group's moderation settings.",
62
- ar: "يتحكم في إعدادات الإشراف على المجموعة.",
63
- },
64
- usage: {
65
- en: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod action <antiLink|forbiddenWords> <DELETE|WARN|KICK>\nmod action antiSpam <WARN|KICK>\nmod words <add|remove> <word>\nmod words list",
66
- ar: "mod status\nmod <enable|disable> <antiLink|antiSpam|forbiddenWords>\nmod action <antiLink|forbiddenWords> <DELETE|WARN|KICK>\nmod action antiSpam <WARN|KICK>\nmod words <add|remove> <الكلمة>\nmod words list",
67
- },
68
68
  chat: "group", // يعمل في الجروبات فقط
69
69
  botAdminRequired: false, // لا يتطلب أن يكون البوت مشرفًا لتغيير الإعدادات
70
70
 
71
- async execute(sock, msg, args) {
71
+ async execute(sock, msg, args, _body, _handed, ctx) {
72
72
  const groupId = msg.key.remoteJid;
73
73
  const senderIds = senderCandidates(msg, sock);
74
74
 
75
- // التحقق من صلاحيات المشرف (LID-aware via central module). Owners can
76
- // also drive moderation settings.
77
- const groupMetadata = await resolveGroupMetadata(sock, groupId);
75
+ // The dispatcher already read a fresh roster. A direct call reads with
76
+ // `{ fresh: true }` so a stale admin flag cannot open this command.
77
+ // Owners still pass below. Forbidden-word protection keeps last-known data.
78
+ const groupMetadata =
79
+ ctx && Object.prototype.hasOwnProperty.call(ctx, "authGroupMetadata")
80
+ ? ctx.authGroupMetadata
81
+ : await resolveGroupMetadata(sock, groupId, { fresh: true });
78
82
  const senderIsAdmin = senderIds.some((id) => isAdminInGroupSync(groupMetadata, id));
79
83
  const isOwner = msg.key.fromMe || senderIds.some(isOwnerJidSync);
80
84
  if (!senderIsAdmin && !isOwner) {
81
85
  return sock.sendMessage(
82
86
  groupId,
83
- { text: tr("🚫 This command is for admins only.", "🚫 هذا الأمر للمشرفين فقط.") },
87
+ { text: t("bot.moderation.mod.thisCommandIsForAdmins") },
84
88
  { quoted: msg },
85
89
  );
86
90
  }
@@ -98,10 +102,7 @@ module.exports = {
98
102
  return sock.sendMessage(
99
103
  groupId,
100
104
  {
101
- text: tr(
102
- `⚠️ There is no feature called "${args[1] || ""}".`,
103
- `⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
104
- ),
105
+ text: t("bot.moderation.mod.thereIsNoFeatureCalled", { featureName: args[1] || "" }),
105
106
  },
106
107
  { quoted: msg },
107
108
  );
@@ -110,7 +111,7 @@ module.exports = {
110
111
  saveGroupSettings(groupId, settings);
111
112
  await sock.sendMessage(
112
113
  groupId,
113
- { text: tr(`✅ *${feature}* is on.`, `✅ تم تفعيل ميزة *${feature}*.`) },
114
+ { text: t("bot.moderation.mod.isOn", { feature }) },
114
115
  { quoted: msg },
115
116
  );
116
117
  break;
@@ -120,10 +121,7 @@ module.exports = {
120
121
  return sock.sendMessage(
121
122
  groupId,
122
123
  {
123
- text: tr(
124
- `⚠️ There is no feature called "${args[1] || ""}".`,
125
- `⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
126
- ),
124
+ text: t("bot.moderation.mod.thereIsNoFeatureCalled", { featureName: args[1] || "" }),
127
125
  },
128
126
  { quoted: msg },
129
127
  );
@@ -132,7 +130,7 @@ module.exports = {
132
130
  saveGroupSettings(groupId, settings);
133
131
  await sock.sendMessage(
134
132
  groupId,
135
- { text: tr(`❌ *${feature}* is off.`, `❌ تم تعطيل ميزة *${feature}*.`) },
133
+ { text: t("bot.moderation.mod.isOff", { feature }) },
136
134
  { quoted: msg },
137
135
  );
138
136
  break;
@@ -142,10 +140,7 @@ module.exports = {
142
140
  return sock.sendMessage(
143
141
  groupId,
144
142
  {
145
- text: tr(
146
- `⚠️ There is no feature called "${args[1] || ""}".`,
147
- `⚠️ الميزة "${args[1] || ""}" غير موجودة.`,
148
- ),
143
+ text: t("bot.moderation.mod.thereIsNoFeatureCalled", { featureName: args[1] || "" }),
149
144
  },
150
145
  { quoted: msg },
151
146
  );
@@ -156,14 +151,9 @@ module.exports = {
156
151
  return sock.sendMessage(
157
152
  groupId,
158
153
  {
159
- text: tr(
160
- allowDelete
161
- ? "Invalid action. Available: `DELETE`, `WARN`, `KICK`"
162
- : "Invalid action. Available: `WARN`, `KICK`",
163
- allowDelete
164
- ? "الإجراء غير صالح. الإجراءات المتاحة: `DELETE`, `WARN`, `KICK`"
165
- : "الإجراء غير صالح. الإجراءات المتاحة: `WARN`, `KICK`",
166
- ),
154
+ text: allowDelete
155
+ ? t("bot.moderation.mod.invalidActionWithDelete")
156
+ : t("bot.moderation.mod.invalidActionWithoutDelete"),
167
157
  },
168
158
  { quoted: msg },
169
159
  );
@@ -176,24 +166,21 @@ module.exports = {
176
166
  return sock.sendMessage(
177
167
  groupId,
178
168
  {
179
- text: tr(
180
- error.errors?.[0]?.message || "That action is not allowed.",
181
- "هذا الإجراء غير مسموح.",
182
- ),
169
+ text: actionNotAllowed(error),
183
170
  },
184
171
  { quoted: msg },
185
172
  );
186
173
  }
187
174
  await sock.sendMessage(
188
175
  groupId,
189
- { text: tr(`✅ *${feature}* action is now ${action}.`, `✅ تم تعيين إجراء *${feature}* إلى ${action}.`) },
176
+ { text: t("bot.moderation.mod.actionIsNow", { feature, action }) },
190
177
  { quoted: msg },
191
178
  );
192
179
  break;
193
180
  }
194
181
 
195
182
  case "status": {
196
- let statusText = tr("📊 *Moderation settings* 📊\n\n", "📊 *حالة إعدادات المراقبة* 📊\n\n");
183
+ let statusText = t("bot.moderation.mod.moderationSettings");
197
184
  const actionOf = {
198
185
  antiLink: featureActionOf(settings, "antilink"),
199
186
  antiSpam: featureActionOf(settings, "antispam"),
@@ -201,14 +188,11 @@ module.exports = {
201
188
  };
202
189
  for (const key of Object.values(FEATURE_KEYS)) {
203
190
  const status = featureEnabled(settings, key)
204
- ? tr("✅ on", "✅ مفعل")
205
- : tr("❌ off", "❌ معطل");
191
+ ? t("bot.moderation.mod.on")
192
+ : t("bot.moderation.mod.off");
206
193
  statusText += `› *${key}*: ${status} · ${actionOf[key]}\n`;
207
194
  }
208
- statusText += tr(
209
- `\n- To see the forbidden words, type: \`!mod words list\``,
210
- `\n- لعرض قائمة الكلمات الممنوعة، اكتب: \`!mod words list\``,
211
- );
195
+ statusText += t("bot.moderation.mod.toSeeTheForbiddenWords");
212
196
  await sock.sendMessage(groupId, { text: statusText }, { quoted: msg });
213
197
  break;
214
198
  }
@@ -220,34 +204,31 @@ module.exports = {
220
204
  if (wordAction === "add") {
221
205
  if (!word)
222
206
  return sock.sendMessage(groupId, {
223
- text: tr("Write the word you want to add.", "الرجاء كتابة الكلمة التي تريد إضافتها."),
207
+ text: t("bot.moderation.mod.wordToAddRequired"),
224
208
  });
225
209
  if (!modSettings.forbiddenWords.list.includes(word)) {
226
210
  modSettings.forbiddenWords.list.push(word.slice(0, 100));
227
211
  }
228
212
  saveGroupSettings(groupId, settings);
229
213
  await sock.sendMessage(groupId, {
230
- text: tr(
231
- `✅ Added "${word}" to the forbidden words.`,
232
- `✅ تم إضافة "${word}" إلى قائمة الكلمات الممنوعة.`,
233
- ),
214
+ text: t("bot.moderation.mod.addedToTheForbiddenWords", { word }),
234
215
  });
235
216
  } else if (wordAction === "remove") {
236
217
  if (!word)
237
218
  return sock.sendMessage(groupId, {
238
- text: tr("Write the word you want to remove.", "الرجاء كتابة الكلمة التي تريد إزالتها."),
219
+ text: t("bot.moderation.mod.wordToRemoveRequired"),
239
220
  });
240
221
  modSettings.forbiddenWords.list = modSettings.forbiddenWords.list.filter(
241
222
  (w) => w !== word,
242
223
  );
243
224
  saveGroupSettings(groupId, settings);
244
225
  await sock.sendMessage(groupId, {
245
- text: tr(`🗑️ Removed "${word}" from the list.`, `🗑️ تم إزالة "${word}" من القائمة.`),
226
+ text: t("bot.moderation.mod.removedFromTheList", { word }),
246
227
  });
247
228
  } else if (wordAction === "list") {
248
- let listText = tr("🚫 *Forbidden words* 🚫\n\n", "🚫 *قائمة الكلمات الممنوعة* 🚫\n\n");
229
+ let listText = t("bot.moderation.mod.forbiddenWords");
249
230
  if (modSettings.forbiddenWords.list.length === 0) {
250
- listText += tr("The list is empty.", "القائمة فارغة حاليًا.");
231
+ listText += t("bot.moderation.mod.theListIsEmpty");
251
232
  } else {
252
233
  modSettings.forbiddenWords.list.forEach((w, i) => {
253
234
  listText += `${i + 1}. ${w}\n`;
@@ -256,34 +237,14 @@ module.exports = {
256
237
  await sock.sendMessage(groupId, { text: listText });
257
238
  } else {
258
239
  await sock.sendMessage(groupId, {
259
- text: tr(
260
- "Wrong usage. Available: `add`, `remove`, `list`",
261
- "استخدام خاطئ. الأوامر المتاحة: `add`, `remove`, `list`",
262
- ),
240
+ text: t("bot.moderation.mod.wrongUsageAvailableAddRemove"),
263
241
  });
264
242
  }
265
243
  break;
266
244
  }
267
245
 
268
246
  default: {
269
- const helpText = tr(
270
- "🤖 *Moderation commands*\n\n" +
271
- "• `!mod enable <feature>`\nTurn a feature on (antilink, antispam, forbiddenwords)\n\n" +
272
- "• `!mod disable <feature>`\nTurn a feature off.\n\n" +
273
- "• `!mod action <feature> <DELETE|WARN|KICK>`\nSet the feature action (antiSpam: WARN|KICK).\n\n" +
274
- "• `!mod status`\nShow which features are on.\n\n" +
275
- "• `!mod words add <word>`\nAdd a forbidden word.\n\n" +
276
- "• `!mod words remove <word>`\nRemove a forbidden word.\n\n" +
277
- "• `!mod words list`\nList the forbidden words.",
278
- "🤖 *أوامر التحكم في المراقبة*\n\n" +
279
- "• `!mod enable <feature>`\nلتفعيل ميزة (antilink, antispam, forbiddenwords)\n\n" +
280
- "• `!mod disable <feature>`\nلتعطيل ميزة.\n\n" +
281
- "• `!mod action <feature> <DELETE|WARN|KICK>`\nتعيين إجراء الميزة (antiSpam: WARN|KICK).\n\n" +
282
- "• `!mod status`\nلعرض حالة الميزات الحالية.\n\n" +
283
- "• `!mod words add <word>`\nلإضافة كلمة ممنوعة.\n\n" +
284
- "• `!mod words remove <word>`\nلإزالة كلمة ممنوعة.\n\n" +
285
- "• `!mod words list`\nلعرض قائمة الكلمات الممنوعة.",
286
- );
247
+ const helpText = t("bot.moderation.mod.help");
287
248
  await sock.sendMessage(groupId, { text: helpText }, { quoted: msg });
288
249
  break;
289
250
  }
@@ -1,17 +1,9 @@
1
1
  // file: /commands/notes.js
2
2
  const { getAllNotes } = require("../utils/storage.cjs");
3
- const { tr } = require("../utils/i18n.cjs");
3
+ const { t } = require("../utils/i18n.cjs");
4
4
 
5
5
  module.exports = {
6
6
  name: "notes",
7
- description: {
8
- en: "Lists all saved note keywords for the group.",
9
- ar: "يعرض الكلمات المفتاحية لكل الملاحظات المحفوظة في المجموعة.",
10
- },
11
- usage: {
12
- en: "notes",
13
- ar: "notes",
14
- },
15
7
  chat: "all",
16
8
 
17
9
  async execute(sock, msg) {
@@ -22,16 +14,13 @@ module.exports = {
22
14
 
23
15
  if (keywords.length === 0) {
24
16
  return await sock.sendMessage(groupId, {
25
- text: tr("This group has no saved notes.", "لا توجد ملاحظات محفوظة في هذه المجموعة."),
17
+ text: t("bot.core.notes.empty"),
26
18
  });
27
19
  }
28
20
 
29
- let reply = tr("*🔑 Saved note keywords:*\n\n", "*🔑 الكلمات المفتاحية للملاحظات المحفوظة:*\n\n");
21
+ let reply = t("bot.core.notes.heading");
30
22
  reply += keywords.map((kw) => `\`#${kw}\``).join("\n");
31
- reply += tr(
32
- "\n\nTo get a note, use: `!note #keyword`",
33
- "\n\nللحصول على ملاحظة، استخدم: `!note #keyword`",
34
- );
23
+ reply += t("bot.core.notes.footer");
35
24
 
36
25
  await sock.sendMessage(groupId, { text: reply });
37
26
  },
@@ -1,4 +1,4 @@
1
- const { tr } = require("../utils/i18n.cjs");
1
+ const { t } = require("../utils/i18n.cjs");
2
2
  const { isolate } = require("../utils/bidi.cjs");
3
3
  const { createStatus } = require("../utils/statusMessage.cjs");
4
4
  const {
@@ -46,14 +46,6 @@ function requirePack(who, name) {
46
46
  module.exports = {
47
47
  name: "pack",
48
48
  aliases: ["حزمة"],
49
- description: {
50
- en: "Create, fill and manage your sticker packs.",
51
- ar: "ينشئ حزم الملصقات ويديرها ويضيف إليها.",
52
- },
53
- usage: {
54
- en: "pack <name> (reply to media to add)\npack <name> (show without a reply)\npack create <name>\npack add <name>\npack remove <name>\npack rename <old> | <new>\npack delete <name>\npack show <name>",
55
- ar: "pack <الاسم> (رد على وسائط للإضافة)\npack <الاسم> (عرض بلا رد)\npack إنشاء <الاسم>\npack إضافة <الاسم>\npack إزالة <الاسم>\npack تسمية <القديم> | <الجديد>\npack حذف <الاسم>\npack عرض <الاسم>",
56
- },
57
49
  keywords,
58
50
  chat: "all",
59
51
  async execute(sock, msg, args = []) {
@@ -61,7 +53,7 @@ module.exports = {
61
53
  const who = await ownerModule.forMessage(msg, sock);
62
54
  if (!who.key)
63
55
  return sock.sendMessage(jid, {
64
- text: tr("I couldn't identify the sender.", "تعذّر تحديد هوية المرسل."),
56
+ text: t("bot.stickers.pack.senderUnknown"),
65
57
  });
66
58
  const parsed = parse(args);
67
59
  let status;
@@ -78,33 +70,26 @@ module.exports = {
78
70
  }
79
71
  }
80
72
  if (!oldName || !newName) {
81
- line = tr(
82
- `Use ${commandHint("pack", "rename <old> | <new>")}.`,
83
- `استخدم ${commandHint("pack", "تسمية <القديم> | <الجديد>")}.`,
84
- );
73
+ line = t("bot.stickers.pack.renameUsage", {
74
+ hint: commandHint("pack", t("bot.stickers.hint.rename")),
75
+ });
85
76
  } else {
86
77
  const pack = requirePack(who, oldName);
87
78
  const renamed = library.updatePack(who, pack.id, newName);
88
- line = tr(
89
- `Renamed pack to ${isolate(renamed.name)}.`,
90
- `أُعيدت تسمية الحزمة إلى ${isolate(renamed.name)}.`,
91
- );
79
+ line = t("bot.stickers.pack.renamed", { name: isolate(renamed.name) });
92
80
  }
93
81
  } else if (!parsed.name) {
94
- line = tr(
95
- `Use ${commandHint("pack", "<name>")} while replying to media, or ${commandHint("pack", "create <name>")}.`,
96
- `استخدم ${commandHint("pack", "<الاسم>")} عند الرد على وسائط، أو ${commandHint("pack", "إنشاء <الاسم>")}.`,
97
- );
82
+ line = t("bot.stickers.pack.needName", {
83
+ add: commandHint("pack", t("bot.stickers.hint.name")),
84
+ create: commandHint("pack", t("bot.stickers.hint.create")),
85
+ });
98
86
  } else if (parsed.action === "create") {
99
87
  const pack = library.createPack(who, parsed.name);
100
- line = tr(`Created pack ${isolate(pack.name)}.`, `أُنشئت الحزمة ${isolate(pack.name)}.`);
88
+ line = t("bot.stickers.pack.created", { name: isolate(pack.name) });
101
89
  } else if (parsed.action === "delete") {
102
90
  const pack = requirePack(who, parsed.name);
103
91
  library.deletePack(who, pack.id);
104
- line = tr(
105
- `Deleted pack ${isolate(pack.name)}. Its stickers remain in your library.`,
106
- `حُذفت الحزمة ${isolate(pack.name)}. بقيت ملصقاتها في مكتبتك.`,
107
- );
92
+ line = t("bot.stickers.pack.deleted", { name: isolate(pack.name) });
108
93
  } else if (parsed.action === "remove") {
109
94
  const pack = requirePack(who, parsed.name);
110
95
  const target = targetOf(msg, { quotedOnly: true });
@@ -113,18 +98,19 @@ module.exports = {
113
98
  const sticker = library.findStickerByContent(who, buffer);
114
99
  const removed = library.removeFromPack(who, pack.id, [sticker.id]);
115
100
  if (!removed.affected) throw new StickerError("NOT_FOUND");
116
- line = tr(
117
- `Removed the sticker from ${isolate(pack.name)}. It remains in your library.`,
118
- `أُزيل الملصق من ${isolate(pack.name)}. بقي في مكتبتك.`,
119
- );
101
+ line = t("bot.stickers.pack.removed", { name: isolate(pack.name) });
120
102
  } else {
121
103
  const target = targetOf(msg, { quotedOnly: true });
122
104
  if (parsed.action === "show" || (parsed.action === "auto" && !target)) {
123
105
  const pack = requirePack(who, parsed.name);
124
- line = tr(
125
- `${isolate(pack.name)} — ${countLabel(pack.count)}. Use ${commandHint("stickers", `pack ${pack.name}`)} to see them.`,
126
- `${isolate(pack.name)} — ${countLabel(pack.count)}. استخدم ${commandHint("stickers", `حزمة ${pack.name}`)} لعرضها.`,
127
- );
106
+ line = t("bot.stickers.pack.show", {
107
+ name: isolate(pack.name),
108
+ count: countLabel(pack.count),
109
+ hint: commandHint(
110
+ "stickers",
111
+ `${t("bot.stickers.hint.showWord")} ${pack.name}`,
112
+ ),
113
+ });
128
114
  } else {
129
115
  if (!target) throw new StickerError("NO_MEDIA");
130
116
  let pack = library.findPackByName(who, parsed.name);
@@ -132,12 +118,9 @@ module.exports = {
132
118
  if (createdPack) pack = library.createPack(who, parsed.name);
133
119
  try {
134
120
  const buffer = await downloadTarget(target);
135
- status = await createStatus(
136
- sock,
137
- jid,
138
- tr("🎨 Saving sticker...", "🎨 جارٍ حفظ الملصق..."),
139
- { replyTo: msg },
140
- );
121
+ status = await createStatus(sock, jid, t("bot.stickers.pack.saving"), {
122
+ replyTo: msg,
123
+ });
141
124
  const { promise } = studio.createFromBuffer({
142
125
  owner: who,
143
126
  buffer,
@@ -147,14 +130,8 @@ module.exports = {
147
130
  });
148
131
  const result = await promise;
149
132
  line = result.created
150
- ? tr(
151
- `Saved sticker to ${isolate(pack.name)}.`,
152
- `حُفظ الملصق في ${isolate(pack.name)}.`,
153
- )
154
- : tr(
155
- `Already in your library; added to ${isolate(pack.name)}.`,
156
- `الملصق موجود في مكتبتك بالفعل؛ أُضيف إلى ${isolate(pack.name)}.`,
157
- );
133
+ ? t("bot.stickers.pack.saved", { name: isolate(pack.name) })
134
+ : t("bot.stickers.pack.duplicate", { name: isolate(pack.name) });
158
135
  } catch (error) {
159
136
  if (createdPack) {
160
137
  try {
@@ -1,4 +1,4 @@
1
- const { tr } = require("../utils/i18n.cjs");
1
+ const { t } = require("../utils/i18n.cjs");
2
2
  const { isolate } = require("../utils/bidi.cjs");
3
3
  const ownerModule = require("../stickers/owner.cjs");
4
4
  const library = require("../stickers/library.cjs");
@@ -7,41 +7,31 @@ const { commandHint, countLabel, errorText } = require("../utils/stickerBot.cjs"
7
7
  module.exports = {
8
8
  name: "packs",
9
9
  aliases: ["حزم"],
10
- description: {
11
- en: "List your sticker packs and library total.",
12
- ar: "يعرض حزم ملصقاتك وإجمالي المكتبة.",
13
- },
14
- usage: { en: "packs", ar: "packs" },
15
10
  chat: "all",
16
11
  async execute(sock, msg) {
17
12
  const jid = msg.key.remoteJid;
18
13
  const who = await ownerModule.forMessage(msg, sock);
19
14
  if (!who.key)
20
15
  return sock.sendMessage(jid, {
21
- text: tr("I couldn't identify the sender.", "تعذّر تحديد هوية المرسل."),
16
+ text: t("bot.stickers.packs.senderUnknown"),
22
17
  });
23
18
  try {
24
19
  const packs = library.listPacks(who);
25
20
  const total = library.listStickers(who, { limit: 1 }).total;
26
21
  if (!packs.length)
27
22
  return sock.sendMessage(jid, {
28
- text: tr(
29
- `No packs yet. Reply to media with ${commandHint("pack", "<name>")} to start one. Library: ${countLabel(total)}.`,
30
- `لا توجد حزم بعد. رد على وسائط بالأمر ${commandHint("pack", "<الاسم>")} لإنشاء حزمة. المكتبة: ${countLabel(total)}.`,
31
- ),
23
+ text: t("bot.stickers.packs.empty", {
24
+ hint: commandHint("pack", t("bot.stickers.hint.name")),
25
+ count: countLabel(total),
26
+ }),
32
27
  });
33
28
  const lines = packs
34
29
  .slice(0, 30)
35
30
  .map((pack) => `${isolate(pack.name)} — ${countLabel(pack.count)}`);
36
31
  if (packs.length > 30)
37
- lines.push(
38
- tr(
39
- `and ${countLabel(packs.length - 30, "pack")} more`,
40
- `و${countLabel(packs.length - 30, "pack")} أخرى`,
41
- ),
42
- );
32
+ lines.push(t("bot.stickers.packs.more", { count: countLabel(packs.length - 30, "pack") }));
43
33
  await sock.sendMessage(jid, {
44
- text: `${tr("Your packs · Library:", "حزمك · المكتبة:")} ${countLabel(total)}\n${lines.join("\n")}`,
34
+ text: `${t("bot.stickers.packs.header")} ${countLabel(total)}\n${lines.join("\n")}`,
45
35
  });
46
36
  } catch (error) {
47
37
  await sock.sendMessage(jid, { text: errorText(error) });