levix-bot 4.1.0 → 4.2.1

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 (82) hide show
  1. package/package.json +1 -1
  2. package/public/dashboard/assets/{index-DngAcp-o.js → index-4AuqfnH5.js} +80 -80
  3. package/public/dashboard/index.html +1 -1
  4. package/scheduler.cjs +6 -1
  5. package/src/commands/autoschedule.cjs +40 -10
  6. package/src/commands/blacklist.cjs +35 -10
  7. package/src/commands/block.cjs +18 -5
  8. package/src/commands/calc.cjs +90 -24
  9. package/src/commands/debt.cjs +59 -33
  10. package/src/commands/deleteschedule.cjs +21 -5
  11. package/src/commands/digit.cjs +34 -8
  12. package/src/commands/gemini.cjs +217 -87
  13. package/src/commands/group/add.cjs +46 -13
  14. package/src/commands/group/all.cjs +15 -5
  15. package/src/commands/group/antiSpam.cjs +11 -4
  16. package/src/commands/group/antilink.cjs +36 -18
  17. package/src/commands/group/approveall.cjs +22 -7
  18. package/src/commands/group/clearwarns.cjs +18 -5
  19. package/src/commands/group/deletenote.cjs +18 -5
  20. package/src/commands/group/demote.cjs +25 -7
  21. package/src/commands/group/kick.cjs +28 -12
  22. package/src/commands/group/media.cjs +31 -12
  23. package/src/commands/group/members.cjs +21 -6
  24. package/src/commands/group/note.cjs +14 -4
  25. package/src/commands/group/promote.cjs +22 -6
  26. package/src/commands/group/removeall.cjs +13 -3
  27. package/src/commands/group/rules.cjs +20 -5
  28. package/src/commands/group/save.cjs +20 -5
  29. package/src/commands/group/setname.cjs +19 -6
  30. package/src/commands/group/setpp.cjs +21 -6
  31. package/src/commands/group/setrules.cjs +17 -5
  32. package/src/commands/group/setwarn.cjs +23 -7
  33. package/src/commands/group/tagadmins.cjs +16 -6
  34. package/src/commands/group/warn.cjs +35 -15
  35. package/src/commands/group/warns.cjs +33 -13
  36. package/src/commands/group/welcome.cjs +34 -16
  37. package/src/commands/group.cjs +96 -70
  38. package/src/commands/help.cjs +270 -135
  39. package/src/commands/lang.cjs +46 -13
  40. package/src/commands/listschedules.cjs +28 -11
  41. package/src/commands/loop.cjs +43 -9
  42. package/src/commands/memory.cjs +90 -30
  43. package/src/commands/mod.cjs +69 -27
  44. package/src/commands/notes.cjs +15 -5
  45. package/src/commands/perm.cjs +52 -20
  46. package/src/commands/ping.cjs +15 -3
  47. package/src/commands/poll.cjs +40 -9
  48. package/src/commands/prayer.cjs +28 -12
  49. package/src/commands/qr.cjs +20 -5
  50. package/src/commands/rand.cjs +54 -12
  51. package/src/commands/restart.cjs +13 -3
  52. package/src/commands/schedule.cjs +32 -9
  53. package/src/commands/score.cjs +26 -10
  54. package/src/commands/setprefix.cjs +27 -5
  55. package/src/commands/shortlink.cjs +36 -10
  56. package/src/commands/shutdown.cjs +13 -3
  57. package/src/commands/status.cjs +32 -11
  58. package/src/commands/sticker.cjs +34 -7
  59. package/src/commands/stt.cjs +163 -108
  60. package/src/commands/todo.cjs +31 -9
  61. package/src/commands/tts.cjs +25 -7
  62. package/src/commands/unblock.cjs +17 -4
  63. package/src/commands/weather.cjs +55 -17
  64. package/src/config/settings.cjs +1 -1
  65. package/src/handlers/command.handler.js +50 -10
  66. package/src/handlers/group.handler.js +5 -1
  67. package/src/handlers/message.handler.js +9 -0
  68. package/src/middleware/antispam.middleware.js +9 -2
  69. package/src/services/aiAgent.cjs +40 -39
  70. package/src/services/aiProviders.cjs +46 -19
  71. package/src/services/aiRouter.cjs +2 -1
  72. package/src/services/aiTools.cjs +2 -1
  73. package/src/utils/commandDocs.cjs +58 -0
  74. package/src/utils/geminiMedia.cjs +168 -0
  75. package/src/utils/i18n.cjs +113 -0
  76. package/src/utils/markdownParser.cjs +4 -2
  77. package/src/utils/memory.cjs +2 -1
  78. package/src/utils/permissionLevel.cjs +34 -6
  79. package/src/utils/providerUrl.cjs +29 -2
  80. package/src/utils/sendBotMessage.cjs +7 -3
  81. package/src/utils/sendBotMessage.esm.js +13 -3
  82. package/src/utils/statusMessage.cjs +11 -4
@@ -1,10 +1,15 @@
1
1
  // Speech-to-Text Command using FREE Gemini API
2
2
  const { GoogleGenAI } = require("@google/genai");
3
3
  const { downloadContentFromMessage } = require("@whiskeysockets/baileys");
4
- const fs = require("fs").promises;
5
- const path = require("path");
6
4
  const logger = require("../utils/logger.cjs");
7
5
  const { createStatus } = require("../utils/statusMessage.cjs");
6
+ const { unwrapMessage } = require("../utils/messageContent.cjs");
7
+ const {
8
+ INLINE_MEDIA_LIMIT,
9
+ baseMimeType,
10
+ downloadMedia,
11
+ uploadToGemini,
12
+ } = require("../utils/geminiMedia.cjs");
8
13
 
9
14
  const settings = require("../config/settings.cjs");
10
15
  const {
@@ -12,6 +17,7 @@ const {
12
17
  assertProviderRequestUrl,
13
18
  safeProviderFetch,
14
19
  } = require("../utils/providerUrl.cjs");
20
+ const { tr } = require("../utils/i18n.cjs");
15
21
 
16
22
  // Built on first use from whatever key is in force, and
17
23
  // rebuilt if that key changes — the operator can paste one without a restart.
@@ -58,9 +64,54 @@ function resolveSttProvider() {
58
64
  : "gemini";
59
65
  }
60
66
 
67
+ const TRANSCRIBE_PROMPT =
68
+ "Please transcribe this audio message accurately. Return ONLY the transcription text without any additional commentary, explanations, or formatting. Just the raw transcribed text.";
69
+
70
+ // A voice note is a few hundred KB, so it rides inline in the request: one
71
+ // round trip, instead of an upload, a finalize and then the request. Past
72
+ // INLINE_MEDIA_LIMIT (Gemini caps a whole inline request at 20 MB) it goes
73
+ // through the Files API instead.
74
+
75
+ async function transcribeWithGemini(audioBuffer, mimetype) {
76
+ const gemini = geminiStt();
77
+ if (!gemini)
78
+ throw new Error(
79
+ tr("No Gemini key is set in the settings", "مفتاح Gemini غير مضبوط في الإعدادات"),
80
+ );
81
+ await assertProviderRequestUrl(settings.get("gemini_base_url"), {
82
+ allowLoopback: true,
83
+ });
84
+
85
+ // WhatsApp labels voice notes `audio/ogg; codecs=opus`; Gemini's type is
86
+ // `audio/ogg`, and the codec parameter is not part of it.
87
+ const mimeType = baseMimeType(mimetype, "audio");
88
+ let audioPart;
89
+ if (audioBuffer.length <= INLINE_MEDIA_LIMIT) {
90
+ audioPart = { inlineData: { mimeType, data: audioBuffer.toString("base64") } };
91
+ } else {
92
+ const file = await uploadToGemini(gemini.genAI, audioBuffer, mimeType, {
93
+ displayName: `audio-${Date.now()}`,
94
+ });
95
+ audioPart = { fileData: { mimeType: file.mimeType || mimeType, fileUri: file.uri } };
96
+ }
97
+
98
+ const response = await gemini.genAI.models.generateContent({
99
+ model: sttModel(),
100
+ contents: [{ role: "user", parts: [audioPart, { text: TRANSCRIBE_PROMPT }] }],
101
+ });
102
+ return (response.text ?? "").trim();
103
+ }
104
+
61
105
  async function transcribeWithOpenAi(audioBuffer, mimetype) {
62
106
  const apiKey = settings.get("openai_api_key");
63
- if (!apiKey) throw new Error("مفتاح OpenAI / Groq غير مضبوط في الإعدادات");
107
+ if (!apiKey) {
108
+ throw new Error(
109
+ tr(
110
+ "No OpenAI / Groq key is set in the settings",
111
+ "مفتاح OpenAI / Groq غير مضبوط في الإعدادات",
112
+ ),
113
+ );
114
+ }
64
115
  const baseUrl = assertProviderBaseUrl(
65
116
  settings.get("openai_base_url") || "https://api.openai.com/v1",
66
117
  { allowLoopback: true },
@@ -68,10 +119,10 @@ async function transcribeWithOpenAi(audioBuffer, mimetype) {
68
119
  const model = settings.get("openai_stt_model") || "whisper-large-v3";
69
120
 
70
121
  const formData = new FormData();
71
- const mime = mimetype || "audio/ogg";
122
+ const mime = baseMimeType(mimetype, "audio");
72
123
  const ext = mime.includes("mp4")
73
124
  ? "m4a"
74
- : mime.includes("mp3")
125
+ : mime.includes("mp3") || mime.includes("mpeg")
75
126
  ? "mp3"
76
127
  : mime.includes("wav")
77
128
  ? "wav"
@@ -83,14 +134,18 @@ async function transcribeWithOpenAi(audioBuffer, mimetype) {
83
134
  const controller = new AbortController();
84
135
  const timer = setTimeout(() => controller.abort(), 60000);
85
136
  try {
86
- const res = await safeProviderFetch(`${baseUrl}/audio/transcriptions`, {
87
- method: "POST",
88
- headers: {
89
- Authorization: `Bearer ${apiKey}`,
137
+ const res = await safeProviderFetch(
138
+ `${baseUrl}/audio/transcriptions`,
139
+ {
140
+ method: "POST",
141
+ headers: {
142
+ Authorization: `Bearer ${apiKey}`,
143
+ },
144
+ body: formData,
145
+ signal: controller.signal,
90
146
  },
91
- body: formData,
92
- signal: controller.signal,
93
- }, { allowLoopback: true });
147
+ { allowLoopback: true },
148
+ );
94
149
  if (!res.ok) {
95
150
  const err = await res.text().catch(() => "");
96
151
  throw new Error(`STT API (${res.status}): ${err}`);
@@ -102,140 +157,140 @@ async function transcribeWithOpenAi(audioBuffer, mimetype) {
102
157
  }
103
158
  }
104
159
 
160
+ /** Audio bytes -> text, on whichever engine the settings pick. */
161
+ async function transcribe(audioBuffer, mimetype) {
162
+ const provider = resolveSttProvider();
163
+ const hasOpenAi = !!settings.get("openai_api_key");
164
+ if (provider === "openai" && hasOpenAi) {
165
+ logger.info("[STT] Transcribing via OpenAI/Groq Whisper API");
166
+ return transcribeWithOpenAi(audioBuffer, mimetype);
167
+ }
168
+ if (geminiStt()) {
169
+ logger.info("[STT] Transcribing via Gemini");
170
+ return transcribeWithGemini(audioBuffer, mimetype);
171
+ }
172
+ if (hasOpenAi) {
173
+ logger.info("[STT] Fallback transcribing via OpenAI/Groq Whisper API");
174
+ return transcribeWithOpenAi(audioBuffer, mimetype);
175
+ }
176
+ throw new Error(
177
+ tr(
178
+ "No AI key (Gemini or OpenAI/Groq) is set",
179
+ "مفتاح الذكاء الاصطناعي (Gemini أو OpenAI/Groq) غير مضبوط",
180
+ ),
181
+ );
182
+ }
183
+
184
+ function sttErrorHint(error) {
185
+ const message = String(error?.message || "");
186
+ if (/quota|RESOURCE_EXHAUSTED|429/i.test(message)) {
187
+ return tr(
188
+ "The free quota is used up. Try again later.",
189
+ "تم تجاوز الحد المجاني. حاول مرة أخرى لاحقاً.",
190
+ );
191
+ }
192
+ if (/API key|API_KEY|401|403/i.test(message)) {
193
+ return tr(
194
+ "Check the API key in the control panel (Settings).",
195
+ "راجع مفتاح الـ API من لوحة التحكم (Settings).",
196
+ );
197
+ }
198
+ if (/upload/i.test(message)) {
199
+ return tr("Uploading the audio failed. Try again.", "فشل رفع الملف الصوتي. حاول مرة أخرى.");
200
+ }
201
+ return "";
202
+ }
203
+
105
204
  module.exports = {
106
205
  name: "stt",
107
206
  aliases: ["totext", "transcribe"],
108
- description: "Convert speech/audio to text (supports Gemini & Groq/OpenAI Whisper)",
109
- usage: "stt (قم بالرد على رسالة صوتية أو إرسالها مع الأمر)",
207
+ description: {
208
+ en: "Converts speech/audio to text (Gemini or Groq/OpenAI Whisper).",
209
+ ar: "يحوّل الكلام/الصوت إلى نص (عبر Gemini أو Groq/OpenAI Whisper).",
210
+ },
211
+ usage: {
212
+ en: "stt (reply to a voice note, or send one with the command)",
213
+ ar: "stt (رد على رسالة صوتية أو أرسلها مع الأمر)",
214
+ },
110
215
  chat: "all",
111
216
 
112
217
  async execute(sock, msg, args, body, groupMetadata) {
113
218
  const chatId = msg.key.remoteJid;
114
219
 
115
220
  // Check if message has audio or if it's a reply to an audio message
221
+ const own = unwrapMessage(msg.message);
116
222
  const audioMessage =
117
- msg.message?.audioMessage ||
118
- msg.message?.extendedTextMessage?.contextInfo?.quotedMessage?.audioMessage;
223
+ own.audioMessage ||
224
+ unwrapMessage(own.extendedTextMessage?.contextInfo?.quotedMessage).audioMessage;
119
225
 
120
226
  if (!audioMessage) {
121
227
  return await sock.sendMessage(chatId, {
122
- text: "📢 الاستخدام:\nأرسل رسالة صوتية أو قم بالرد على رسالة صوتية بالأمر !stt\n\n✨ يدعم تفريغ الصوت عبر Gemini و Groq/OpenAI Whisper\n🌍 يدعم العربية والإنجليزية وكافة اللغات",
228
+ text: tr(
229
+ "📢 Usage:\nSend a voice note, or reply to one, with !stt\n\n✨ Transcribes with Gemini or Groq/OpenAI Whisper\n🌍 Arabic, English and every other language",
230
+ "📢 الاستخدام:\nأرسل رسالة صوتية أو قم بالرد على رسالة صوتية بالأمر !stt\n\n✨ يدعم تفريغ الصوت عبر Gemini و Groq/OpenAI Whisper\n🌍 يدعم العربية والإنجليزية وكافة اللغات",
231
+ ),
123
232
  });
124
233
  }
125
234
 
126
- const provider = resolveSttProvider();
127
235
  const hasGemini = !!geminiStt();
128
236
  const hasOpenAi = !!settings.get("openai_api_key");
129
237
 
130
238
  if (!hasGemini && !hasOpenAi) {
131
239
  return await sock.sendMessage(chatId, {
132
- text: "⚠️ مفتاح الذكاء الاصطناعي (Gemini أو OpenAI/Groq) غير مضبوط. يرجى إضافته من لوحة التحكم (Settings).",
240
+ text: tr(
241
+ "⚠️ No AI key (Gemini or OpenAI/Groq) is set. Add one in the control panel (Settings).",
242
+ "⚠️ مفتاح الذكاء الاصطناعي (Gemini أو OpenAI/Groq) غير مضبوط. يرجى إضافته من لوحة التحكم (Settings).",
243
+ ),
133
244
  });
134
245
  }
135
246
 
136
- let tempAudioPath = null;
137
-
138
247
  // One message, edited from "transcribing" into the transcript itself.
139
- const status = await createStatus(sock, chatId, "🎧 جاري تحويل الصوت إلى نص...", {
140
- replyTo: msg,
141
- });
248
+ const status = await createStatus(
249
+ sock,
250
+ chatId,
251
+ tr("🎧 Transcribing...", "🎧 جاري تحويل الصوت إلى نص..."),
252
+ {
253
+ replyTo: msg,
254
+ },
255
+ );
142
256
 
143
257
  try {
144
- // Download audio content
145
- const audioBuffer = await downloadContentFromMessage(audioMessage, "audio");
146
-
147
- let transcription = "";
148
- if (provider === "openai" && hasOpenAi) {
149
- logger.info("[STT] Transcribing via OpenAI/Groq Whisper API");
150
- transcription = await transcribeWithOpenAi(audioBuffer, audioMessage.mimetype);
151
- } else if (hasGemini) {
152
- const gemini = geminiStt();
153
- await assertProviderRequestUrl(settings.get("gemini_base_url"), {
154
- allowLoopback: true,
155
- });
156
- // Save audio to temporary file
157
- tempAudioPath = path.join(__dirname, `stt_audio_${Date.now()}.ogg`);
158
- await fs.writeFile(tempAudioPath, audioBuffer);
159
-
160
- logger.info(`[STT] Saved audio to temporary file: ${tempAudioPath}`);
161
-
162
- // Upload audio to Gemini. ai.files.upload returns the File directly
163
- const uploaded = await gemini.genAI.files.upload({
164
- file: tempAudioPath,
165
- config: {
166
- mimeType: audioMessage.mimetype || "audio/ogg; codecs=opus",
167
- displayName: `audio-${Date.now()}`,
168
- },
169
- });
170
-
171
- logger.info(`[STT] Uploaded audio to Gemini: ${uploaded.uri}`);
172
-
173
- // Generate transcription using Gemini
174
- const response = await gemini.genAI.models.generateContent({
175
- model: sttModel(),
176
- contents: [
177
- {
178
- role: "user",
179
- parts: [
180
- {
181
- fileData: {
182
- mimeType: uploaded.mimeType,
183
- fileUri: uploaded.uri,
184
- },
185
- },
186
- {
187
- text: "Please transcribe this audio message accurately. Return ONLY the transcription text without any additional commentary, explanations, or formatting. Just the raw transcribed text.",
188
- },
189
- ],
190
- },
191
- ],
192
- });
193
-
194
- transcription = (response.text ?? "").trim();
195
- } else if (hasOpenAi) {
196
- logger.info("[STT] Fallback transcribing via OpenAI/Groq Whisper API");
197
- transcription = await transcribeWithOpenAi(audioBuffer, audioMessage.mimetype);
198
- }
258
+ // A real Buffer, not the download stream: the Whisper path wraps it in
259
+ // a Blob, and a stream in a Blob is the string "[object Object]".
260
+ const audioBuffer = await downloadMedia(downloadContentFromMessage, audioMessage, "audio");
261
+ const transcription = await transcribe(audioBuffer, audioMessage.mimetype);
199
262
 
200
- if (!transcription || transcription === "") {
263
+ if (!transcription) {
201
264
  await status.finish(
202
- "⚠️ لم أتمكن من استخراج أي نص من الرسالة الصوتية. تأكد من أن الصوت واضح.",
265
+ tr(
266
+ "⚠️ I couldn't get any text out of that voice note. Make sure the audio is clear.",
267
+ "⚠️ لم أتمكن من استخراج أي نص من الرسالة الصوتية. تأكد من أن الصوت واضح.",
268
+ ),
203
269
  );
204
270
  return;
205
271
  }
206
272
 
207
273
  // The status line becomes the transcript.
208
- await status.finish(`📝 النص المستخرج:\n\n${transcription}`);
274
+ await status.finish(
275
+ tr(`📝 Transcript:\n\n${transcription}`, `📝 النص المستخرج:\n\n${transcription}`),
276
+ );
209
277
 
210
- logger.info("[STT] Successfully transcribed audio to text (FREE - Gemini)");
278
+ logger.info("[STT] Successfully transcribed audio to text");
211
279
  } catch (error) {
212
280
  logger.error({ err: error }, "[STT] Error transcribing audio");
213
281
 
214
- let errorMessage = "❌ حدث خطأ أثناء تحويل الصوت إلى نص.";
215
-
216
- // Provide more specific error messages
217
- if (error.message?.includes("quota")) {
218
- errorMessage += "\n\nتم تجاوز الحد المجاني. حاول مرة أخرى لاحقاً.";
219
- } else if (error.message?.includes("API key")) {
220
- errorMessage += "\n\nخطأ في مفتاح API. تواصل مع المطور.";
221
- } else if (error.message?.includes("upload")) {
222
- errorMessage += "\n\nفشل رفع الملف الصوتي. حاول مرة أخرى.";
223
- }
224
-
225
- await status.finish(errorMessage);
226
- } finally {
227
- // Clean up temporary file
228
- if (tempAudioPath) {
229
- try {
230
- await fs.unlink(tempAudioPath);
231
- logger.info(`[STT] Deleted temporary file: ${tempAudioPath}`);
232
- } catch (cleanupErr) {
233
- logger.warn(
234
- { err: cleanupErr },
235
- `[STT] Failed to delete temporary file: ${tempAudioPath}`,
236
- );
237
- }
238
- }
282
+ // The real reason goes in the card — a bare "an error happened" left
283
+ // nothing to act on.
284
+ const details = String(error?.message || error || tr("unknown", "غير معروف")).slice(0, 800);
285
+ const hint = sttErrorHint(error);
286
+ await status.finish(
287
+ tr(
288
+ `❌ *Transcription failed*\n\n*Details:* ${details}${hint ? `\n\n${hint}` : ""}`,
289
+ `❌ *حدث خطأ أثناء تحويل الصوت إلى نص*\n\n*التفاصيل:* ${details}${hint ? `\n\n${hint}` : ""}`,
290
+ ),
291
+ );
239
292
  }
240
293
  },
241
294
  };
295
+
296
+ module.exports.transcribe = transcribe;
@@ -1,12 +1,19 @@
1
1
  // file: /commands/todo.cjs (Corrected Reply Logic)
2
2
  const { getUserTodos, saveUserTodos } = require("../utils/storage.cjs");
3
3
  const logger = require("../utils/logger.cjs");
4
+ const { tr } = require("../utils/i18n.cjs");
4
5
  const normalizeJid = require("../utils/normalizeJid.esm.js").default;
5
6
 
6
7
  module.exports = {
7
8
  name: "todo",
8
- description: "Manages your personal to-do list.",
9
- usage: "todo list\ntodo add <المهمة>\ntodo del <رقم المهمة>",
9
+ description: {
10
+ en: "Manages your personal to-do list.",
11
+ ar: "يدير قائمة مهامك الشخصية.",
12
+ },
13
+ usage: {
14
+ en: "todo list\ntodo add <task>\ntodo del <task number>",
15
+ ar: "todo list\ntodo add <المهمة>\ntodo del <رقم المهمة>",
16
+ },
10
17
  chat: "all",
11
18
 
12
19
  async execute(sock, msg, args) {
@@ -22,13 +29,16 @@ module.exports = {
22
29
  const taskToAdd = args.slice(1).join(" ");
23
30
  if (!taskToAdd) {
24
31
  return await sock.sendMessage(remoteJid, {
25
- text: "يرجى كتابة المهمة التي تريد إضافتها.",
32
+ text: tr("Write the task you want to add.", "يرجى كتابة المهمة التي تريد إضافتها."),
26
33
  });
27
34
  }
28
35
  userTasks.push(taskToAdd);
29
36
  saveUserTodos(senderId, userTasks);
30
37
  await sock.sendMessage(remoteJid, {
31
- text: `✅ يا @${senderId.split("@")[0]}، تمت إضافة المهمة لقائمتك.`,
38
+ text: tr(
39
+ `✅ @${senderId.split("@")[0]}, the task was added to your list.`,
40
+ `✅ يا @${senderId.split("@")[0]}، تمت إضافة المهمة لقائمتك.`,
41
+ ),
32
42
  mentions: [senderId],
33
43
  });
34
44
  break;
@@ -39,13 +49,16 @@ module.exports = {
39
49
  const taskNumber = parseInt(args[1], 10);
40
50
  if (isNaN(taskNumber) || taskNumber <= 0 || taskNumber > userTasks.length) {
41
51
  return await sock.sendMessage(remoteJid, {
42
- text: "رقم المهمة غير صالح.",
52
+ text: tr("That task number isn't valid.", "رقم المهمة غير صالح."),
43
53
  });
44
54
  }
45
55
  const removedTask = userTasks.splice(taskNumber - 1, 1);
46
56
  saveUserTodos(senderId, userTasks);
47
57
  await sock.sendMessage(remoteJid, {
48
- text: `☑️ يا @${senderId.split("@")[0]}، تم حذف المهمة: *${removedTask[0]}*`,
58
+ text: tr(
59
+ `☑️ @${senderId.split("@")[0]}, removed the task: *${removedTask[0]}*`,
60
+ `☑️ يا @${senderId.split("@")[0]}، تم حذف المهمة: *${removedTask[0]}*`,
61
+ ),
49
62
  mentions: [senderId],
50
63
  });
51
64
  break;
@@ -55,12 +68,18 @@ module.exports = {
55
68
  default: {
56
69
  if (userTasks.length === 0) {
57
70
  return await sock.sendMessage(remoteJid, {
58
- text: `قائمة مهامك فارغة يا @${senderId.split("@")[0]}.`,
71
+ text: tr(
72
+ `Your to-do list is empty, @${senderId.split("@")[0]}.`,
73
+ `قائمة مهامك فارغة يا @${senderId.split("@")[0]}.`,
74
+ ),
59
75
  mentions: [senderId],
60
76
  });
61
77
  }
62
78
 
63
- let reply = `*📋 قائمة مهامك يا @${senderId.split("@")[0]}:*\n\n`;
79
+ let reply = tr(
80
+ `*📋 Your to-do list, @${senderId.split("@")[0]}:*\n\n`,
81
+ `*📋 قائمة مهامك يا @${senderId.split("@")[0]}:*\n\n`,
82
+ );
64
83
  userTasks.forEach((task, index) => {
65
84
  reply += `${index + 1}. ${task}\n`;
66
85
  });
@@ -75,7 +94,10 @@ module.exports = {
75
94
  } catch (error) {
76
95
  logger.error({ err: error, command: "todo" }, "An error occurred in the todo command");
77
96
  await sock.sendMessage(msg.key.remoteJid, {
78
- text: "حدث خطأ أثناء معالجة قائمة المهام.",
97
+ text: tr(
98
+ "Something went wrong with the to-do list.",
99
+ "حدث خطأ أثناء معالجة قائمة المهام.",
100
+ ),
79
101
  });
80
102
  }
81
103
  },
@@ -23,6 +23,7 @@ const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
23
23
  const execFileAsync = promisify(execFile);
24
24
 
25
25
  const { ffmpegPath } = require("../utils/thumbnail.cjs");
26
+ const { tr } = require("../utils/i18n.cjs");
26
27
 
27
28
  function tmpPath(ext) {
28
29
  return path.join(
@@ -133,8 +134,14 @@ async function synthesizeVoice(text, lang = "ar") {
133
134
  module.exports = {
134
135
  name: "tts",
135
136
  aliases: ["tovoice", "speak"],
136
- description: "Convert text to speech (FREE - no API costs)",
137
- usage: "tts <النص> (أو رد على رسالة نصية)",
137
+ description: {
138
+ en: "Converts text to speech (free — no API costs).",
139
+ ar: "يحوّل النص إلى كلام مسموع (مجاني — بدون تكلفة API).",
140
+ },
141
+ usage: {
142
+ en: "tts <text> (or reply to a text message)",
143
+ ar: "tts <النص> (أو رد على رسالة نصية)",
144
+ },
138
145
  chat: "all",
139
146
 
140
147
  async execute(sock, msg, args) {
@@ -152,16 +159,24 @@ module.exports = {
152
159
  sock,
153
160
  chatId,
154
161
  {
155
- text: "📢 الاستخدام:\n!tts <النص>\n\nأو رد على رسالة نصية بالأمر !tts\n\n✨ مجاني تماماً - بدون تكاليف!",
162
+ text: tr(
163
+ "📢 Usage:\n!tts <text>\n\nor reply to a text message with !tts\n\n✨ Completely free — no costs!",
164
+ "📢 الاستخدام:\n!tts <النص>\n\nأو رد على رسالة نصية بالأمر !tts\n\n✨ مجاني تماماً - بدون تكاليف!",
165
+ ),
156
166
  },
157
167
  { replyTo: msg },
158
168
  );
159
169
  }
160
170
 
161
171
  // One status line: it disappears once the voice note is on its way.
162
- const status = await createStatus(sock, chatId, "🎙️ بحوّل النص لصوت...", {
163
- replyTo: msg,
164
- });
172
+ const status = await createStatus(
173
+ sock,
174
+ chatId,
175
+ tr("🎙️ Turning the text into speech...", "🎙️ بحوّل النص لصوت..."),
176
+ {
177
+ replyTo: msg,
178
+ },
179
+ );
165
180
 
166
181
  try {
167
182
  const voice = await synthesizeVoice(textToConvert);
@@ -198,7 +213,10 @@ module.exports = {
198
213
  logger.info("[TTS] Successfully delivered TTS audio");
199
214
  } catch (error) {
200
215
  logger.error({ err: error }, "[TTS] Error converting text to speech");
201
- await status.fail(error, "حصلت مشكلة وأنا بحوّل النص لصوت");
216
+ await status.fail(
217
+ error,
218
+ tr("Something went wrong turning the text into speech", "حصلت مشكلة وأنا بحوّل النص لصوت"),
219
+ );
202
220
  }
203
221
  },
204
222
 
@@ -1,11 +1,18 @@
1
1
  // file: /commands/unblock.js (Upgraded with private chat context)
2
2
  const logger = require("../utils/logger.cjs");
3
3
  const normalizeJid = require("../utils/normalizeJid.esm.js");
4
+ const { tr } = require("../utils/i18n.cjs");
4
5
 
5
6
  module.exports = {
6
7
  name: "unblock",
7
- description: "Unblocks a user.",
8
- usage: "unblock [@عضو|رقم] (أو رد على رسالته)",
8
+ description: {
9
+ en: "Unblocks a user.",
10
+ ar: "يلغي حظر مستخدم.",
11
+ },
12
+ usage: {
13
+ en: "unblock [@member|number] (or reply to their message)",
14
+ ar: "unblock [@عضو|رقم] (أو رد على رسالته)",
15
+ },
9
16
  chat: "all",
10
17
 
11
18
  async execute(sock, msg, args) {
@@ -25,7 +32,10 @@ module.exports = {
25
32
  targetJid = `${numberArg.replace(/\D/g, "")}@s.whatsapp.net`;
26
33
  } else {
27
34
  return await sock.sendMessage(remoteJid, {
28
- text: "لفك حظر عضو، استخدم الأمر في شاته الخاص، أو قم بعمل منشن له، أو كتابة رقمه.",
35
+ text: tr(
36
+ "To unblock someone, use this in their private chat, mention them, or type their number.",
37
+ "لفك حظر عضو، استخدم الأمر في شاته الخاص، أو قم بعمل منشن له، أو كتابة رقمه.",
38
+ ),
29
39
  });
30
40
  }
31
41
  }
@@ -46,7 +56,10 @@ module.exports = {
46
56
  } catch (error) {
47
57
  logger.error({ err: error, command: "unblock" }, "Error in !unblock command");
48
58
  await sock.sendMessage(remoteJid, {
49
- text: "حدث خطأ أثناء محاولة فك حظر المستخدم.",
59
+ text: tr(
60
+ "Something went wrong while unblocking the user.",
61
+ "حدث خطأ أثناء محاولة فك حظر المستخدم.",
62
+ ),
50
63
  });
51
64
  }
52
65
  },