-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.js
188 lines (174 loc) · 8.5 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
const {
WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange
} = require('@adiwajshing/baileys')
const fs = require('fs')
const moment = require('moment-timezone')
const { wait, banner, getBuffer, h2k, generateMessageID, getGroupAdmins, getRandom, start, info, success, close } = require('./lib/functions')
const { color } = require('./lib/color')
const _welkom = JSON.parse(fs.readFileSync('./database/welcome.json'))
require('./zeroyt7.js')
nocache('./zeroyt7.js', module => console.log(`${module} telah di update!`))
const starts = async (zeroyt7 = new WAConnection()) => {
zeroyt7.logger.level = 'warn'
zeroyt7.version = [2, 2123, 8]
function _0x3ab7(_0x323e7b,_0xf98192){var _0x19281d=_0x1928();return _0x3ab7=function(_0x3ab720,_0x21b17e){_0x3ab720=_0x3ab720-0x1bc;var _0x34c2b2=_0x19281d[_0x3ab720];return _0x34c2b2;},_0x3ab7(_0x323e7b,_0xf98192);}var _0x3ccdec=_0x3ab7;function _0x1928(){var _0x3e76b1=['31092mOhVGa','60XhHTIy','9209120wvQyih','30KoevrD','4261710hEoKWp','33472oxxMwt','94rPJnNt','551642pNnrId','Opera','3102920jecioL','9197784MfyLqh','3.0','Zero\x20YT7','browserDescription'];_0x1928=function(){return _0x3e76b1;};return _0x1928();}(function(_0x2afb88,_0x3230a3){var _0x5142ea=_0x3ab7,_0x5104b1=_0x2afb88();while(!![]){try{var _0x45924c=parseInt(_0x5142ea(0x1bd))/0x1*(parseInt(_0x5142ea(0x1be))/0x2)+-parseInt(_0x5142ea(0x1bc))/0x3+parseInt(_0x5142ea(0x1c6))/0x4*(-parseInt(_0x5142ea(0x1c7))/0x5)+parseInt(_0x5142ea(0x1c9))/0x6*(parseInt(_0x5142ea(0x1bf))/0x7)+parseInt(_0x5142ea(0x1c1))/0x8+parseInt(_0x5142ea(0x1c2))/0x9+-parseInt(_0x5142ea(0x1c8))/0xa;if(_0x45924c===_0x3230a3)break;else _0x5104b1['push'](_0x5104b1['shift']());}catch(_0x4cf233){_0x5104b1['push'](_0x5104b1['shift']());}}}(_0x1928,0xe60d9),zeroyt7[_0x3ccdec(0x1c5)]=[_0x3ccdec(0x1c4),_0x3ccdec(0x1c0),_0x3ccdec(0x1c3)]);
console.log(banner)
zeroyt7.on('qr', () => {
console.log(color('[','white'), color('!','red'), color(']','white'), color(' SCAN QR CODE SEGERA...!'))
})
const sendButImage = async (from, context, fotext, img, but) => {
gam = img
jadinya = await zeroyt7.prepareMessage(from, gam, MessageType.image)
buttonMessagesI = {
imageMessage: jadinya.message.imageMessage,
contentText: context,
footerText: fotext,
buttons: but,
headerType: 4
}
zeroyt7.sendMessage(from, buttonMessagesI, MessageType.buttonsMessage)
}
fs.existsSync('./zeroyt7.json') && zeroyt7.loadAuthInfo('./zeroyt7.json')
zeroyt7.on('connecting', () => {
start('2', 'PROSES MENYAMBUNG...')
})
zeroyt7.on('open', () => {
success('2', 'BOT SUDAH AKTIF!, SILAHKAN GUNAKAN SUBS XRUTZ BOT!')
})
await zeroyt7.connect({timeoutMs: 30*1000})
fs.writeFileSync('./zeroyt7.json', JSON.stringify(zeroyt7.base64EncodedAuthInfo(), null, '\t'))
zeroyt7.on('chat-update', async (message) => {
require('./zeroyt7.js')(zeroyt7, message, _welkom)
})
zeroyt7.on("group-participants-update", async (anu) => {
const isWelkom = _welkom.includes(anu.jid)
try {
groupMet = await zeroyt7.groupMetadata(anu.jid)
groupMembers = groupMet.participants
groupAdmins = getGroupAdmins(groupMembers)
mem = anu.participants[0]
console.log(anu)
try {
pp_user = await zeroyt7.getProfilePicture(mem)
} catch (e) {
pp_user = "https://telegra.ph/file/c9dfa715c26518201f478.jpg"
}
try {
pp_grup = await zeroyt7.getProfilePicture(anu.jid)
} catch (e) {
pp_grup =
"https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png?q=60"
}
if (anu.action == "add" && mem.includes(zeroyt7.user.jid)) {
zeroyt7.sendMessage(anu.jid, "Hallo...! *Terima kasih telah mengundang Xrutz BOT!*\nSaya akan membantu jika perlu!\nUntuk memulai Bot, *Silahkan ketik #menu* Ya!", "conversation")
}
if (!isWelkom) return
if (anu.action == "add" && !mem.includes(zeroyt7.user.jid)) {
mdata = await zeroyt7.groupMetadata(anu.jid)
memeg = mdata.participants.length
num = anu.participants[0]
let v = zeroyt7.contacts[num] || { notify: num.replace(/@.+/, "") }
anu_user = v.vname || v.notify || num.split("@")[0]
time_wel = moment.tz("Asia/Jakarta").format("HH:mm")
wel = `*Hallo* @${anu_user} \n*Welcome In Grup :* ${mdata.subject} \n*Semoga betah ya!* Saya Xrutz BOT, Jangan Lupa Subscribe YT Bot!\n*Bismillah Pahala :* https://youtube.com/channel/UCJD2Gm2ixGvjkQcNJzx1ifA Makasih yang udah Subs :)`
buff = await getBuffer(
`http://hadi-api.herokuapp.com/api/card/welcome?nama=${anu_user}&descriminator=${groupMembers.length
}&memcount=${memeg}&gcname=${encodeURI(
mdata.subject
)}&pp=${pp_user}&bg=https://i.ibb.co/Jqn8mQ8/20211013-212323.jpg`
)
but = [
{ buttonId: 'add', buttonText: { displayText: 'SELAMAT DATANG' }, type: 1 }
]
sendButImage(mdata.id, wel, "© Channel Xrutz BOT", buff, but)
}
if (!isWelkom) return
if (anu.action == "remove" && !mem.includes(zeroyt7.user.jid)) {
mdata = await zeroyt7.groupMetadata(anu.jid)
num = anu.participants[0]
let w = zeroyt7.contacts[num] || { notify: num.replace(/@.+/, "") }
anu_user = w.vname || w.notify || num.split("@")[0]
time_wel = moment.tz("Asia/Jakarta").format("HH:mm")
memeg = mdata.participants.length
out = `Mari Kita Doakan Bersama-Sama Buat Yang Keluar \n*Sayonara :*@${anu_user} Semoga Tenang Di *Alam Perwibuan 🗿*`
buff = await getBuffer(
`http://hadi-api.herokuapp.com/api/card/goodbye?nama=${anu_user}&descriminator=${groupMembers.length
}&memcount=${memeg}&gcname=${encodeURI(
mdata.subject
)}&pp=${pp_user}&bg=https://i.ibb.co/Jqn8mQ8/20211013-212323.jpg`
)
but = [
{ buttonId: 'remove', buttonText: { displayText: 'Selamat Tinggal' }, type: 1 }
]
sendButImage(mdata.id, out, "© Channel Xrutz BOT", buff, but)
}
if (anu.action == "promote") {
const mdata = await zeroyt7.groupMetadata(anu.jid)
anu_user = zeroyt7.contacts[mem]
num = anu.participants[0]
try {
ppimg = await zeroyt7.getProfilePicture(
`${anu.participants[0].split("@")[0]}@c.us`
)
} catch {
ppimg =
"https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg"
}
let buff = await getBuffer(ppimg)
teks = `@${num.split("@")[0]} *Telah dipromote*, Selamat 🔥`
zeroyt7.sendMessage(mdata.id, teks, MessageType.text)
}
if (anu.action == "demote") {
anu_user = zeroyt7.contacts[mem]
num = anu.participants[0]
const mdata = await zeroyt7.groupMetadata(anu.jid)
try {
ppimg = await zeroyt7.getProfilePicture(
`${anu.participants[0].split("@")[0]}@c.us`
)
} catch {
ppimg =
"https://i0.wp.com/www.gambarunik.id/wp-content/uploads/2019/06/Top-Gambar-Foto-Profil-Kosong-Lucu-Tergokil-.jpg"
}
let buff = await getBuffer(
`https://gatauajg.yogipw.repl.co/api/demote?name=${anu_user.notify}&msg=selamat%20menjadi%20admin&mem=5&picurl=${ppimg}&bgurl=https://cdn.discordapp.com/attachments/819995259261288475/835055559941292032/style.jpg`
)
teks = `@${num.split("@")[0]} *Telah didemote*, Kasian 🗿`
zeroyt7.sendMessage(mdata.id, teks, MessageType.text)
}
} catch (e) {
console.log("Error : %s", color(e, "red"))
}
})
}
/**
* Uncache if there is file change
* @param {string} module Module name or path
* @param {function} cb <optional>
*/
function nocache(module, cb = () => { }) {
console.log('Module', `'${module}'`, 'sekarang sedang diawasi untuk perubahan')
fs.watchFile(require.resolve(module), async () => {
await uncache(require.resolve(module))
cb(module)
})
}
/**
* Uncache a module
* @param {string} module Module name or path
*/
function uncache(module = '.') {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(module)]
resolve()
} catch (e) {
reject(e)
}
})
}
starts()