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