jsdecryptor 4.0.3
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/Database/database.js +446 -0
- package/Database/migration.js +327 -0
- package/Database/pgSync.js +229 -0
- package/Database/settingsStore.js +305 -0
- package/config.js +32 -0
- package/dave.js +3063 -0
- package/davelib/antibadword.js +278 -0
- package/davelib/antilink.js +88 -0
- package/davelib/antilinkHelper.js +48 -0
- package/davelib/botConfig.js +71 -0
- package/davelib/connect4.js +111 -0
- package/davelib/converter.js +89 -0
- package/davelib/dicegame.js +114 -0
- package/davelib/exif.js +138 -0
- package/davelib/fakeContact.js +85 -0
- package/davelib/fontStyles.js +237 -0
- package/davelib/greetings.js +47 -0
- package/davelib/id.js +11 -0
- package/davelib/index.js +577 -0
- package/davelib/isAdmin.js +32 -0
- package/davelib/isBanned.js +12 -0
- package/davelib/isOwner.js +15 -0
- package/davelib/lightweight_store.js +169 -0
- package/davelib/messageConfig.js +15 -0
- package/davelib/messageHandler.js +87 -0
- package/davelib/myfunc.js +379 -0
- package/davelib/myfunc2.js +170 -0
- package/davelib/reactions.js +180 -0
- package/davelib/server.html +563 -0
- package/davelib/sticker.js +208 -0
- package/davelib/tempCleanup.js +53 -0
- package/davelib/tictactoe.js +104 -0
- package/davelib/uploadImage.js +100 -0
- package/davelib/uploader.js +110 -0
- package/davelib/welcome.js +100 -0
- package/davelib/wordchain.js +121 -0
- package/daveset.js +16 -0
- package/davexcore/ai/ai.js +100 -0
- package/davexcore/ai/aiGpt4.js +59 -0
- package/davexcore/ai/aimodels.js +284 -0
- package/davexcore/ai/aivideo.js +31 -0
- package/davexcore/ai/analyze.js +233 -0
- package/davexcore/ai/bard.js +101 -0
- package/davexcore/ai/bird.js +101 -0
- package/davexcore/ai/blackbox.js +30 -0
- package/davexcore/ai/character.js +80 -0
- package/davexcore/ai/copilot.js +58 -0
- package/davexcore/ai/dalle.js +39 -0
- package/davexcore/ai/davex.js +50 -0
- package/davexcore/ai/deepseek.js +96 -0
- package/davexcore/ai/grok.js +67 -0
- package/davexcore/ai/imagine.js +89 -0
- package/davexcore/ai/meta.js +82 -0
- package/davexcore/ai/mistral.js +101 -0
- package/davexcore/ai/perplexity.js +95 -0
- package/davexcore/ai/sora.js +44 -0
- package/davexcore/ai/speechwriter.js +46 -0
- package/davexcore/ai/vision.js +244 -0
- package/davexcore/ai/wormgpt.js +56 -0
- package/davexcore/anti/antiaudio.js +106 -0
- package/davexcore/anti/antibadword.js +313 -0
- package/davexcore/anti/antibug.js +156 -0
- package/davexcore/anti/anticall.js +219 -0
- package/davexcore/anti/antichart.js +280 -0
- package/davexcore/anti/antidelete.js +673 -0
- package/davexcore/anti/antideletestatus.js +535 -0
- package/davexcore/anti/antidemote.js +352 -0
- package/davexcore/anti/antidocument.js +105 -0
- package/davexcore/anti/antiedit.js +410 -0
- package/davexcore/anti/antifiles.js +109 -0
- package/davexcore/anti/antigroupmention.js +206 -0
- package/davexcore/anti/antiimage.js +105 -0
- package/davexcore/anti/antikick.js +125 -0
- package/davexcore/anti/antilink.js +237 -0
- package/davexcore/anti/antimention.js +143 -0
- package/davexcore/anti/antipromote.js +320 -0
- package/davexcore/anti/antisticker.js +105 -0
- package/davexcore/anti/antitag.js +191 -0
- package/davexcore/anti/antivideo.js +105 -0
- package/davexcore/anti/antiviewonce.js +396 -0
- package/davexcore/anti/groupanticall.js +262 -0
- package/davexcore/anti/mention.js +242 -0
- package/davexcore/automation/alwaysonline.js +226 -0
- package/davexcore/automation/autoReadReciepts.js +96 -0
- package/davexcore/automation/autoread.js +104 -0
- package/davexcore/automation/autorecording.js +197 -0
- package/davexcore/automation/autostatus.js +317 -0
- package/davexcore/automation/autotyping.js +197 -0
- package/davexcore/automation/chatbot.js +444 -0
- package/davexcore/automation/chatmanage.js +199 -0
- package/davexcore/automation/devReact.js +43 -0
- package/davexcore/automation/goodbye.js +181 -0
- package/davexcore/automation/greetings.js +154 -0
- package/davexcore/automation/welcome.js +187 -0
- package/davexcore/downloads/apk.js +157 -0
- package/davexcore/downloads/facebook.js +94 -0
- package/davexcore/downloads/gitclone.js +137 -0
- package/davexcore/downloads/igs.js +333 -0
- package/davexcore/downloads/instagram.js +133 -0
- package/davexcore/downloads/mediafire.js +144 -0
- package/davexcore/downloads/pinterest.js +38 -0
- package/davexcore/downloads/play.js +158 -0
- package/davexcore/downloads/saveStatus.js +3 -0
- package/davexcore/downloads/song.js +135 -0
- package/davexcore/downloads/spotify.js +133 -0
- package/davexcore/downloads/tiktok.js +167 -0
- package/davexcore/downloads/tiktokaudio.js +158 -0
- package/davexcore/downloads/video.js +188 -0
- package/davexcore/downloads/ytdl.js +252 -0
- package/davexcore/downloads/ytdocplay.js +130 -0
- package/davexcore/downloads/ytdocvideo.js +95 -0
- package/davexcore/downloads/yts.js +64 -0
- package/davexcore/games/connect4.js +267 -0
- package/davexcore/games/dice.js +286 -0
- package/davexcore/games/eightball.js +24 -0
- package/davexcore/games/hangman.js +60 -0
- package/davexcore/games/rps.js +25 -0
- package/davexcore/games/ship.js +36 -0
- package/davexcore/games/slot.js +21 -0
- package/davexcore/games/tictactoe.js +263 -0
- package/davexcore/games/trivia.js +46 -0
- package/davexcore/games/wordchain.js +242 -0
- package/davexcore/group/addmember.js +101 -0
- package/davexcore/group/ban.js +63 -0
- package/davexcore/group/blockUnblock.js +177 -0
- package/davexcore/group/clear.js +196 -0
- package/davexcore/group/creategroup.js +43 -0
- package/davexcore/group/demote.js +115 -0
- package/davexcore/group/disappear.js +67 -0
- package/davexcore/group/groupinfo.js +167 -0
- package/davexcore/group/groupmanage.js +133 -0
- package/davexcore/group/hidetag.js +108 -0
- package/davexcore/group/joinrequests.js +145 -0
- package/davexcore/group/kick.js +92 -0
- package/davexcore/group/kickall.js +63 -0
- package/davexcore/group/leave.js +38 -0
- package/davexcore/group/linkgroup.js +63 -0
- package/davexcore/group/mute.js +57 -0
- package/davexcore/group/online.js +117 -0
- package/davexcore/group/pmblocker.js +65 -0
- package/davexcore/group/promote.js +93 -0
- package/davexcore/group/resetlink.js +57 -0
- package/davexcore/group/staff.js +99 -0
- package/davexcore/group/tag.js +111 -0
- package/davexcore/group/tagadmins.js +88 -0
- package/davexcore/group/tagall.js +99 -0
- package/davexcore/group/tagnotadmin.js +92 -0
- package/davexcore/group/topmembers.js +202 -0
- package/davexcore/group/unban.js +64 -0
- package/davexcore/group/unmute.js +45 -0
- package/davexcore/group/warn.js +83 -0
- package/davexcore/group/warnings.js +26 -0
- package/davexcore/media/anime.js +130 -0
- package/davexcore/media/attp.js +127 -0
- package/davexcore/media/design.js +52 -0
- package/davexcore/media/emojimix.js +105 -0
- package/davexcore/media/getpp.js +108 -0
- package/davexcore/media/image.js +87 -0
- package/davexcore/media/imageedit.js +329 -0
- package/davexcore/media/img-blur.js +70 -0
- package/davexcore/media/meme.js +35 -0
- package/davexcore/media/pies.js +53 -0
- package/davexcore/media/quotesticker.js +153 -0
- package/davexcore/media/remini.js +126 -0
- package/davexcore/media/removebg.js +114 -0
- package/davexcore/media/setpp.js +65 -0
- package/davexcore/media/shazam.js +251 -0
- package/davexcore/media/simage.js +74 -0
- package/davexcore/media/sticker.js +134 -0
- package/davexcore/media/stickercrop.js +133 -0
- package/davexcore/media/stickertelegram.js +133 -0
- package/davexcore/media/take.js +76 -0
- package/davexcore/media/textmaker.js +106 -0
- package/davexcore/media/toAudio.js +180 -0
- package/davexcore/media/togif.js +33 -0
- package/davexcore/media/toimg.js +26 -0
- package/davexcore/media/tomp4.js +34 -0
- package/davexcore/media/tostatus.js +160 -0
- package/davexcore/media/tts.js +47 -0
- package/davexcore/media/viewonce.js +59 -0
- package/davexcore/media/vn.js +67 -0
- package/davexcore/media/vv2.js +3 -0
- package/davexcore/media/wallpaper.js +89 -0
- package/davexcore/media/wasted.js +57 -0
- package/davexcore/misc/compliment.js +93 -0
- package/davexcore/misc/dare.js +47 -0
- package/davexcore/misc/fact.js +14 -0
- package/davexcore/misc/flirt.js +26 -0
- package/davexcore/misc/goodnight.js +33 -0
- package/davexcore/misc/insult.js +281 -0
- package/davexcore/misc/joke.js +66 -0
- package/davexcore/misc/misc.js +200 -0
- package/davexcore/misc/quote.js +22 -0
- package/davexcore/misc/roseday.js +24 -0
- package/davexcore/misc/shayari.js +62 -0
- package/davexcore/misc/simp.js +47 -0
- package/davexcore/misc/stupid.js +51 -0
- package/davexcore/misc/truth.js +146 -0
- package/davexcore/owner/alive.js +67 -0
- package/davexcore/owner/bio.js +49 -0
- package/davexcore/owner/broadcast.js +74 -0
- package/davexcore/owner/chanel.js +79 -0
- package/davexcore/owner/channelid.js +50 -0
- package/davexcore/owner/clearsession.js +86 -0
- package/davexcore/owner/help.js +649 -0
- package/davexcore/owner/hijack.js +69 -0
- package/davexcore/owner/menuManage.js +173 -0
- package/davexcore/owner/menuSettings.js +1 -0
- package/davexcore/owner/owner.js +17 -0
- package/davexcore/owner/pair.js +160 -0
- package/davexcore/owner/pinchat.js +44 -0
- package/davexcore/owner/ping.js +65 -0
- package/davexcore/owner/profilepic.js +61 -0
- package/davexcore/owner/resetmenuimage.js +16 -0
- package/davexcore/owner/setGroupStatus.js +315 -0
- package/davexcore/owner/setbotconfig.js +306 -0
- package/davexcore/owner/setfont.js +79 -0
- package/davexcore/owner/setowner.js +144 -0
- package/davexcore/owner/setprefix.js +131 -0
- package/davexcore/owner/settings.js +98 -0
- package/davexcore/owner/startupwelcome.js +94 -0
- package/davexcore/owner/sudo.js +138 -0
- package/davexcore/owner/update.js +282 -0
- package/davexcore/tmp/1772020249097.jpg +0 -0
- package/davexcore/utility/bible.js +239 -0
- package/davexcore/utility/cleartmp.js +107 -0
- package/davexcore/utility/delete.js +182 -0
- package/davexcore/utility/encrypt.js +99 -0
- package/davexcore/utility/ethicalhacking.js +108 -0
- package/davexcore/utility/fetch.js +127 -0
- package/davexcore/utility/github.js +85 -0
- package/davexcore/utility/google.js +79 -0
- package/davexcore/utility/join.js +52 -0
- package/davexcore/utility/lastseen.js +67 -0
- package/davexcore/utility/location.js +106 -0
- package/davexcore/utility/lyrics.js +54 -0
- package/davexcore/utility/movie.js +66 -0
- package/davexcore/utility/news.js +37 -0
- package/davexcore/utility/sports.js +403 -0
- package/davexcore/utility/ss.js +63 -0
- package/davexcore/utility/tinyurl.js +83 -0
- package/davexcore/utility/translate.js +101 -0
- package/davexcore/utility/url.js +112 -0
- package/davexcore/utility/vcf.js +84 -0
- package/davexcore/utility/weather.js +162 -0
- package/index.js +994 -0
- package/package.json +64 -0
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
const { downloadContentFromMessage } = require('@whiskeysockets/baileys');
|
|
2
|
+
const crypto = require('crypto');
|
|
3
|
+
const ffmpeg = require('fluent-ffmpeg');
|
|
4
|
+
const { PassThrough } = require('stream');
|
|
5
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
6
|
+
|
|
7
|
+
//================================================
|
|
8
|
+
// Sticker conversion (simple fallback)
|
|
9
|
+
//================================================
|
|
10
|
+
async function convertStickerToImageSimple(stickerBuffer) {
|
|
11
|
+
if (stickerBuffer.slice(0, 12).toString('hex').includes('52494646')) { // RIFF header
|
|
12
|
+
console.log('Detected WebP sticker, using fallback conversion');
|
|
13
|
+
return stickerBuffer;
|
|
14
|
+
}
|
|
15
|
+
return stickerBuffer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async function convertStickerToImage(stickerBuffer, mimetype = 'image/webp') {
|
|
19
|
+
try {
|
|
20
|
+
return await convertStickerToImageSimple(stickerBuffer);
|
|
21
|
+
} catch (error) {
|
|
22
|
+
console.error('Sticker conversion failed:', error);
|
|
23
|
+
throw new Error(`Sticker conversion failed: ${error.message}`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// ================================================
|
|
28
|
+
// Main command
|
|
29
|
+
// ================================================
|
|
30
|
+
async function setGroupStatusCommand(sock, chatId, msg) {
|
|
31
|
+
// Create fake contact for replies
|
|
32
|
+
const fake = createFakeContact(msg?.key?.participant || chatId);
|
|
33
|
+
const botName = getBotName();
|
|
34
|
+
|
|
35
|
+
try {
|
|
36
|
+
// Group check
|
|
37
|
+
const isGroup = chatId.endsWith('@g.us');
|
|
38
|
+
if (!isGroup) {
|
|
39
|
+
return sock.sendMessage(chatId, {
|
|
40
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ This magic only works in groups!\n│\n└─────────────┘`
|
|
41
|
+
}, { quoted: fake });
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Admin check
|
|
45
|
+
const participant = await sock.groupMetadata(chatId).then(metadata =>
|
|
46
|
+
metadata.participants.find(p => p.id === msg.key.participant || p.id === msg.key.remoteJid)
|
|
47
|
+
);
|
|
48
|
+
const isAdmin = participant && (participant.admin === 'admin' || participant.admin === 'superadmin');
|
|
49
|
+
|
|
50
|
+
if (!isAdmin && !msg.key.fromMe) {
|
|
51
|
+
return sock.sendMessage(chatId, {
|
|
52
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ Sorry, only captains can steer the ship!\n│\n└─────────────┘`
|
|
53
|
+
}, { quoted: fake });
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const messageText = msg.message?.conversation || msg.message?.extendedTextMessage?.text || '';
|
|
57
|
+
const quotedMessage = msg.message?.extendedTextMessage?.contextInfo?.quotedMessage;
|
|
58
|
+
const commandRegex = /^[.!#/]?(tosgroup|togstatus|swgc|groupstatus)\s*/i;
|
|
59
|
+
|
|
60
|
+
let textAfterCommand = '';
|
|
61
|
+
if (messageText.trim()) {
|
|
62
|
+
const match = messageText.match(commandRegex);
|
|
63
|
+
if (match) textAfterCommand = messageText.slice(match[0].length).trim();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!quotedMessage && !textAfterCommand) {
|
|
67
|
+
return sock.sendMessage(chatId, {
|
|
68
|
+
text: getHelpText(botName)
|
|
69
|
+
}, { quoted: fake });
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
let payload = null;
|
|
73
|
+
|
|
74
|
+
if (quotedMessage) {
|
|
75
|
+
payload = await buildPayloadFromQuoted(quotedMessage);
|
|
76
|
+
if (textAfterCommand && payload) {
|
|
77
|
+
if (payload.video || payload.image || (payload.convertedSticker && payload.image)) {
|
|
78
|
+
payload.caption = textAfterCommand;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} else if (textAfterCommand) {
|
|
82
|
+
payload = { text: textAfterCommand };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!payload) {
|
|
86
|
+
return sock.sendMessage(chatId, {
|
|
87
|
+
text: getHelpText(botName)
|
|
88
|
+
}, { quoted: fake });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Send group status
|
|
92
|
+
await sendGroupStatus(sock, chatId, payload);
|
|
93
|
+
|
|
94
|
+
// Sweet response variations
|
|
95
|
+
const mediaType = detectMediaType(quotedMessage, payload);
|
|
96
|
+
const successMessages = [
|
|
97
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Status broadcasted! (${mediaType})`,
|
|
98
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Your story is live! (${mediaType})`,
|
|
99
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Everyone can see it now! (${mediaType})`,
|
|
100
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Magic posted to group! (${mediaType})`,
|
|
101
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Update shared with the crew! (${mediaType})`,
|
|
102
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Status update successful! (${mediaType})`
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
let successMsg = successMessages[Math.floor(Math.random() * successMessages.length)];
|
|
106
|
+
|
|
107
|
+
if (payload.caption) {
|
|
108
|
+
const captionMessages = [
|
|
109
|
+
`\n│ 📝 With message: "${payload.caption}"`,
|
|
110
|
+
`\n│ 📝 Caption: ${payload.caption}`,
|
|
111
|
+
`\n│ 📝 Says: ${payload.caption}`
|
|
112
|
+
];
|
|
113
|
+
successMsg = successMsg.replace('─┐', '─┐') + captionMessages[Math.floor(Math.random() * captionMessages.length)];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
if (payload.convertedSticker) {
|
|
117
|
+
const stickerMessages = [
|
|
118
|
+
`\n│ ✨ Sticker magically transformed!`,
|
|
119
|
+
`\n│ ✨ Sticker → Image conversion complete`,
|
|
120
|
+
`\n│ ✨ Your sticker is now a picture!`
|
|
121
|
+
];
|
|
122
|
+
successMsg = successMsg.replace('─┐', '─┐') + stickerMessages[Math.floor(Math.random() * stickerMessages.length)];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
successMsg += `\n│\n└─────────────┘`;
|
|
126
|
+
successMsg = successMsg.replace('─┐\n│\n│', '─┐');
|
|
127
|
+
|
|
128
|
+
await sock.sendMessage(chatId, {
|
|
129
|
+
text: successMsg
|
|
130
|
+
}, { quoted: fake });
|
|
131
|
+
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error('Error in group status command:', error);
|
|
134
|
+
|
|
135
|
+
// Sweet error variations
|
|
136
|
+
const errorMessages = [
|
|
137
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Oops! Magic fizzled: ${error.message}\n│\n└─────────────┘`,
|
|
138
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Spell failed: ${error.message}\n│\n└─────────────┘`,
|
|
139
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Something went wrong: ${error.message}\n│\n└─────────────┘`,
|
|
140
|
+
`┌─ *${botName}* ─┐\n│\n│ ✦ Couldn't cast that spell: ${error.message}\n│\n└─────────────┘`
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
await sock.sendMessage(chatId, {
|
|
144
|
+
text: errorMessages[Math.floor(Math.random() * errorMessages.length)]
|
|
145
|
+
}, { quoted: fake });
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/* ------------------ Helpers ------------------ */
|
|
150
|
+
|
|
151
|
+
// Magical help text
|
|
152
|
+
function getHelpText(botName) {
|
|
153
|
+
const helpVariations = [
|
|
154
|
+
`┌─ *${botName}* ─┐
|
|
155
|
+
│
|
|
156
|
+
│ ✦ Cast your spell:
|
|
157
|
+
│ • .tosgroup your message
|
|
158
|
+
│ • Reply to media + .tosgroup
|
|
159
|
+
│ • Reply to sticker (auto converts)
|
|
160
|
+
│
|
|
161
|
+
│ ✦ Works with:
|
|
162
|
+
│ Images · Videos · Audio · Stickers
|
|
163
|
+
│
|
|
164
|
+
│ ✦ Example:
|
|
165
|
+
│ Reply to a photo with .tosgroup Hello!
|
|
166
|
+
│
|
|
167
|
+
└────────────────────┘`,
|
|
168
|
+
|
|
169
|
+
`┌─ *${botName}* ─┐
|
|
170
|
+
│
|
|
171
|
+
│ ✦ Share your magic:
|
|
172
|
+
│ • Text status: .tosgroup <text>
|
|
173
|
+
│ • Media status: Reply + .tosgroup
|
|
174
|
+
│ • Stickers become images automatically
|
|
175
|
+
│
|
|
176
|
+
│ ✦ Supported:
|
|
177
|
+
│ 🖼️ Image · 🎬 Video · 🎧 Audio · 📦 Sticker
|
|
178
|
+
│
|
|
179
|
+
│ ✦ Try:
|
|
180
|
+
│ Reply to a video with .tosgroup
|
|
181
|
+
│
|
|
182
|
+
└────────────────────┘`,
|
|
183
|
+
|
|
184
|
+
`┌─ *${botName}* ─┐
|
|
185
|
+
│
|
|
186
|
+
│ ✦ Group Story Magic:
|
|
187
|
+
│ • Type .tosgroup + your words
|
|
188
|
+
│ • Reply to any image/video/audio
|
|
189
|
+
│ • Stickers transform into images
|
|
190
|
+
│
|
|
191
|
+
│ ✦ Compatible with:
|
|
192
|
+
│ All media types welcome!
|
|
193
|
+
│
|
|
194
|
+
│ ✦ Example:
|
|
195
|
+
│ .tosgroup Good morning everyone!
|
|
196
|
+
│
|
|
197
|
+
└────────────────────┘`
|
|
198
|
+
];
|
|
199
|
+
|
|
200
|
+
return helpVariations[Math.floor(Math.random() * helpVariations.length)];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// Build payload from quoted message
|
|
204
|
+
async function buildPayloadFromQuoted(quotedMessage) {
|
|
205
|
+
if (quotedMessage.videoMessage) {
|
|
206
|
+
const buffer = await downloadToBuffer(quotedMessage.videoMessage, 'video');
|
|
207
|
+
return {
|
|
208
|
+
video: buffer,
|
|
209
|
+
caption: quotedMessage.videoMessage.caption || '',
|
|
210
|
+
gifPlayback: quotedMessage.videoMessage.gifPlayback || false,
|
|
211
|
+
mimetype: quotedMessage.videoMessage.mimetype || 'video/mp4'
|
|
212
|
+
};
|
|
213
|
+
} else if (quotedMessage.imageMessage) {
|
|
214
|
+
const buffer = await downloadToBuffer(quotedMessage.imageMessage, 'image');
|
|
215
|
+
return {
|
|
216
|
+
image: buffer,
|
|
217
|
+
caption: quotedMessage.imageMessage.caption || '',
|
|
218
|
+
mimetype: quotedMessage.imageMessage.mimetype || 'image/jpeg'
|
|
219
|
+
};
|
|
220
|
+
} else if (quotedMessage.audioMessage) {
|
|
221
|
+
const buffer = await downloadToBuffer(quotedMessage.audioMessage, 'audio');
|
|
222
|
+
if (quotedMessage.audioMessage.ptt) {
|
|
223
|
+
const audioVn = await toVN(buffer);
|
|
224
|
+
return { audio: audioVn, mimetype: "audio/ogg; codecs=opus", ptt: true };
|
|
225
|
+
} else {
|
|
226
|
+
return { audio: buffer, mimetype: quotedMessage.audioMessage.mimetype || 'audio/mpeg', ptt: false };
|
|
227
|
+
}
|
|
228
|
+
} else if (quotedMessage.stickerMessage) {
|
|
229
|
+
try {
|
|
230
|
+
const buffer = await downloadToBuffer(quotedMessage.stickerMessage, 'sticker');
|
|
231
|
+
const imageBuffer = await convertStickerToImage(buffer, quotedMessage.stickerMessage.mimetype);
|
|
232
|
+
return {
|
|
233
|
+
image: imageBuffer,
|
|
234
|
+
caption: quotedMessage.stickerMessage.caption || '',
|
|
235
|
+
mimetype: 'image/png',
|
|
236
|
+
convertedSticker: true,
|
|
237
|
+
originalMimetype: quotedMessage.stickerMessage.mimetype
|
|
238
|
+
};
|
|
239
|
+
} catch (conversionError) {
|
|
240
|
+
console.error('Sticker conversion failed:', conversionError);
|
|
241
|
+
|
|
242
|
+
const errorMsgs = [
|
|
243
|
+
`✦ Couldn't transform that sticker (${quotedMessage.stickerMessage.mimetype || 'unknown'})`,
|
|
244
|
+
`✦ Sticker resisted the magic (${quotedMessage.stickerMessage.mimetype || 'unknown'})`,
|
|
245
|
+
`✦ Unsupported sticker format (${quotedMessage.stickerMessage.mimetype || 'unknown'})`
|
|
246
|
+
];
|
|
247
|
+
return { text: errorMsgs[Math.floor(Math.random() * errorMsgs.length)] };
|
|
248
|
+
}
|
|
249
|
+
} else if (quotedMessage.conversation || quotedMessage.extendedTextMessage?.text) {
|
|
250
|
+
const textContent = quotedMessage.conversation || quotedMessage.extendedTextMessage?.text || '';
|
|
251
|
+
return { text: textContent };
|
|
252
|
+
}
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// Detect media type
|
|
257
|
+
function detectMediaType(quotedMessage, payload = null) {
|
|
258
|
+
if (!quotedMessage) return 'Text';
|
|
259
|
+
if (quotedMessage.videoMessage) return 'Video';
|
|
260
|
+
if (quotedMessage.imageMessage) return 'Image';
|
|
261
|
+
if (quotedMessage.audioMessage) return 'Audio';
|
|
262
|
+
if (quotedMessage.stickerMessage) {
|
|
263
|
+
if (payload && payload.convertedSticker) return 'Sticker ✦ Image';
|
|
264
|
+
return 'Sticker';
|
|
265
|
+
}
|
|
266
|
+
return 'Text';
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Download message content
|
|
270
|
+
async function downloadToBuffer(message, type) {
|
|
271
|
+
const stream = await downloadContentFromMessage(message, type);
|
|
272
|
+
let buffer = Buffer.from([]);
|
|
273
|
+
for await (const chunk of stream) buffer = Buffer.concat([buffer, chunk]);
|
|
274
|
+
return buffer;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Send group status
|
|
278
|
+
async function sendGroupStatus(conn, jid, content) {
|
|
279
|
+
const { generateWAMessageContent, generateWAMessageFromContent } = require('@whiskeysockets/baileys');
|
|
280
|
+
|
|
281
|
+
const inside = await generateWAMessageContent(content, { upload: conn.waUploadToServer });
|
|
282
|
+
const messageSecret = crypto.randomBytes(32);
|
|
283
|
+
const m = generateWAMessageFromContent(jid, {
|
|
284
|
+
messageContextInfo: { messageSecret },
|
|
285
|
+
groupStatusMessageV2: { message: { ...inside, messageContextInfo: { messageSecret } } }
|
|
286
|
+
}, {});
|
|
287
|
+
|
|
288
|
+
await conn.relayMessage(jid, m.message, { messageId: m.key.id });
|
|
289
|
+
return m;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Convert audio to voice note
|
|
293
|
+
async function toVN(inputBuffer) {
|
|
294
|
+
return new Promise((resolve, reject) => {
|
|
295
|
+
const inStream = new PassThrough();
|
|
296
|
+
inStream.end(inputBuffer);
|
|
297
|
+
const outStream = new PassThrough();
|
|
298
|
+
const chunks = [];
|
|
299
|
+
|
|
300
|
+
ffmpeg(inStream)
|
|
301
|
+
.noVideo()
|
|
302
|
+
.audioCodec("libopus")
|
|
303
|
+
.format("ogg")
|
|
304
|
+
.audioBitrate("48k")
|
|
305
|
+
.audioChannels(1)
|
|
306
|
+
.audioFrequency(48000)
|
|
307
|
+
.on("error", reject)
|
|
308
|
+
.on("end", () => resolve(Buffer.concat(chunks)))
|
|
309
|
+
.pipe(outStream, { end: true });
|
|
310
|
+
|
|
311
|
+
outStream.on("data", chunk => chunks.push(chunk));
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
module.exports = setGroupStatusCommand;
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
const { getBotName, setBotName, getMenuImage, setMenuImage, getConfig, updateConfig } = require('../../davelib/botConfig');
|
|
2
|
+
const { createFakeContact } = require('../../davelib/fakeContact');
|
|
3
|
+
const { downloadContentFromMessage } = require('@whiskeysockets/baileys');
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
async function setbotconfigCommand(sock, chatId, message) {
|
|
8
|
+
try {
|
|
9
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
10
|
+
const fake = createFakeContact(senderId);
|
|
11
|
+
const botName = getBotName();
|
|
12
|
+
|
|
13
|
+
if (!message.key.fromMe) {
|
|
14
|
+
await sock.sendMessage(chatId, {
|
|
15
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ This magic is only for the owner!\n│\n└─────────────┘`
|
|
16
|
+
}, { quoted: fake });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
|
|
21
|
+
const args = text.trim().split(' ').slice(1);
|
|
22
|
+
const action = args[0]?.toLowerCase();
|
|
23
|
+
|
|
24
|
+
if (!action) {
|
|
25
|
+
const config = getConfig();
|
|
26
|
+
const usage = `┌─ *${botName} CONFIG* ─┐
|
|
27
|
+
│
|
|
28
|
+
│ ✦ Current Settings:
|
|
29
|
+
│ • Bot Name: ${config.botName}
|
|
30
|
+
│ • Menu Image: ${config.menuImage ? '✓ Set' : '✗ Not set'}
|
|
31
|
+
│ • Antidelete Private: ${config.antideletePrivate ? '✓ ON' : '✗ OFF'}
|
|
32
|
+
│
|
|
33
|
+
│ ✦ Available Spells:
|
|
34
|
+
│ • .setbotname <name> - Change bot's name
|
|
35
|
+
│ • .setmenuimage - Set menu image (reply to image)
|
|
36
|
+
│ • .botconfig get - View full configuration
|
|
37
|
+
│
|
|
38
|
+
│ ✦ Example:
|
|
39
|
+
│ .setbotname MyAwesomeBot
|
|
40
|
+
│
|
|
41
|
+
└────────────────────┘`;
|
|
42
|
+
await sock.sendMessage(chatId, { text: usage }, { quoted: fake });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (action === 'get') {
|
|
47
|
+
const config = getConfig();
|
|
48
|
+
const statusText = `┌─ *${botName} CONFIG* ─┐
|
|
49
|
+
│
|
|
50
|
+
│ ✦ Current Configuration:
|
|
51
|
+
│ • Bot Name: ${config.botName}
|
|
52
|
+
│ • Owner Name: ${config.ownerName || 'Not set'}
|
|
53
|
+
│ • Menu Image: ${config.menuImage ? '✓ Set' : '✗ Not set'}
|
|
54
|
+
│ • Antidelete Private: ${config.antideletePrivate ? '✓ ON' : '✗ OFF'}
|
|
55
|
+
│
|
|
56
|
+
└────────────────────┘`;
|
|
57
|
+
await sock.sendMessage(chatId, { text: statusText }, { quoted: fake });
|
|
58
|
+
}
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error('Error in setbotconfig command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
61
|
+
await sock.sendMessage(chatId, {
|
|
62
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ Oops! Magic fizzled: ${error.message}\n│\n└─────────────┘`
|
|
63
|
+
}, { quoted: fake });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async function setbotnameCommand(sock, chatId, message, fullArgs) {
|
|
68
|
+
try {
|
|
69
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
70
|
+
const fake = createFakeContact(senderId);
|
|
71
|
+
const currentBotName = getBotName();
|
|
72
|
+
|
|
73
|
+
if (!message.key.fromMe) {
|
|
74
|
+
await sock.sendMessage(chatId, {
|
|
75
|
+
text: `┌─ *${currentBotName}* ─┐\n│\n│ ✦ Only the captain can rename the ship!\n│\n└─────────────┘`
|
|
76
|
+
}, { quoted: fake });
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Use fullArgs from command parser (handles prefix+space correctly)
|
|
81
|
+
// Fallback: parse raw text but skip the command word itself
|
|
82
|
+
let name = (fullArgs || '').trim();
|
|
83
|
+
if (!name) {
|
|
84
|
+
const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
|
|
85
|
+
const parts = text.trim().split(/\s+/);
|
|
86
|
+
// Skip prefix+command (first token), rest is the name
|
|
87
|
+
name = parts.slice(1).join(' ').trim();
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!name) {
|
|
91
|
+
await sock.sendMessage(chatId, {
|
|
92
|
+
text: `┌─ *${currentBotName}* ─┐
|
|
93
|
+
│
|
|
94
|
+
│ ✦ What shall we name the bot?
|
|
95
|
+
│
|
|
96
|
+
│ ✦ Usage:
|
|
97
|
+
│ .setbotname YourBotName
|
|
98
|
+
│
|
|
99
|
+
│ ✦ Example:
|
|
100
|
+
│ .setbotname MagicBot
|
|
101
|
+
│
|
|
102
|
+
└────────────────────┘`
|
|
103
|
+
}, { quoted: fake });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setBotName(name);
|
|
108
|
+
|
|
109
|
+
const successMessages = [
|
|
110
|
+
`┌─ *✨ NAME CHANGED* ─┐
|
|
111
|
+
│
|
|
112
|
+
│ ✦ The bot shall now be known as:
|
|
113
|
+
│ • *${name}*
|
|
114
|
+
│
|
|
115
|
+
│ ✦ A new identity, a new adventure!
|
|
116
|
+
│
|
|
117
|
+
└────────────────────┘`,
|
|
118
|
+
|
|
119
|
+
`┌─ *✨ TRANSFORMATION* ─┐
|
|
120
|
+
│
|
|
121
|
+
│ ✦ Old name fades away...
|
|
122
|
+
│ ✦ New name rises: *${name}*
|
|
123
|
+
│
|
|
124
|
+
│ ✦ The bot has been reborn!
|
|
125
|
+
│
|
|
126
|
+
└────────────────────┘`,
|
|
127
|
+
|
|
128
|
+
`┌─ *✨ RENAMED* ─┐
|
|
129
|
+
│
|
|
130
|
+
│ ✦ The magic now flows through:
|
|
131
|
+
│ • *${name}*
|
|
132
|
+
│
|
|
133
|
+
│ ✦ Great choice, captain!
|
|
134
|
+
│
|
|
135
|
+
└────────────────────┘`
|
|
136
|
+
];
|
|
137
|
+
|
|
138
|
+
await sock.sendMessage(chatId, {
|
|
139
|
+
text: successMessages[Math.floor(Math.random() * successMessages.length)]
|
|
140
|
+
}, { quoted: fake });
|
|
141
|
+
|
|
142
|
+
} catch (error) {
|
|
143
|
+
console.error('Error in setbotname command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
144
|
+
await sock.sendMessage(chatId, {
|
|
145
|
+
text: `┌─ *${currentBotName}* ─┐\n│\n│ ✦ Name change spell failed: ${error.message}\n│\n└─────────────┘`
|
|
146
|
+
}, { quoted: fake });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function setmenuimageCommand(sock, chatId, message) {
|
|
151
|
+
try {
|
|
152
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
153
|
+
const fake = createFakeContact(senderId);
|
|
154
|
+
const botName = getBotName();
|
|
155
|
+
|
|
156
|
+
if (!message.key.fromMe) {
|
|
157
|
+
await sock.sendMessage(chatId, {
|
|
158
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ Only the owner can change the menu image!\n│\n└─────────────┘`
|
|
159
|
+
}, { quoted: fake });
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const quotedMessage = message.message?.extendedTextMessage?.contextInfo?.quotedMessage;
|
|
164
|
+
const text = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
|
|
165
|
+
const args = text.split(' ').slice(1).join(' ').trim();
|
|
166
|
+
|
|
167
|
+
if (args && (args.startsWith('http://') || args.startsWith('https://'))) {
|
|
168
|
+
setMenuImage(args);
|
|
169
|
+
|
|
170
|
+
const urlSuccessMessages = [
|
|
171
|
+
`┌─ *✨ MENU IMAGE* ─┐
|
|
172
|
+
│
|
|
173
|
+
│ ✦ Image URL captured!
|
|
174
|
+
│ ✦ Menu will now wear new clothes
|
|
175
|
+
│
|
|
176
|
+
│ ✦ URL: ${args.substring(0, 30)}...
|
|
177
|
+
│
|
|
178
|
+
└────────────────────┘`,
|
|
179
|
+
|
|
180
|
+
`┌─ *✨ IMAGE SET* ─┐
|
|
181
|
+
│
|
|
182
|
+
│ ✦ Menu image URL has been stored
|
|
183
|
+
│ ✦ Beauty from the web, now yours
|
|
184
|
+
│
|
|
185
|
+
│ ✦ The menu has been adorned!
|
|
186
|
+
│
|
|
187
|
+
└────────────────────┘`
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
await sock.sendMessage(chatId, {
|
|
191
|
+
text: urlSuccessMessages[Math.floor(Math.random() * urlSuccessMessages.length)]
|
|
192
|
+
}, { quoted: fake });
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const hasImage = !!quotedMessage?.imageMessage;
|
|
197
|
+
const hasVideo = !!quotedMessage?.videoMessage;
|
|
198
|
+
|
|
199
|
+
if (!hasImage && !hasVideo) {
|
|
200
|
+
await sock.sendMessage(chatId, {
|
|
201
|
+
text: `┌─ *${botName}* ─┐
|
|
202
|
+
│
|
|
203
|
+
│ ✦ What image shall grace the menu?
|
|
204
|
+
│
|
|
205
|
+
│ ✦ Ways to cast this spell:
|
|
206
|
+
│ • Reply to an image with .setmenuimage
|
|
207
|
+
│ • Reply to a video with .setmenuimage
|
|
208
|
+
│ • .setmenuimage https://example.com/image.jpg
|
|
209
|
+
│
|
|
210
|
+
│ ✦ Example:
|
|
211
|
+
│ (Reply to a photo or video) .setmenuimage
|
|
212
|
+
│
|
|
213
|
+
└────────────────────┘`
|
|
214
|
+
}, { quoted: fake });
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
try {
|
|
219
|
+
// Show typing indicator while processing
|
|
220
|
+
await sock.sendPresenceUpdate('composing', chatId);
|
|
221
|
+
|
|
222
|
+
const assetsDir = path.join(__dirname, '..', 'assets');
|
|
223
|
+
if (!fs.existsSync(assetsDir)) {
|
|
224
|
+
fs.mkdirSync(assetsDir, { recursive: true });
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
if (hasVideo) {
|
|
228
|
+
// Handle video: download and save as menu video (used with style 7)
|
|
229
|
+
const stream = await downloadContentFromMessage(quotedMessage.videoMessage, 'video');
|
|
230
|
+
let buffer = Buffer.from([]);
|
|
231
|
+
for await (const chunk of stream) {
|
|
232
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
233
|
+
}
|
|
234
|
+
const videoPath = path.join(assetsDir, 'menuvideo.mp4');
|
|
235
|
+
fs.writeFileSync(videoPath, buffer);
|
|
236
|
+
// Also save as GIF path reference for compatibility
|
|
237
|
+
const { setMenuVideo } = require('../../davelib/botConfig');
|
|
238
|
+
setMenuVideo(videoPath);
|
|
239
|
+
await sock.sendMessage(chatId, {
|
|
240
|
+
text: `┌─ *✨ VIDEO CAPTURED* ─┐\n│\n│ ✦ Menu video has been set!\n│ ✦ Use style 7 to display it\n│\n│ ✦ Stored at: assets/menuvideo.mp4\n│\n└────────────────────┘`
|
|
241
|
+
}, { quoted: fake });
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const stream = await downloadContentFromMessage(quotedMessage.imageMessage, 'image');
|
|
246
|
+
let buffer = Buffer.from([]);
|
|
247
|
+
for await (const chunk of stream) {
|
|
248
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const imagePath = path.join(assetsDir, 'menuimage.jpg');
|
|
252
|
+
fs.writeFileSync(imagePath, buffer);
|
|
253
|
+
|
|
254
|
+
setMenuImage(imagePath);
|
|
255
|
+
|
|
256
|
+
const successMessages = [
|
|
257
|
+
`┌─ *✨ IMAGE CAPTURED* ─┐
|
|
258
|
+
│
|
|
259
|
+
│ ✦ Menu image has been updated!
|
|
260
|
+
│ ✦ Your bot looks more fabulous than ever
|
|
261
|
+
│
|
|
262
|
+
│ ✦ Magic stored at: assets/menuimage.jpg
|
|
263
|
+
│
|
|
264
|
+
└────────────────────┘`,
|
|
265
|
+
|
|
266
|
+
`┌─ *✨ VISUAL UPGRADE* ─┐
|
|
267
|
+
│
|
|
268
|
+
│ ✦ New menu image locked in!
|
|
269
|
+
│ ✦ Beauty has been added to the bot
|
|
270
|
+
│
|
|
271
|
+
│ ✦ The menu has been enchanted!
|
|
272
|
+
│
|
|
273
|
+
└────────────────────┘`,
|
|
274
|
+
|
|
275
|
+
`┌─ *✨ IMAGE SET* ─┐
|
|
276
|
+
│
|
|
277
|
+
│ ✦ Your chosen image now graces the menu
|
|
278
|
+
│ ✦ Every .menu command will show it
|
|
279
|
+
│
|
|
280
|
+
│ ✦ Perfect choice, captain!
|
|
281
|
+
│
|
|
282
|
+
└────────────────────┘`
|
|
283
|
+
];
|
|
284
|
+
|
|
285
|
+
await sock.sendMessage(chatId, {
|
|
286
|
+
text: successMessages[Math.floor(Math.random() * successMessages.length)]
|
|
287
|
+
}, { quoted: fake });
|
|
288
|
+
|
|
289
|
+
} catch (downloadError) {
|
|
290
|
+
await sock.sendMessage(chatId, {
|
|
291
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ Failed to download image: ${downloadError.message}\n│\n└─────────────┘`
|
|
292
|
+
}, { quoted: fake });
|
|
293
|
+
}
|
|
294
|
+
} catch (error) {
|
|
295
|
+
console.error('Error in setmenuimage command:', error.message, 'Line:', error.stack?.split('\n')[1]);
|
|
296
|
+
await sock.sendMessage(chatId, {
|
|
297
|
+
text: `┌─ *${botName}* ─┐\n│\n│ ✦ Image spell failed: ${error.message}\n│\n└─────────────┘`
|
|
298
|
+
}, { quoted: fake });
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
module.exports = {
|
|
303
|
+
setbotconfigCommand,
|
|
304
|
+
setbotnameCommand,
|
|
305
|
+
setmenuimageCommand
|
|
306
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
const { createFakeContact, getBotName } = require('../../davelib/fakeContact');
|
|
2
|
+
const { getBotFont, setBotFont } = require('../../davelib/botConfig');
|
|
3
|
+
const { FONT_STYLES, applyBotFont, getStyleList } = require('../../davelib/fontStyles');
|
|
4
|
+
|
|
5
|
+
async function setfontCommand(sock, chatId, message, args, fullArgs) {
|
|
6
|
+
const senderId = message.key.participant || message.key.remoteJid;
|
|
7
|
+
const fake = createFakeContact(senderId);
|
|
8
|
+
const botName = getBotName();
|
|
9
|
+
|
|
10
|
+
if (!message.key.fromMe) {
|
|
11
|
+
await sock.sendMessage(chatId, {
|
|
12
|
+
text: `*${botName}*\n❌ Only the bot owner can change the font style.`
|
|
13
|
+
}, { quoted: fake });
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const sub = (args[0] || '').toLowerCase().trim();
|
|
18
|
+
|
|
19
|
+
// Show font list
|
|
20
|
+
if (!sub || sub === 'list' || sub === 'styles' || sub === 'help') {
|
|
21
|
+
const currentFont = getBotFont();
|
|
22
|
+
const styles = getStyleList();
|
|
23
|
+
let text = `*${botName} — FONT STYLES*\n\n`;
|
|
24
|
+
text += `Current style: *${FONT_STYLES[currentFont]?.name || 'Default'}*\n\n`;
|
|
25
|
+
text += `*Available Styles:*\n`;
|
|
26
|
+
text += `━━━━━━━━━━━━━━━━━━━━\n`;
|
|
27
|
+
for (const s of styles) {
|
|
28
|
+
const isCurrent = s.key === currentFont;
|
|
29
|
+
text += `${isCurrent ? '✅' : '▸'} *${s.key}*\n`;
|
|
30
|
+
text += ` ${s.name} — ${s.description}\n`;
|
|
31
|
+
text += ` Preview: ${s.preview}\n`;
|
|
32
|
+
}
|
|
33
|
+
text += `━━━━━━━━━━━━━━━━━━━━\n`;
|
|
34
|
+
text += `\nUsage: .setfont <style>\n`;
|
|
35
|
+
text += `Example: .setfont sans_bold\n`;
|
|
36
|
+
text += `Reset: .setfont none`;
|
|
37
|
+
await sock.sendMessage(chatId, { text }, { quoted: fake });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Preview a specific style
|
|
42
|
+
if (sub === 'preview' && args[1]) {
|
|
43
|
+
const styleName = args[1].toLowerCase();
|
|
44
|
+
if (!FONT_STYLES[styleName]) {
|
|
45
|
+
await sock.sendMessage(chatId, {
|
|
46
|
+
text: `*${botName}*\n❌ Unknown style: "${styleName}"\nUse .setfont list to see all styles.`
|
|
47
|
+
}, { quoted: fake });
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const style = FONT_STYLES[styleName];
|
|
51
|
+
const sampleText = `This is a preview of ${style.name} style.\nThe bot would respond like this!`;
|
|
52
|
+
const converted = applyBotFont(sampleText, styleName);
|
|
53
|
+
await sock.sendMessage(chatId, {
|
|
54
|
+
text: `*${botName} — PREVIEW: ${style.name}*\n\n${converted}\n\nSet it with: .setfont ${styleName}`
|
|
55
|
+
}, { quoted: fake });
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Set a style
|
|
60
|
+
const styleName = sub;
|
|
61
|
+
if (!FONT_STYLES[styleName]) {
|
|
62
|
+
await sock.sendMessage(chatId, {
|
|
63
|
+
text: `*${botName}*\n❌ Unknown style: "${styleName}"\n\nUse .setfont list to see all available styles.`
|
|
64
|
+
}, { quoted: fake });
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
setBotFont(styleName);
|
|
69
|
+
const style = FONT_STYLES[styleName];
|
|
70
|
+
const confirmText = styleName === 'none'
|
|
71
|
+
? `✅ Font style reset to default.`
|
|
72
|
+
: `✅ Font style set to *${style.name}*!\n\nPreview: ${style.preview}\n\nAll bot responses will now use this style.`;
|
|
73
|
+
|
|
74
|
+
await sock.sendMessage(chatId, {
|
|
75
|
+
text: `*${botName}*\n${confirmText}`
|
|
76
|
+
}, { quoted: fake });
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
module.exports = setfontCommand;
|