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,170 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
6
|
+
return (mod && mod.__esModule) ? mod : { "default": mod }
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true })
|
|
9
|
+
|
|
10
|
+
const axios = require("axios")
|
|
11
|
+
const cheerio = require("cheerio")
|
|
12
|
+
const { resolve } = require("path")
|
|
13
|
+
const util = require("util")
|
|
14
|
+
let BodyForm = require('form-data')
|
|
15
|
+
let { fromBuffer } = require('file-type')
|
|
16
|
+
//let fetch = require('node-fetch')
|
|
17
|
+
let fs = require('fs')
|
|
18
|
+
const child_process = require('child_process')
|
|
19
|
+
const ffmpeg = require('fluent-ffmpeg')
|
|
20
|
+
|
|
21
|
+
const {unlink } = require ('fs').promises
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
exports.sleep = async (ms) => {
|
|
25
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
26
|
+
}
|
|
27
|
+
exports.fetchJson = async (url, options) => {
|
|
28
|
+
try {
|
|
29
|
+
options ? options : {}
|
|
30
|
+
const res = await axios({
|
|
31
|
+
method: 'GET',
|
|
32
|
+
url: url,
|
|
33
|
+
headers: {
|
|
34
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
|
|
35
|
+
},
|
|
36
|
+
...options
|
|
37
|
+
})
|
|
38
|
+
return res.data
|
|
39
|
+
} catch (err) {
|
|
40
|
+
return err
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.fetchBuffer = async (url, options) => {
|
|
44
|
+
try {
|
|
45
|
+
options ? options : {}
|
|
46
|
+
const res = await axios({
|
|
47
|
+
method: "GET",
|
|
48
|
+
url,
|
|
49
|
+
headers: {
|
|
50
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36",
|
|
51
|
+
'DNT': 1,
|
|
52
|
+
'Upgrade-Insecure-Request': 1
|
|
53
|
+
},
|
|
54
|
+
...options,
|
|
55
|
+
responseType: 'arraybuffer'
|
|
56
|
+
})
|
|
57
|
+
return res.data
|
|
58
|
+
} catch (err) {
|
|
59
|
+
return err
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.webp2mp4File=async(path) =>{
|
|
63
|
+
return new Promise((resolve, reject) => {
|
|
64
|
+
const form = new BodyForm()
|
|
65
|
+
form.append('new-image-url', '')
|
|
66
|
+
form.append('new-image', fs.createReadStream(path))
|
|
67
|
+
axios({
|
|
68
|
+
method: 'post',
|
|
69
|
+
url: 'https://s6.ezgif.com/webp-to-mp4',
|
|
70
|
+
data: form,
|
|
71
|
+
headers: {
|
|
72
|
+
'Content-Type': `multipart/form-data; boundary=${form._boundary}`
|
|
73
|
+
}
|
|
74
|
+
}).then(({ data }) => {
|
|
75
|
+
const bodyFormThen = new BodyForm()
|
|
76
|
+
const $ = cheerio.load(data)
|
|
77
|
+
const file = $('input[name="file"]').attr('value')
|
|
78
|
+
bodyFormThen.append('file', file)
|
|
79
|
+
bodyFormThen.append('convert', "Convert WebP to MP4!")
|
|
80
|
+
axios({
|
|
81
|
+
method: 'post',
|
|
82
|
+
url: 'https://ezgif.com/webp-to-mp4/' + file,
|
|
83
|
+
data: bodyFormThen,
|
|
84
|
+
headers: {
|
|
85
|
+
'Content-Type': `multipart/form-data; boundary=${bodyFormThen._boundary}`
|
|
86
|
+
}
|
|
87
|
+
}).then(({ data }) => {
|
|
88
|
+
const $ = cheerio.load(data)
|
|
89
|
+
const result = 'https:' + $('div#output > p.outfile > video > source').attr('src')
|
|
90
|
+
resolve({
|
|
91
|
+
status: true,
|
|
92
|
+
message: "Created By Eternity",
|
|
93
|
+
result: result
|
|
94
|
+
})
|
|
95
|
+
}).catch(reject)
|
|
96
|
+
}).catch(reject)
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
exports.fetchUrl = async (url, options) => {
|
|
101
|
+
try {
|
|
102
|
+
options ? options : {}
|
|
103
|
+
const res = await axios({
|
|
104
|
+
method: 'GET',
|
|
105
|
+
url: url,
|
|
106
|
+
headers: {
|
|
107
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36'
|
|
108
|
+
},
|
|
109
|
+
...options
|
|
110
|
+
})
|
|
111
|
+
return res.data
|
|
112
|
+
} catch (err) {
|
|
113
|
+
return err
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
exports.WAVersion = async () => {
|
|
118
|
+
let get = await exports.fetchUrl("https://web.whatsapp.com/check-update?version=1&platform=web")
|
|
119
|
+
let version = [get.currentVersion.replace(/[.]/g, ", ")]
|
|
120
|
+
return version
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
exports.getRandom = (ext) => {
|
|
124
|
+
return `${Math.floor(Math.random() * 10000)}${ext}`
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
exports.isUrl = (url) => {
|
|
128
|
+
return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/, 'gi'))
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
exports.isNumber = (number) => {
|
|
132
|
+
const int = parseInt(number)
|
|
133
|
+
return typeof int === 'number' && !isNaN(int)
|
|
134
|
+
}
|
|
135
|
+
exports.TelegraPh= (Path) =>{
|
|
136
|
+
return new Promise (async (resolve, reject) => {
|
|
137
|
+
if (!fs.existsSync(Path)) return reject(new Error("File not Found"))
|
|
138
|
+
try {
|
|
139
|
+
const form = new BodyForm();
|
|
140
|
+
form.append("file", fs.createReadStream(Path))
|
|
141
|
+
const data = await axios({
|
|
142
|
+
url: "https://telegra.ph/upload",
|
|
143
|
+
method: "POST",
|
|
144
|
+
headers: {
|
|
145
|
+
...form.getHeaders()
|
|
146
|
+
},
|
|
147
|
+
data: form
|
|
148
|
+
})
|
|
149
|
+
return resolve("https://telegra.ph" + data.data[0].src)
|
|
150
|
+
} catch (err) {
|
|
151
|
+
return reject(new Error(String(err)))
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
}
|
|
155
|
+
const sleepy = async (ms) => {
|
|
156
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
157
|
+
}
|
|
158
|
+
exports.buffergif = async (image) => {
|
|
159
|
+
|
|
160
|
+
const filename = `${Math.random().toString(36)}`
|
|
161
|
+
await fs.writeFileSync(`./XeonMedia/trash/${filename}.gif`, image)
|
|
162
|
+
child_process.exec(
|
|
163
|
+
`ffmpeg -i ./XeonMedia/trash/${filename}.gif -movflags faststart -pix_fmt yuv420p -vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" ./XeonMedia/trash/${filename}.mp4`
|
|
164
|
+
)
|
|
165
|
+
await sleepy(4000)
|
|
166
|
+
|
|
167
|
+
var buffer5 = await fs.readFileSync(`./XeonMedia/trash/${filename}.mp4`)
|
|
168
|
+
Promise.all([unlink(`./XeonMedia/video/${filename}.mp4`), unlink(`./XeonMedia/gif/${filename}.gif`)])
|
|
169
|
+
return buffer5
|
|
170
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
const { getOwnerConfig, setOwnerConfig } = require('../Database/settingsStore');
|
|
2
|
+
|
|
3
|
+
const defaultEmojis = ['š', 'š', 'š„°', 'š','š','š'];
|
|
4
|
+
|
|
5
|
+
function loadAutoReactionState() {
|
|
6
|
+
try {
|
|
7
|
+
const config = getOwnerConfig('autoReaction');
|
|
8
|
+
if (config && typeof config === 'object') {
|
|
9
|
+
return {
|
|
10
|
+
enabled: config.enabled || false,
|
|
11
|
+
customReactions: Array.isArray(config.customReactions)
|
|
12
|
+
? config.customReactions
|
|
13
|
+
: defaultEmojis
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.error('Error loading auto-reaction state:', error);
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
enabled: false,
|
|
21
|
+
customReactions: defaultEmojis
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function saveAutoReactionState(state, customReactions = null) {
|
|
26
|
+
try {
|
|
27
|
+
const current = loadAutoReactionState();
|
|
28
|
+
|
|
29
|
+
const reactionsToSave = Array.isArray(customReactions)
|
|
30
|
+
? customReactions
|
|
31
|
+
: current.customReactions;
|
|
32
|
+
|
|
33
|
+
const newConfig = {
|
|
34
|
+
enabled: state,
|
|
35
|
+
customReactions: reactionsToSave
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
setOwnerConfig('autoReaction', newConfig);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
console.error('Error saving auto-reaction state:', error);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function refreshAutoReactionConfig() {
|
|
45
|
+
autoReactionConfig = loadAutoReactionState();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Store auto-reaction state
|
|
49
|
+
let autoReactionConfig = loadAutoReactionState();
|
|
50
|
+
|
|
51
|
+
// Function to get random emoji from custom reactions
|
|
52
|
+
function getRandomEmoji() {
|
|
53
|
+
const reactions = autoReactionConfig.customReactions;
|
|
54
|
+
// Additional safety check to ensure it's an array
|
|
55
|
+
if (!Array.isArray(reactions) || reactions.length === 0) {
|
|
56
|
+
return defaultEmojis[Math.floor(Math.random() * defaultEmojis.length)];
|
|
57
|
+
}
|
|
58
|
+
return reactions[Math.floor(Math.random() * reactions.length)];
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Function to add reaction to a command message
|
|
62
|
+
async function addCommandReaction(sock, message) {
|
|
63
|
+
try {
|
|
64
|
+
if (!autoReactionConfig.enabled || !message?.key?.id) return;
|
|
65
|
+
|
|
66
|
+
const emoji = getRandomEmoji();
|
|
67
|
+
await sock.sendMessage(message.key.remoteJid, {
|
|
68
|
+
react: {
|
|
69
|
+
text: emoji,
|
|
70
|
+
key: message.key
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error adding command reaction:', error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Function to handle areact command
|
|
79
|
+
async function handleAreactCommand(sock, chatId, message, isOwner) {
|
|
80
|
+
try {
|
|
81
|
+
if (!isOwner) {
|
|
82
|
+
await sock.sendMessage(chatId, {
|
|
83
|
+
text: 'ā This command is only available for the owner!',
|
|
84
|
+
quoted: message
|
|
85
|
+
});
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const messageText = message.message?.conversation || message.message?.extendedTextMessage?.text || '';
|
|
90
|
+
const args = messageText.split(' ');
|
|
91
|
+
const action = args[1]?.toLowerCase();
|
|
92
|
+
|
|
93
|
+
if (action === 'on') {
|
|
94
|
+
autoReactionConfig.enabled = true;
|
|
95
|
+
saveAutoReactionState(true, autoReactionConfig.customReactions);
|
|
96
|
+
await sock.sendMessage(chatId, {
|
|
97
|
+
text: 'ā
Auto-reactions have been enabled globally\n\nCustom reactions will be used for all commands!',
|
|
98
|
+
quoted: message
|
|
99
|
+
});
|
|
100
|
+
} else if (action === 'off') {
|
|
101
|
+
autoReactionConfig.enabled = false;
|
|
102
|
+
saveAutoReactionState(false, autoReactionConfig.customReactions);
|
|
103
|
+
await sock.sendMessage(chatId, {
|
|
104
|
+
text: 'ā
Auto-reactions have been disabled globally',
|
|
105
|
+
quoted: message
|
|
106
|
+
});
|
|
107
|
+
} else if (action === 'set') {
|
|
108
|
+
// Handle custom reaction setting
|
|
109
|
+
const customReactions = args.slice(2);
|
|
110
|
+
|
|
111
|
+
if (customReactions.length === 0) {
|
|
112
|
+
await sock.sendMessage(chatId, {
|
|
113
|
+
text: 'ā Please provide at least one emoji!\n\nExample: `.areact set š š ā`',
|
|
114
|
+
quoted: message
|
|
115
|
+
});
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// Validate emojis (basic check)
|
|
120
|
+
const validEmojis = customReactions.filter(emoji =>
|
|
121
|
+
emoji.length <= 4 && /[\p{Emoji}]/u.test(emoji)
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
if (validEmojis.length === 0) {
|
|
125
|
+
await sock.sendMessage(chatId, {
|
|
126
|
+
text: 'ā Please provide valid emojis!',
|
|
127
|
+
quoted: message
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
autoReactionConfig.customReactions = validEmojis;
|
|
133
|
+
saveAutoReactionState(autoReactionConfig.enabled, validEmojis);
|
|
134
|
+
|
|
135
|
+
await sock.sendMessage(chatId, {
|
|
136
|
+
text: `ā
Custom reactions updated!\n\nNew reactions: ${validEmojis.join(' ')}\n\nAuto-reactions are currently ${autoReactionConfig.enabled ? 'enabled' : 'disabled'}`},
|
|
137
|
+
{ quoted: message
|
|
138
|
+
});
|
|
139
|
+
} else if (action === 'reset') {
|
|
140
|
+
// Reset to default reactions
|
|
141
|
+
autoReactionConfig.customReactions = defaultEmojis;
|
|
142
|
+
saveAutoReactionState(autoReactionConfig.enabled, defaultEmojis);
|
|
143
|
+
|
|
144
|
+
await sock.sendMessage(chatId, {
|
|
145
|
+
text: `ā
Custom reactions reset to default!\n\nDefault reactions: ${defaultEmojis.join(' ')}`,
|
|
146
|
+
quoted: message
|
|
147
|
+
});
|
|
148
|
+
} else if (action === 'list') {
|
|
149
|
+
// Show current custom reactions
|
|
150
|
+
const currentReactions = autoReactionConfig.customReactions.join(' ');
|
|
151
|
+
await sock.sendMessage(chatId, {
|
|
152
|
+
text: `š Current custom reactions:\n\n${currentReactions}\n\nAuto-reactions are ${autoReactionConfig.enabled ? 'ā
enabled' : 'ā disabled'}`,
|
|
153
|
+
quoted: message
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
// Show help
|
|
157
|
+
const currentState = autoReactionConfig.enabled ? 'enabled' : 'disabled';
|
|
158
|
+
const currentReactions = autoReactionConfig.customReactions.join(' ');
|
|
159
|
+
|
|
160
|
+
await sock.sendMessage(chatId, {
|
|
161
|
+
text: `āļø Auto-reactions are currently **${currentState}** globally.\n\nš Current reactions: ${currentReactions}\n\n**Commands:**\n⢠\`.areact on\` - Enable auto-reactions\n⢠\`.areact off\` - Disable auto-reactions\n⢠\`.areact set <emojis>\` - Set custom reactions\n⢠\`.areact reset\` - Reset to default reactions\n⢠\`.areact list\` - Show current reactions\n\n**Example:**\n\`.areact set š š ā š«\``},
|
|
162
|
+
{ quoted: message
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
} catch (error) {
|
|
166
|
+
console.error('Error handling areact command:', error);
|
|
167
|
+
await sock.sendMessage(chatId, {
|
|
168
|
+
text: 'ā Error controlling auto-reactions',
|
|
169
|
+
quoted: message
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
module.exports = {
|
|
175
|
+
addCommandReaction,
|
|
176
|
+
handleAreactCommand,
|
|
177
|
+
refreshAutoReactionConfig,
|
|
178
|
+
getAutoReactionConfig: () => autoReactionConfig,
|
|
179
|
+
defaultEmojis
|
|
180
|
+
};
|