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.
- package/README.md +57 -3
- package/SETUP.md +63 -7
- package/app.cjs +159 -46
- package/deploy/install.sh +10 -5
- package/package.json +9 -6
- package/public/dashboard/assets/40af6d88b63079a0-BZ8ojJNu.woff2 +0 -0
- package/public/dashboard/assets/481acf6760031cee-BypgxfGb.woff2 +0 -0
- package/public/dashboard/assets/6d3351fc535f8ef3-D2-eand5.woff2 +0 -0
- package/public/dashboard/assets/8ab0af53a3bda9d3-CyCXRvzh.woff2 +0 -0
- package/public/dashboard/assets/8f262393e9249e61-TQp-UTiE.woff2 +0 -0
- package/public/dashboard/assets/94d65887a83f1282-DmpS2jIq.woff2 +0 -0
- package/public/dashboard/assets/99e400330f36ae77-D3oMJlXt.woff2 +0 -0
- package/public/dashboard/assets/9d1f41b13e519d90-BVNSOH3d.woff2 +0 -0
- package/public/dashboard/assets/a005256cb957ecc7-CoYeBiSI.woff2 +0 -0
- package/public/dashboard/assets/b19c2080652a3c2b-DIC32ArD.woff2 +0 -0
- package/public/dashboard/assets/c4064400db3750ce-BehTv68k.woff2 +0 -0
- package/public/dashboard/assets/c69d345fa1068c2d-CmI34b-g.woff2 +0 -0
- package/public/dashboard/assets/cc27b30471250057-6fWv1k7M.woff2 +0 -0
- package/public/dashboard/assets/d8c30647abfeffe6-eXO_dkmS.woff2 +0 -0
- package/public/dashboard/assets/eb83d8d40af4411f-Buze_B52.woff2 +0 -0
- package/public/dashboard/assets/effc6711249e7349-qRpaaN48.woff2 +0 -0
- package/public/dashboard/assets/gateway-BDYet0pI.css +1 -0
- package/public/dashboard/assets/gateway-BYt6-s1O.js +1 -0
- package/public/dashboard/assets/index-B9wFpD_z.css +2 -0
- package/public/dashboard/assets/index-DWcQmu0_.js +124 -0
- package/public/dashboard/assets/index-Da-j89O-.js +458 -0
- package/public/dashboard/font-licenses/jetbrainsmono-OFL.txt +93 -0
- package/public/dashboard/font-licenses/plusjakartasans-OFL.txt +93 -0
- package/public/dashboard/font-licenses/tajawal-OFL.txt +93 -0
- package/public/dashboard/gateway.html +17 -0
- package/public/dashboard/index.html +3 -5
- package/public/ui-boot.js +33 -14
- package/scheduler.cjs +76 -23
- package/src/auth/auth-storage.cjs +54 -7
- package/src/auth/use-database-auth-state.js +70 -39
- package/src/automation/engine.js +412 -0
- package/src/automation/limits.cjs +6 -0
- package/src/automation/manage.js +290 -0
- package/src/automation/reactions.js +471 -0
- package/src/automation/rules.cjs +114 -0
- package/src/automation/status.cjs +76 -0
- package/src/backup/account.cjs +29 -0
- package/src/backup/activation.cjs +247 -0
- package/src/backup/content.cjs +36 -0
- package/src/backup/create.cjs +280 -0
- package/src/backup/extensions.cjs +101 -0
- package/src/backup/format.cjs +565 -0
- package/src/backup/jobs.cjs +111 -0
- package/src/backup/journal.cjs +41 -0
- package/src/backup/plan.cjs +223 -0
- package/src/backup/recovery.cjs +110 -0
- package/src/backup/restore.cjs +460 -0
- package/src/backup/uploads.cjs +146 -0
- package/src/bootstrap/core.js +50 -12
- package/src/bootstrap/panel.js +53 -2
- package/src/bootstrap/session-startup-policy.js +8 -1
- package/src/cli.js +163 -22
- package/src/commands/autodelete.cjs +41 -57
- package/src/commands/autoschedule.cjs +7 -33
- package/src/commands/blacklist.cjs +17 -35
- package/src/commands/block.cjs +4 -18
- package/src/commands/calc.cjs +22 -74
- package/src/commands/debt.cjs +28 -59
- package/src/commands/deleteschedule.cjs +7 -23
- package/src/commands/digit.cjs +5 -39
- package/src/commands/gemini.cjs +135 -218
- package/src/commands/group/add.cjs +28 -76
- package/src/commands/group/all.cjs +4 -15
- package/src/commands/group/antilink.cjs +28 -41
- package/src/commands/group/antispam.cjs +25 -35
- package/src/commands/group/approveall.cjs +7 -21
- package/src/commands/group/clearwarns.cjs +4 -18
- package/src/commands/group/deletenote.cjs +4 -18
- package/src/commands/group/demote.cjs +6 -23
- package/src/commands/group/flagged.cjs +10 -19
- package/src/commands/group/kick.cjs +26 -36
- package/src/commands/group/media.cjs +21 -36
- package/src/commands/group/members.cjs +16 -28
- package/src/commands/group/note.cjs +3 -14
- package/src/commands/group/policy.cjs +16 -37
- package/src/commands/group/promote.cjs +5 -22
- package/src/commands/group/removeall.cjs +6 -38
- package/src/commands/group/rules.cjs +4 -19
- package/src/commands/group/save.cjs +4 -18
- package/src/commands/group/setname.cjs +5 -19
- package/src/commands/group/setpp.cjs +8 -26
- package/src/commands/group/setrules.cjs +4 -15
- package/src/commands/group/setwarn.cjs +6 -23
- package/src/commands/group/tagadmins.cjs +5 -16
- package/src/commands/group/warn.cjs +5 -16
- package/src/commands/group/warns.cjs +12 -33
- package/src/commands/group/welcome.cjs +17 -34
- package/src/commands/group.cjs +91 -68
- package/src/commands/help.cjs +48 -89
- package/src/commands/lang.cjs +38 -97
- package/src/commands/listschedules.cjs +19 -30
- package/src/commands/loop.cjs +9 -55
- package/src/commands/md.cjs +2 -13
- package/src/commands/memory.cjs +53 -87
- package/src/commands/mod.cjs +40 -79
- package/src/commands/notes.cjs +4 -15
- package/src/commands/pack.cjs +26 -49
- package/src/commands/packs.cjs +8 -18
- package/src/commands/perm.cjs +48 -51
- package/src/commands/ping.cjs +2 -10
- package/src/commands/poll.cjs +5 -38
- package/src/commands/prayer.cjs +55 -36
- package/src/commands/qr.cjs +4 -18
- package/src/commands/rand.cjs +9 -58
- package/src/commands/restart.cjs +15 -33
- package/src/commands/schedule.cjs +5 -25
- package/src/commands/score.cjs +6 -27
- package/src/commands/send.cjs +4 -18
- package/src/commands/setprefix.cjs +11 -23
- package/src/commands/shortlink.cjs +13 -39
- package/src/commands/status.cjs +188 -76
- package/src/commands/sticker.cjs +5 -16
- package/src/commands/stickers.cjs +16 -20
- package/src/commands/stopbot.cjs +9 -25
- package/src/commands/stt.cjs +75 -107
- package/src/commands/todo.cjs +11 -31
- package/src/commands/toimage.cjs +11 -27
- package/src/commands/translate.cjs +53 -36
- package/src/commands/tts.cjs +46 -40
- package/src/commands/unblock.cjs +3 -17
- package/src/commands/update.cjs +23 -0
- package/src/commands/weather.cjs +40 -47
- package/src/config/ai-identity.cjs +14 -1
- package/src/config/baileys.config.js +16 -3
- package/src/config/data-dir.cjs +37 -0
- package/src/config/defaults.cjs +1 -0
- package/src/config/exit-codes.cjs +11 -0
- package/src/config/lock.cjs +55 -81
- package/src/config/official-links.cjs +61 -0
- package/src/config/paths.cjs +4 -33
- package/src/config/release.cjs +87 -0
- package/src/config/settings.cjs +199 -10
- package/src/core/connection.js +77 -9
- package/src/core/events.js +119 -33
- package/src/core/session.js +536 -84
- package/src/core/socket.js +81 -10
- package/src/db/copy.cjs +136 -0
- package/src/db/db.cjs +241 -36
- package/src/db/startup-guard.js +5 -0
- package/src/db/store.cjs +561 -54
- package/src/diagnostics/baileysLog.cjs +87 -0
- package/src/diagnostics/debugLog.cjs +16 -4
- package/src/diagnostics/device.cjs +4 -2
- package/src/diagnostics/nodeRuntime.cjs +131 -0
- package/src/diagnostics/signalSessionInspect.cjs +38 -0
- package/src/domain/command.js +24 -22
- package/src/extensions/autoReply.cjs +521 -0
- package/src/extensions/context.cjs +73 -0
- package/src/extensions/contract.cjs +69 -0
- package/src/extensions/entitlement/client.cjs +381 -0
- package/src/extensions/entitlement/index.cjs +629 -0
- package/src/extensions/entitlement/installation.cjs +117 -0
- package/src/extensions/entitlement/keys.cjs +72 -0
- package/src/extensions/entitlement/state.cjs +201 -0
- package/src/extensions/entitlement/target.cjs +7 -0
- package/src/extensions/entitlement/token.cjs +225 -0
- package/src/extensions/host.cjs +519 -0
- package/src/extensions/templateKeys.cjs +81 -0
- package/src/handlers/command.handler.js +191 -64
- package/src/handlers/group.handler.js +78 -18
- package/src/handlers/message.handler.js +56 -25
- package/src/i18n/catalog.generated.cjs +3537 -0
- package/src/index.js +51 -12
- package/src/legal/bundled/ar.json +102 -0
- package/src/legal/bundled/en.json +102 -0
- package/src/legal/bundled/es-419.json +102 -0
- package/src/legal/bundled/pt-BR.json +102 -0
- package/src/legal/cli.cjs +200 -0
- package/src/legal/consent.cjs +187 -0
- package/src/legal/document.cjs +156 -0
- package/src/legal/keys.cjs +100 -0
- package/src/legal/release.cjs +226 -0
- package/src/legal/remote.cjs +419 -0
- package/src/legal/terms.cjs +142 -0
- package/src/messaging/escape.cjs +31 -0
- package/src/messaging/health.cjs +65 -0
- package/src/messaging/identity.cjs +42 -0
- package/src/messaging/message.cjs +136 -0
- package/src/messaging/parser.cjs +88 -0
- package/src/messaging/router.cjs +217 -0
- package/src/middleware/permissions.middleware.js +34 -2
- package/src/panel/account-profile.cjs +489 -0
- package/src/panel/fallback-page.cjs +177 -0
- package/src/panel/password-reset.cjs +13 -14
- package/src/panel/recovery-email.cjs +3 -1
- package/src/routes/backup.api.esm.js +175 -0
- package/src/routes/dashboard.api.esm.js +183 -7
- package/src/routes/plus.api.esm.js +172 -0
- package/src/routes/reactions.api.esm.js +60 -0
- package/src/services/aiAgent.cjs +56 -43
- package/src/services/aiDocs.cjs +187 -0
- package/src/services/aiImage.cjs +183 -0
- package/src/services/aiMedia.cjs +146 -0
- package/src/services/aiProviders.cjs +76 -80
- package/src/services/aiRouter.cjs +2 -2
- package/src/services/aiToolAuth.cjs +76 -4
- package/src/services/aiTools.cjs +431 -105
- package/src/services/autoDelete.cjs +9 -1
- package/src/services/levix-docs.generated.json +2623 -0
- package/src/services/memoryPolicy.cjs +56 -0
- package/src/services/updateCheck.cjs +362 -0
- package/src/stickers/errors.cjs +53 -97
- package/src/stickers/library.cjs +13 -6
- package/src/stickers/owner.cjs +1 -1
- package/src/utils/commandContext.cjs +13 -0
- package/src/utils/commandDocs.cjs +42 -20
- package/src/utils/geminiHttpOptions.cjs +56 -0
- package/src/utils/geminiMedia.cjs +28 -3
- package/src/utils/groupMetadataCache.cjs +386 -21
- package/src/utils/httpsFetch.cjs +113 -0
- package/src/utils/i18n.cjs +117 -7
- package/src/utils/linkPreview.cjs +90 -0
- package/src/utils/logger.cjs +6 -0
- package/src/utils/markdownParser.cjs +3 -3
- package/src/utils/memory.cjs +375 -28
- package/src/utils/messageContent.cjs +7 -1
- package/src/utils/moderationAction.cjs +116 -73
- package/src/utils/moderationSummary.cjs +32 -56
- package/src/utils/permissionLevel.cjs +7 -28
- package/src/utils/permissions.cjs +23 -14
- package/src/utils/permissions.esm.js +99 -166
- package/src/utils/recentMessageCache.esm.js +241 -37
- package/src/utils/recurrence.cjs +78 -66
- package/src/utils/sendBotMessage.cjs +14 -29
- package/src/utils/sendBotMessage.esm.js +28 -13
- package/src/utils/statusMessage.cjs +94 -33
- package/src/utils/stickerBot.cjs +18 -16
- package/src/utils/storage.cjs +2 -0
- package/src/utils/storage.esm.js +2 -0
- package/src/utils/thumbnail.cjs +5 -21
- package/public/dashboard/assets/index-B1sOW2VX.js +0 -561
- package/public/dashboard/assets/index-CK8osB4o.css +0 -2
- package/public/dashboard.css +0 -3127
- package/public/dashboard.js +0 -1981
- package/public/gateway-i18n.js +0 -321
- package/public/gateway.js +0 -70
- package/views/dashboard.ejs +0 -775
- package/views/login.ejs +0 -408
- package/views/qr.ejs +0 -155
- package/views/setup.ejs +0 -118
package/src/commands/lang.cjs
CHANGED
|
@@ -2,136 +2,77 @@
|
|
|
2
2
|
const logger = require("../utils/logger.cjs");
|
|
3
3
|
const settings = require("../config/settings.cjs");
|
|
4
4
|
const runtimeConfig = require("../config/runtime-config.cjs");
|
|
5
|
-
const {
|
|
6
|
-
|
|
5
|
+
const {
|
|
6
|
+
isOwnerJidSync,
|
|
7
|
+
isBotAdminUserSync,
|
|
8
|
+
getSenderCandidatesSync,
|
|
9
|
+
} = require("../utils/permissions.cjs");
|
|
10
|
+
const { normalizeLocale, t, withLang } = require("../utils/i18n.cjs");
|
|
7
11
|
|
|
8
12
|
module.exports = {
|
|
9
13
|
name: "lang",
|
|
10
14
|
aliases: ["language", "لغة"],
|
|
11
|
-
description: {
|
|
12
|
-
en: "Shows or changes the bot's language.",
|
|
13
|
-
ar: "يعرض لغة البوت أو يغيّرها.",
|
|
14
|
-
},
|
|
15
|
-
usage: {
|
|
16
|
-
en: "lang [en|ar|auto]",
|
|
17
|
-
ar: "lang [en|ar|auto]",
|
|
18
|
-
},
|
|
19
15
|
chat: "all",
|
|
20
16
|
|
|
21
|
-
async execute(sock, msg, args) {
|
|
17
|
+
async execute(sock, msg, args, body, groupMetadata, ctx) {
|
|
22
18
|
const chatId = msg.key.remoteJid;
|
|
23
|
-
const sender = msg.key.participant || msg.key.remoteJid;
|
|
24
19
|
const prefix = runtimeConfig.getPrefix();
|
|
25
20
|
const currentLang = settings.get("bot_language") || "auto";
|
|
26
|
-
|
|
27
21
|
const firstArg = args?.[0] ? String(args[0]).toLowerCase().trim() : "";
|
|
22
|
+
const requestedLang = firstArg === "auto" ? "auto" : normalizeLocale(firstArg);
|
|
28
23
|
|
|
29
24
|
if (!args || args.length === 0) {
|
|
30
25
|
const labels = {
|
|
31
|
-
auto:
|
|
32
|
-
ar:
|
|
33
|
-
en:
|
|
26
|
+
auto: t("bot.lang.autoLabel"),
|
|
27
|
+
ar: t("bot.lang.arLabel"),
|
|
28
|
+
en: t("bot.lang.enLabel"),
|
|
29
|
+
"pt-BR": t("bot.lang.ptBrLabel"),
|
|
30
|
+
"es-419": t("bot.lang.es419Label"),
|
|
34
31
|
};
|
|
35
|
-
const text =
|
|
36
|
-
`🌐 *Bot language*
|
|
37
|
-
|
|
38
|
-
⚙️ *Current:* \`${labels[currentLang] || currentLang}\`
|
|
39
|
-
• \`${prefix}lang ar\` — Modern Standard Arabic, always
|
|
40
|
-
• \`${prefix}lang en\` — English always
|
|
41
|
-
• \`${prefix}lang auto\` — follow the language of each message
|
|
42
|
-
|
|
43
|
-
Commands, !help and the AI all answer in it.
|
|
44
|
-
|
|
45
|
-
🔢 *To convert digits* use \`${prefix}digit\` — e.g. \`${prefix}digit 12345\``,
|
|
46
|
-
`🌐 *لغة البوت*
|
|
47
|
-
|
|
48
|
-
⚙️ *اللغة الحالية:* \`${labels[currentLang] || currentLang}\`
|
|
49
|
-
• \`${prefix}lang ar\` — العربية الفصحى دائماً
|
|
50
|
-
• \`${prefix}lang en\` — English always
|
|
51
|
-
• \`${prefix}lang auto\` — تلقائي حسب لغة الرسالة
|
|
52
|
-
|
|
53
|
-
ستستخدمها جميع الأوامر و!help والذكاء الاصطناعي في الردود.
|
|
54
|
-
|
|
55
|
-
🔢 *لتحويل الأرقام* استخدم \`${prefix}digit\` — مثال: \`${prefix}digit 12345\``,
|
|
56
|
-
);
|
|
32
|
+
const text = t("bot.lang.list", { prefix, current: labels[currentLang] || currentLang });
|
|
57
33
|
await sock.sendMessage(chatId, { text }, { quoted: msg });
|
|
58
34
|
return;
|
|
59
35
|
}
|
|
60
36
|
|
|
61
|
-
if (
|
|
37
|
+
if (requestedLang) {
|
|
62
38
|
if (args.length > 1) {
|
|
63
39
|
await sock.sendMessage(
|
|
64
40
|
chatId,
|
|
65
|
-
{
|
|
66
|
-
text: tr(
|
|
67
|
-
`🔢 To convert digits, use \`${prefix}digit\`:\n• \`${prefix}digit ${firstArg} ${args.slice(1).join(" ")}\`\n• or \`${prefix}digit ${args.slice(1).join(" ")}\` to detect the direction.`,
|
|
68
|
-
`🔢 لتحويل الأرقام استخدم \`${prefix}digit\`:\n• \`${prefix}digit ${firstArg} ${args.slice(1).join(" ")}\`\n• أو \`${prefix}digit ${args.slice(1).join(" ")}\` للتحويل التلقائي.`,
|
|
69
|
-
),
|
|
70
|
-
},
|
|
41
|
+
{ text: t("bot.lang.digitHint", { prefix, option: firstArg, rest: args.slice(1).join(" ") }) },
|
|
71
42
|
{ quoted: msg },
|
|
72
43
|
);
|
|
73
44
|
return;
|
|
74
45
|
}
|
|
75
46
|
|
|
76
|
-
const
|
|
77
|
-
|
|
47
|
+
const authMetadata =
|
|
48
|
+
ctx && Object.hasOwn(ctx, "authGroupMetadata")
|
|
49
|
+
? ctx.authGroupMetadata
|
|
50
|
+
: groupMetadata;
|
|
51
|
+
const candidates = getSenderCandidatesSync(msg, sock);
|
|
52
|
+
const isOwner = candidates.some((id) => isOwnerJidSync(id, authMetadata));
|
|
53
|
+
const isAdmin = candidates.some((id) => isBotAdminUserSync(id, authMetadata));
|
|
78
54
|
if (!isOwner && !isAdmin) {
|
|
79
|
-
await sock.sendMessage(
|
|
80
|
-
chatId,
|
|
81
|
-
{
|
|
82
|
-
text: tr(
|
|
83
|
-
`⚠️ Sorry, only the bot owner and admins can change the bot's language.\n_To convert digits, use \`${prefix}digit\`._`,
|
|
84
|
-
`⚠️ عذراً، تغيير لغة البوت متاح لمالك البوت والمسؤولين فقط.\n_لتحويل الأرقام استخدم \`${prefix}digit\`._`,
|
|
85
|
-
),
|
|
86
|
-
},
|
|
87
|
-
{ quoted: msg },
|
|
88
|
-
);
|
|
55
|
+
await sock.sendMessage(chatId, { text: t("bot.lang.denied", { prefix }) }, { quoted: msg });
|
|
89
56
|
return;
|
|
90
57
|
}
|
|
91
58
|
|
|
92
|
-
settings.set("bot_language",
|
|
93
|
-
logger.info(`[Language] Bot response language set to: ${
|
|
59
|
+
settings.set("bot_language", requestedLang);
|
|
60
|
+
logger.info(`[Language] Bot response language set to: ${requestedLang}`);
|
|
94
61
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
{
|
|
107
|
-
text: "✅ Bot language set to *English*. Commands and the AI assistant will now always answer in English.",
|
|
108
|
-
},
|
|
109
|
-
{ quoted: msg },
|
|
110
|
-
);
|
|
111
|
-
} else {
|
|
112
|
-
await sock.sendMessage(
|
|
113
|
-
chatId,
|
|
114
|
-
{
|
|
115
|
-
text: tr(
|
|
116
|
-
"✅ Language set to *Auto*. The bot will answer each message in the language it is written in.",
|
|
117
|
-
"✅ تم ضبط اللغة على *التلقائي (Auto)*. سيرد البوت بحسب لغة كل رسالة ترسلها له تلقائياً.",
|
|
118
|
-
),
|
|
119
|
-
},
|
|
120
|
-
{ quoted: msg },
|
|
121
|
-
);
|
|
122
|
-
}
|
|
62
|
+
const confirmation = {
|
|
63
|
+
ar: "selectedAr",
|
|
64
|
+
en: "selectedEn",
|
|
65
|
+
auto: "selectedAuto",
|
|
66
|
+
"pt-BR": "selectedPtBr",
|
|
67
|
+
"es-419": "selectedEs419",
|
|
68
|
+
}[requestedLang];
|
|
69
|
+
const text = requestedLang !== "auto"
|
|
70
|
+
? withLang(requestedLang, () => t(`bot.lang.${confirmation}`))
|
|
71
|
+
: t(`bot.lang.${confirmation}`);
|
|
72
|
+
await sock.sendMessage(chatId, { text }, { quoted: msg });
|
|
123
73
|
return;
|
|
124
74
|
}
|
|
125
75
|
|
|
126
|
-
await sock.sendMessage(
|
|
127
|
-
chatId,
|
|
128
|
-
{
|
|
129
|
-
text: tr(
|
|
130
|
-
`❌ Unknown option.\nUse:\n• \`${prefix}lang ar\` / \`${prefix}lang en\` / \`${prefix}lang auto\` for the bot's language\n• \`${prefix}digit 12345\` to convert digits`,
|
|
131
|
-
`❌ خيار غير صحيح.\nاستخدم:\n• \`${prefix}lang ar\` / \`${prefix}lang en\` / \`${prefix}lang auto\` للغة البوت\n• \`${prefix}digit 12345\` لتحويل الأرقام`,
|
|
132
|
-
),
|
|
133
|
-
},
|
|
134
|
-
{ quoted: msg },
|
|
135
|
-
);
|
|
76
|
+
await sock.sendMessage(chatId, { text: t("bot.lang.unknown", { prefix }) }, { quoted: msg });
|
|
136
77
|
},
|
|
137
78
|
};
|
|
@@ -1,59 +1,48 @@
|
|
|
1
1
|
// file: /commands/listschedules.js
|
|
2
|
-
const {
|
|
3
|
-
const
|
|
2
|
+
const { getScheduledJobsForChat } = require("../../scheduler.cjs");
|
|
3
|
+
const settings = require("../config/settings.cjs");
|
|
4
|
+
const { t, intlTag } = require("../utils/i18n.cjs");
|
|
4
5
|
|
|
5
6
|
module.exports = {
|
|
6
7
|
name: "listschedules",
|
|
7
|
-
description: {
|
|
8
|
-
en: "Lists all active and pending scheduled messages.",
|
|
9
|
-
ar: "يعرض كل الرسائل المجدولة النشطة والمعلّقة.",
|
|
10
|
-
},
|
|
11
|
-
usage: {
|
|
12
|
-
en: "listschedules",
|
|
13
|
-
ar: "listschedules",
|
|
14
|
-
},
|
|
15
8
|
chat: "all",
|
|
16
9
|
userAdminRequired: true,
|
|
17
10
|
|
|
18
11
|
async execute(sock, msg) {
|
|
19
|
-
|
|
12
|
+
// Only this chat's jobs: another chat's reminders are never listed here.
|
|
13
|
+
const jobs = getScheduledJobsForChat(msg.key.remoteJid, msg.key.remoteJidAlt);
|
|
20
14
|
const activeJobs = jobs.filter((job) => job.status === "pending" || job.status === "active");
|
|
21
15
|
|
|
22
16
|
if (activeJobs.length === 0) {
|
|
23
17
|
return await sock.sendMessage(msg.key.remoteJid, {
|
|
24
|
-
text:
|
|
18
|
+
text: t("bot.schedules.listschedules.none"),
|
|
25
19
|
});
|
|
26
20
|
}
|
|
27
21
|
|
|
28
|
-
let reply =
|
|
22
|
+
let reply = t("bot.schedules.listschedules.header");
|
|
29
23
|
|
|
30
24
|
activeJobs.forEach((job, index) => {
|
|
31
|
-
reply +=
|
|
25
|
+
reply += t("bot.schedules.listschedules.jobTitle", { number: index + 1 });
|
|
32
26
|
reply += `*ID:* \`${job.id}\`\n`;
|
|
33
|
-
reply +=
|
|
27
|
+
reply += t("bot.schedules.listschedules.message", { message: job.message });
|
|
34
28
|
|
|
35
29
|
if (job.type === "recurring") {
|
|
36
|
-
reply +=
|
|
37
|
-
`*Repeats:* ${job.cronString} (daily/weekly)\n`,
|
|
38
|
-
`*التكرار:* ${job.cronString} (يوميًا/أسبوعيًا)\n`,
|
|
39
|
-
);
|
|
30
|
+
reply += t("bot.schedules.listschedules.repeats", { cron: job.cronString });
|
|
40
31
|
} else {
|
|
41
|
-
const jobDate = new Date(job.date).toLocaleString(
|
|
42
|
-
timeZone: "
|
|
32
|
+
const jobDate = new Date(job.date).toLocaleString(intlTag(), {
|
|
33
|
+
timeZone: settings.get("bot_timezone"),
|
|
43
34
|
});
|
|
44
|
-
reply +=
|
|
35
|
+
reply += t("bot.schedules.listschedules.when", { date: jobDate });
|
|
45
36
|
}
|
|
46
37
|
const inGroup = job.targetJid.endsWith("@g.us");
|
|
47
|
-
reply +=
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
38
|
+
reply += t("bot.schedules.listschedules.where", {
|
|
39
|
+
place: inGroup
|
|
40
|
+
? t("bot.schedules.listschedules.placeGroup")
|
|
41
|
+
: t("bot.schedules.listschedules.placePrivate"),
|
|
42
|
+
});
|
|
51
43
|
});
|
|
52
44
|
|
|
53
|
-
reply +=
|
|
54
|
-
"*To delete one, use:*\n`!deleteschedule <ID>`",
|
|
55
|
-
"*لحذف مهمة، استخدم:*\n`!deleteschedule <ID>`",
|
|
56
|
-
);
|
|
45
|
+
reply += t("bot.schedules.listschedules.deleteHint");
|
|
57
46
|
|
|
58
47
|
await sock.sendMessage(msg.key.remoteJid, { text: reply });
|
|
59
48
|
},
|
package/src/commands/loop.cjs
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
// flood bot (and from getting the account banned).
|
|
14
14
|
|
|
15
15
|
const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
|
|
16
|
-
const {
|
|
16
|
+
const { t } = require("../utils/i18n.cjs");
|
|
17
17
|
|
|
18
18
|
const MAX_ITEMS = 100; // total iterations, one-message mode
|
|
19
19
|
const MAX_SPLIT_ITEMS = 15; // total iterations, separate-messages mode
|
|
@@ -24,43 +24,7 @@ const SPLIT_FLAGS = new Set(["-s", "--split", "split", "منفصل", "منفصل
|
|
|
24
24
|
const NO_NUMBER_FLAGS = new Set(["-n", "--nonum", "--plain", "بدون-ترقيم"]);
|
|
25
25
|
|
|
26
26
|
const helpText = () =>
|
|
27
|
-
|
|
28
|
-
"🔁 *Loop*\n\n" +
|
|
29
|
-
"*Usage:*\n" +
|
|
30
|
-
"`!loop <count> <text>` — repeat the text in one message\n" +
|
|
31
|
-
"`!loop <from>-<to>` — print the numbers from/to\n" +
|
|
32
|
-
"`!loop <from>-<to>:<step>` — with a custom step\n\n" +
|
|
33
|
-
"*Options:*\n" +
|
|
34
|
-
"`-s` separate messages instead of one\n" +
|
|
35
|
-
"`-n` no numbering\n\n" +
|
|
36
|
-
"*Placeholders in the text:*\n" +
|
|
37
|
-
"`{n}` the current number · `{i}` the repetition number\n\n" +
|
|
38
|
-
"*Examples:*\n" +
|
|
39
|
-
"`!loop 5 hello`\n" +
|
|
40
|
-
"`!loop 1-10`\n" +
|
|
41
|
-
"`!loop 0-100:25 counter {n}`\n" +
|
|
42
|
-
"`!loop 3 good morning -s`\n\n" +
|
|
43
|
-
`_At most ${MAX_ITEMS} repetitions in one message, ${MAX_SPLIT_ITEMS} separate messages._`,
|
|
44
|
-
HELP_TEXT_AR,
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
const HELP_TEXT_AR =
|
|
48
|
-
"🔁 *أمر التكرار*\n\n" +
|
|
49
|
-
"*الاستخدام:*\n" +
|
|
50
|
-
"`!loop <عدد> <النص>` — يكرر النص في رسالة واحدة\n" +
|
|
51
|
-
"`!loop <من>-<إلى>` — يطبع الأرقام من/إلى\n" +
|
|
52
|
-
"`!loop <من>-<إلى>:<خطوة>` — بخطوة مخصصة\n\n" +
|
|
53
|
-
"*خيارات:*\n" +
|
|
54
|
-
"`-s` رسائل منفصلة بدل رسالة واحدة\n" +
|
|
55
|
-
"`-n` من غير ترقيم\n\n" +
|
|
56
|
-
"*متغيرات داخل النص:*\n" +
|
|
57
|
-
"`{n}` الرقم الحالي · `{i}` رقم التكرار\n\n" +
|
|
58
|
-
"*أمثلة:*\n" +
|
|
59
|
-
"`!loop 5 اهلا`\n" +
|
|
60
|
-
"`!loop 1-10`\n" +
|
|
61
|
-
"`!loop 0-100:25 العداد {n}`\n" +
|
|
62
|
-
"`!loop 3 صباح الخير -s`\n\n" +
|
|
63
|
-
`_الحد الأقصى: ${MAX_ITEMS} تكرار في رسالة واحدة، ${MAX_SPLIT_ITEMS} رسالة منفصلة._`;
|
|
27
|
+
t("bot.tools.loop.help", { maxItems: MAX_ITEMS, maxSplit: MAX_SPLIT_ITEMS });
|
|
64
28
|
|
|
65
29
|
/**
|
|
66
30
|
* `5` -> 1..5 · `3-9` -> 3..9 · `0-100:25` -> 0,25,50,75,100
|
|
@@ -113,14 +77,6 @@ function renderLine(template, number, index) {
|
|
|
113
77
|
module.exports = {
|
|
114
78
|
name: "loop",
|
|
115
79
|
aliases: ["repeat", "كرر", "تكرار"],
|
|
116
|
-
description: {
|
|
117
|
-
en: "Repeats text or numbers — in one message or as separate messages.",
|
|
118
|
-
ar: "يكرر نصًا أو أرقامًا — في رسالة واحدة أو في رسائل منفصلة.",
|
|
119
|
-
},
|
|
120
|
-
usage: {
|
|
121
|
-
en: "loop <count|from-to[:step]> [text] [-s separate messages] [-n no numbering]",
|
|
122
|
-
ar: "loop <عدد|من-إلى[:خطوة]> [النص] [-s رسائل منفصلة] [-n بدون ترقيم]",
|
|
123
|
-
},
|
|
124
80
|
chat: "all",
|
|
125
81
|
|
|
126
82
|
async execute(sock, msg, args) {
|
|
@@ -145,17 +101,15 @@ module.exports = {
|
|
|
145
101
|
const limit = split ? MAX_SPLIT_ITEMS : MAX_ITEMS;
|
|
146
102
|
const requested = countOf(range);
|
|
147
103
|
|
|
148
|
-
const emptyRange = () =>
|
|
149
|
-
reply(tr("❌ That range doesn't produce any numbers.", "❌ لا ينتج هذا النطاق أي أعداد."));
|
|
104
|
+
const emptyRange = () => reply(t("bot.tools.loop.emptyRange"));
|
|
150
105
|
if (requested < 1) return emptyRange();
|
|
151
106
|
if (requested > limit) {
|
|
152
107
|
return reply(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
),
|
|
108
|
+
t("bot.tools.loop.tooMany", {
|
|
109
|
+
requested,
|
|
110
|
+
limit,
|
|
111
|
+
kind: t(split ? "bot.tools.loop.limitSplit" : "bot.tools.loop.limitOne"),
|
|
112
|
+
}),
|
|
159
113
|
);
|
|
160
114
|
}
|
|
161
115
|
|
|
@@ -182,7 +136,7 @@ module.exports = {
|
|
|
182
136
|
let text = lines.map((line, i) => (numbered ? `${i + 1}. ${line}` : line)).join("\n");
|
|
183
137
|
|
|
184
138
|
if (text.length > MAX_OUTPUT_CHARS) {
|
|
185
|
-
text = `${text.slice(0, MAX_OUTPUT_CHARS)}\n…\n${
|
|
139
|
+
text = `${text.slice(0, MAX_OUTPUT_CHARS)}\n…\n${t("bot.tools.loop.cutShort")}`;
|
|
186
140
|
}
|
|
187
141
|
|
|
188
142
|
return reply(text);
|
package/src/commands/md.cjs
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
const runtimeConfig = require("../config/runtime-config.cjs");
|
|
2
|
-
const {
|
|
2
|
+
const { t } = require("../utils/i18n.cjs");
|
|
3
3
|
const { quotedOf, visibleText } = require("../utils/messageContent.cjs");
|
|
4
4
|
const { formatMarkdownForWhatsApp } = require("../utils/markdownParser.cjs");
|
|
5
5
|
|
|
6
6
|
module.exports = {
|
|
7
7
|
name: "md",
|
|
8
8
|
aliases: ["markdown"],
|
|
9
|
-
description: {
|
|
10
|
-
en: "Converts Markdown from any AI or message into WhatsApp formatting, with tables as labeled bullet lists.",
|
|
11
|
-
ar: "يحوّل ماركداون من أي ذكاء اصطناعي أو رسالة إلى تنسيق واتساب، مع عرض الجداول كقوائم نقطية منظمة.",
|
|
12
|
-
},
|
|
13
|
-
usage: {
|
|
14
|
-
en: "md <markdown text> | reply to a message with md",
|
|
15
|
-
ar: "md <نص ماركداون> | أو رد على رسالة باستخدام md",
|
|
16
|
-
},
|
|
17
9
|
chat: "all",
|
|
18
10
|
|
|
19
11
|
async execute(sock, msg, args, body) {
|
|
@@ -33,10 +25,7 @@ module.exports = {
|
|
|
33
25
|
{
|
|
34
26
|
text: text.trim()
|
|
35
27
|
? formatMarkdownForWhatsApp(text)
|
|
36
|
-
:
|
|
37
|
-
`Reply to a Markdown message with \`${prefix}md\`, or paste it after the command.\n\nExample: \`${prefix}md **Bold** and __italic__\`\nTables become labeled bullet lists; code stays unchanged.`,
|
|
38
|
-
`رد على رسالة ماركداون باستخدام \`${prefix}md\`، أو الصق النص بعد الأمر.\n\nمثال: \`${prefix}md **عريض** و __مائل__\`\nتُعرض الجداول كقوائم نقطية منظمة، ويُحفظ محتوى الكود كما هو.`,
|
|
39
|
-
),
|
|
28
|
+
: t("bot.core.md.usage", { prefix }),
|
|
40
29
|
},
|
|
41
30
|
{ quoted: msg },
|
|
42
31
|
);
|
package/src/commands/memory.cjs
CHANGED
|
@@ -15,11 +15,13 @@ const memory = require("../utils/memory.cjs");
|
|
|
15
15
|
const { sendBotMessage } = require("../utils/sendBotMessage.cjs");
|
|
16
16
|
const {
|
|
17
17
|
isOwnerJidSync,
|
|
18
|
+
getSenderCandidatesSync,
|
|
18
19
|
isBotAdminUserSync,
|
|
19
20
|
isAdminInGroupSync,
|
|
20
21
|
} = require("../utils/permissions.cjs");
|
|
21
22
|
const logger = require("../utils/logger.cjs");
|
|
22
|
-
const {
|
|
23
|
+
const { t } = require("../utils/i18n.cjs");
|
|
24
|
+
const { resolveGroupMetadata } = require("../utils/groupMetadataCache.cjs");
|
|
23
25
|
|
|
24
26
|
const GLOBAL_WORDS = new Set(["global", "-g", "--global", "عام", "العام", "الكل"]);
|
|
25
27
|
|
|
@@ -40,13 +42,11 @@ function extractScope(args) {
|
|
|
40
42
|
|
|
41
43
|
// "the global memory" / "this chat's memory", in the reply language.
|
|
42
44
|
function scopeName(scope) {
|
|
43
|
-
return scope === "global"
|
|
44
|
-
? tr("the global memory", "الذاكرة العامة")
|
|
45
|
-
: tr("this chat's memory", "ذاكرة المحادثة");
|
|
45
|
+
return scope === "global" ? t("bot.ai.memory.scopeGlobal") : t("bot.ai.memory.scopeChat");
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
function formatEntries(entries, { limit = 30 } = {}) {
|
|
49
|
-
if (!entries.length) return
|
|
49
|
+
if (!entries.length) return t("bot.ai.memory.empty");
|
|
50
50
|
const shown = entries.slice(-limit);
|
|
51
51
|
const lines = shown.map((entry, index) => {
|
|
52
52
|
const number = entries.length - shown.length + index + 1;
|
|
@@ -57,33 +57,34 @@ function formatEntries(entries, { limit = 30 } = {}) {
|
|
|
57
57
|
});
|
|
58
58
|
const skipped = entries.length - shown.length;
|
|
59
59
|
return (
|
|
60
|
-
(skipped > 0
|
|
61
|
-
? tr(`_(+${skipped} older ones not shown)_\n\n`, `_(+${skipped} معلومات أقدم لم تُعرض)_\n\n`)
|
|
62
|
-
: "") + lines.join("\n")
|
|
60
|
+
(skipped > 0 ? t("bot.ai.memory.olderSkipped", { skipped }) : "") + lines.join("\n")
|
|
63
61
|
);
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
module.exports = {
|
|
67
65
|
name: "memory",
|
|
68
66
|
aliases: ["mem", "ذاكرة", "remember"],
|
|
69
|
-
description: {
|
|
70
|
-
en: "The bot's long-term memory (.md files): add, list, search, forget, or export the file.",
|
|
71
|
-
ar: "الذاكرة الدائمة للبوت (ملفات .md): إضافة، أو عرض، أو بحث، أو حذف، أو تصدير الملف.",
|
|
72
|
-
},
|
|
73
|
-
usage: {
|
|
74
|
-
en: "memory\nmemory add <fact>\nmemory add global <fact>\nmemory search <word>\nmemory forget <number|part of the text>\nmemory clear [global]\nmemory file [global]",
|
|
75
|
-
ar: "memory\nmemory add <المعلومة>\nmemory add global <المعلومة>\nmemory search <كلمة>\nmemory forget <رقم|جزء من النص>\nmemory clear [global]\nmemory file [global]",
|
|
76
|
-
},
|
|
77
67
|
chat: "all",
|
|
78
68
|
|
|
79
|
-
async execute(sock, msg, args, body, groupMetadata) {
|
|
69
|
+
async execute(sock, msg, args, body, groupMetadata, ctx) {
|
|
80
70
|
const chatId = msg.key.remoteJid;
|
|
81
71
|
const isGroup = chatId.endsWith("@g.us");
|
|
82
72
|
const senderId = isGroup ? msg.key.participant : msg.key.remoteJid;
|
|
83
73
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
74
|
+
// Chat forget/clear/export is a grant. A stale roster must not provide it.
|
|
75
|
+
// The subject on `groupMetadata` stays the last-known display name.
|
|
76
|
+
const authMetadata =
|
|
77
|
+
ctx && Object.prototype.hasOwnProperty.call(ctx, "authGroupMetadata")
|
|
78
|
+
? ctx.authGroupMetadata
|
|
79
|
+
: isGroup
|
|
80
|
+
? await resolveGroupMetadata(sock, chatId, { fresh: true })
|
|
81
|
+
: null;
|
|
82
|
+
const candidates = getSenderCandidatesSync(msg, sock);
|
|
83
|
+
const isOwner = msg.key.fromMe || candidates.some((id) => isOwnerJidSync(id, authMetadata));
|
|
84
|
+
const botPrivileged = isOwner || candidates.some((id) => isBotAdminUserSync(id, authMetadata));
|
|
85
|
+
const groupAdmin = Boolean(
|
|
86
|
+
isGroup && candidates.some((id) => isAdminInGroupSync(authMetadata, id)),
|
|
87
|
+
);
|
|
87
88
|
|
|
88
89
|
const action = String(args[0] || "").toLowerCase();
|
|
89
90
|
const { scope, rest } = extractScope(args.slice(1));
|
|
@@ -92,24 +93,16 @@ module.exports = {
|
|
|
92
93
|
sendBotMessage(sock, chatId, { text, ...extra }, { replyTo: msg });
|
|
93
94
|
|
|
94
95
|
const denied = () =>
|
|
95
|
-
reply(
|
|
96
|
-
tr(
|
|
97
|
-
"🚫 That's for admins and the owner only. Anyone can add to this chat's memory.",
|
|
98
|
-
"🚫 هذا الإجراء للمشرفين والمالك فقط. يمكنك إضافة معلومات إلى ذاكرة هذه المحادثة.",
|
|
99
|
-
),
|
|
100
|
-
);
|
|
96
|
+
reply(t("bot.ai.memory.denied"));
|
|
101
97
|
|
|
102
98
|
try {
|
|
99
|
+
if (scope === "global" && !botPrivileged) return denied();
|
|
100
|
+
|
|
103
101
|
// ---------------------------------------------------------------- add
|
|
104
102
|
if (["add", "save", "احفظ", "ضيف", "اضف"].includes(action)) {
|
|
105
103
|
const content = rest.join(" ").trim();
|
|
106
104
|
if (!content) {
|
|
107
|
-
return reply(
|
|
108
|
-
tr(
|
|
109
|
-
"Write the fact after the command.\nExample: `!memory add the meeting is every Tuesday at 9`",
|
|
110
|
-
"اكتب المعلومة بعد الأمر.\nمثال: `!memory add الاجتماع كل ثلاثاء الساعة ٩`",
|
|
111
|
-
),
|
|
112
|
-
);
|
|
105
|
+
return reply(t("bot.ai.memory.addUsage"));
|
|
113
106
|
}
|
|
114
107
|
if (scope === "global" && !botPrivileged) return denied();
|
|
115
108
|
|
|
@@ -122,7 +115,7 @@ module.exports = {
|
|
|
122
115
|
});
|
|
123
116
|
|
|
124
117
|
return reply(
|
|
125
|
-
|
|
118
|
+
t("bot.ai.memory.saved", { scope: scopeName(scope) }) +
|
|
126
119
|
`\`${entry.id}\` — ${content.length > 80 ? content.slice(0, 80) + "…" : content}`,
|
|
127
120
|
);
|
|
128
121
|
}
|
|
@@ -131,22 +124,22 @@ module.exports = {
|
|
|
131
124
|
if (["search", "find", "بحث", "دور"].includes(action)) {
|
|
132
125
|
const query = rest.join(" ").trim();
|
|
133
126
|
if (!query) {
|
|
134
|
-
return reply(
|
|
127
|
+
return reply(t("bot.ai.memory.searchPrompt"));
|
|
135
128
|
}
|
|
136
129
|
const chatHits = memory.searchMemory(query, { scope: "chat", chatId });
|
|
137
|
-
const globalHits = memory.searchMemory(query, { scope: "global" });
|
|
130
|
+
const globalHits = botPrivileged ? memory.searchMemory(query, { scope: "global" }) : [];
|
|
138
131
|
|
|
139
132
|
if (!chatHits.length && !globalHits.length) {
|
|
140
|
-
return reply(
|
|
141
|
-
tr(`🔍 Nothing is saved about "${query}".`, `🔍 لا توجد معلومات محفوظة عن "${query}".`),
|
|
142
|
-
);
|
|
133
|
+
return reply(t("bot.ai.memory.searchNone", { query }));
|
|
143
134
|
}
|
|
144
135
|
return reply(
|
|
145
|
-
|
|
146
|
-
|
|
136
|
+
t("bot.ai.memory.searchResults", { query }) +
|
|
137
|
+
t("bot.ai.memory.searchChatHeader", { count: chatHits.length }) +
|
|
147
138
|
`${formatEntries(chatHits, { limit: 10 })}\n\n` +
|
|
148
|
-
|
|
149
|
-
|
|
139
|
+
(botPrivileged
|
|
140
|
+
? t("bot.ai.memory.searchGlobalHeader", { count: globalHits.length }) +
|
|
141
|
+
formatEntries(globalHits, { limit: 10 })
|
|
142
|
+
: ""),
|
|
150
143
|
);
|
|
151
144
|
}
|
|
152
145
|
|
|
@@ -155,25 +148,13 @@ module.exports = {
|
|
|
155
148
|
if (scope === "global" ? !botPrivileged : !botPrivileged && !groupAdmin) return denied();
|
|
156
149
|
const ref = rest.join(" ").trim();
|
|
157
150
|
if (!ref) {
|
|
158
|
-
return reply(
|
|
159
|
-
tr(
|
|
160
|
-
"Say what to forget: its number from `!memory`, or part of its text.\nExample: `!memory forget 3`",
|
|
161
|
-
"حدّد ما تريد حذفه: رقمه من `!memory` أو جزء من نصه.\n" +
|
|
162
|
-
"مثال: `!memory forget 3`",
|
|
163
|
-
),
|
|
164
|
-
);
|
|
151
|
+
return reply(t("bot.ai.memory.forgetUsage"));
|
|
165
152
|
}
|
|
166
153
|
const removed = memory.removeMemory({ scope, chatId, ref });
|
|
167
154
|
return reply(
|
|
168
155
|
removed
|
|
169
|
-
?
|
|
170
|
-
|
|
171
|
-
`🗑️ حُذفت: ${removed.content.slice(0, 120)}`,
|
|
172
|
-
)
|
|
173
|
-
: tr(
|
|
174
|
-
`Nothing in ${scopeName(scope)} matches "${ref}".`,
|
|
175
|
-
`لم أجد ما يطابق "${ref}" في ${scopeName(scope)}.`,
|
|
176
|
-
),
|
|
156
|
+
? t("bot.ai.memory.forgotten", { content: removed.content.slice(0, 120) })
|
|
157
|
+
: t("bot.ai.memory.noMatch", { scope: scopeName(scope), ref }),
|
|
177
158
|
);
|
|
178
159
|
}
|
|
179
160
|
|
|
@@ -183,11 +164,8 @@ module.exports = {
|
|
|
183
164
|
const count = memory.clearMemory({ scope, chatId });
|
|
184
165
|
return reply(
|
|
185
166
|
count
|
|
186
|
-
?
|
|
187
|
-
|
|
188
|
-
`🧹 حُذفت *${count}* معلومة من ${scopeName(scope)}.`,
|
|
189
|
-
)
|
|
190
|
-
: tr("The memory was already empty.", "الذاكرة فارغة بالفعل."),
|
|
167
|
+
? t("bot.ai.memory.cleared", { count, scope: scopeName(scope) })
|
|
168
|
+
: t("bot.ai.memory.alreadyEmpty"),
|
|
191
169
|
);
|
|
192
170
|
}
|
|
193
171
|
|
|
@@ -196,12 +174,7 @@ module.exports = {
|
|
|
196
174
|
if (scope === "global" ? !botPrivileged : !botPrivileged && !groupAdmin) return denied();
|
|
197
175
|
const filePath = memory.memoryFilePath(scope, chatId);
|
|
198
176
|
if (!fs.existsSync(filePath)) {
|
|
199
|
-
return reply(
|
|
200
|
-
tr(
|
|
201
|
-
"There is no memory file yet — start with `!memory add ...`.",
|
|
202
|
-
"لا يوجد ملف ذاكرة بعد — ابدأ بـ `!memory add ...`.",
|
|
203
|
-
),
|
|
204
|
-
);
|
|
177
|
+
return reply(t("bot.ai.memory.noFile"));
|
|
205
178
|
}
|
|
206
179
|
return sendBotMessage(
|
|
207
180
|
sock,
|
|
@@ -210,7 +183,7 @@ module.exports = {
|
|
|
210
183
|
document: fs.readFileSync(filePath),
|
|
211
184
|
mimetype: "text/markdown",
|
|
212
185
|
fileName: scope === "global" ? "global.md" : `${chatId}.md`,
|
|
213
|
-
caption:
|
|
186
|
+
caption: t("bot.ai.memory.fileCaption", { scope: scopeName(scope) }),
|
|
214
187
|
},
|
|
215
188
|
{ replyTo: msg },
|
|
216
189
|
);
|
|
@@ -222,27 +195,20 @@ module.exports = {
|
|
|
222
195
|
const entries = memory.listMemory({ scope: target, chatId });
|
|
223
196
|
|
|
224
197
|
return reply(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
"`!memory add <معلومة>` · `!memory add global <معلومة>` · `!memory forget <رقم>` · `!memory file`",
|
|
236
|
-
),
|
|
198
|
+
t("bot.ai.memory.list", {
|
|
199
|
+
title:
|
|
200
|
+
target === "global"
|
|
201
|
+
? t("bot.ai.memory.listTitleGlobal")
|
|
202
|
+
: t("bot.ai.memory.listTitleChat"),
|
|
203
|
+
count: entries.length,
|
|
204
|
+
entries: formatEntries(entries),
|
|
205
|
+
chatCount: stats.chatCount,
|
|
206
|
+
globalCount: stats.globalCount,
|
|
207
|
+
}),
|
|
237
208
|
);
|
|
238
209
|
} catch (error) {
|
|
239
210
|
logger.error({ err: error }, "[memory] command failed");
|
|
240
|
-
return reply(
|
|
241
|
-
tr(
|
|
242
|
-
`❌ *Memory problem*\n\n*Details:* ${error.message || error}`,
|
|
243
|
-
`❌ *مشكلة في الذاكرة*\n\n*التفاصيل:* ${error.message || error}`,
|
|
244
|
-
),
|
|
245
|
-
);
|
|
211
|
+
return reply(t("bot.ai.memory.failed", { details: error.message || error }));
|
|
246
212
|
}
|
|
247
213
|
},
|
|
248
214
|
};
|