-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathmain.js
More file actions
236 lines (222 loc) · 13.1 KB
/
main.js
File metadata and controls
236 lines (222 loc) · 13.1 KB
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
const {
WAConnection: _WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange
} = require('@adiwajshing/baileys')
const { color, bgcolor } = require('./lib/color')
const fs = require("fs-extra")
const simple = require('./lib/simple.js')
const WAConnection = simple.WAConnection(_WAConnection)
const brightcolor = require('colors');
const encodeUrl = require('encodeurl')
const chalk = require('chalk')
const moment = require("moment-timezone")
const figlet = require('figlet')
const gcdetect = JSON.parse(fs.readFileSync('./database/gcdetect.json'))
const { exec } = require('child_process')
const { wait, simih, getBuffer, h2k, generateMessageID, getGroupAdmins, getRandom, banner, start, info, success, close } = require('./lib/functions')
const settings = JSON.parse(fs.readFileSync('./settings.json'))
const sleep = async (ms) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
const time = moment.tz('Asia/Jakarta').format('HH:mm:ss')
const wita = moment.tz('Asia/Makassar').format('HH:mm:ss')
const wit = moment.tz('Asia/Jayapura').format('HH:mm:ss')
//nocache
nocache('./FardanConnect.js', module => console.log(color('|UPDATE BASE|'), color(`${module} Updated!`, 'red')))
const starts = async (Fardan = new WAConnection()) => {
Fardan.logger.level = 'warn'
Fardan.version = [2, 2142, 12]
console.log(color(`\x1b[1;37m> Base New\n`,'red'))
console.log(color(figlet.textSync('Fax Dev', {
font: 'Standard',
horizontalLayout: 'default',
vertivalLayout: 'default',
width: 80,
whitespaceBreak: false
}), 'yellow'))
console.log(color('\n> GitHub : ','red'), color(`FaxBotz`,'white'))
console.log(color('> YouTube : ','red'), color(`Fax Botz`,'white'))
console.log(color('\n\n\n Big Thanks To\n\n','orange'), color(`Allah SWT\nFardan Ganz\nMy Family\nFardan Ilham\n\nFaxBotz`,'purple'))
Fardan.browserDescription = [ 'Fax Ganteng', 'ubuntu', '3.0' ]
Fardan.on('qr', () => {
console.log(color('Fax Botz','yellow'), color('New','yellow'), color('Base','yellow'), color('[ Scan QR Nya ]'))
})
Fardan.on('credentials-updated', () => {
fs.writeFileSync('./session.json', JSON.stringify(Fardan.base64EncodedAuthInfo(), null, '\t'))
info('2', 'Fax Botz')
})
fs.existsSync('./session.json') && Fardan.loadAuthInfo('./session.json')
Fardan.on('connecting', () => {
start('2', 'NewBase')
})
Fardan.on('open', () => {
success('2', 'Done, Welcome Owner🎯')
})
// session
await Fardan.connect({
timeoutMs: 30 * 1000
})
fs.writeFileSync(`./session.json`, JSON.stringify(Fardan.base64EncodedAuthInfo(), null, '\t'))
if (!settings.autoplaymusic) {
exec(`cd /sdcard/download && play *mp3`)
}
Fardan.on('chat-update', async (mek) => {
require('./FardanConnect.js')(Fardan, mek)
ownerNumber = ["6281523940672@s.whatsapp.net","6281523940672@s.whatsapp.net",`${settings.NomorOwner}@s.whatsapp.net`]
dtod = "6281523940672@s.whatsapp.net"
otod = `${settings.NomorOwner}@s.whatsapp.net`
})
//SERAH LU MAU GANTI KYK MANA
Fardan.on('group-participants-update', async (anu) => {
mem = anu.participants[0]
const mdata = await Fardan.groupMetadata(anu.jid)
try {
console.log(anu)
if (anu.action == 'add') {
const welkom = JSON.parse(fs.readFileSync('./database/welkom.json'))
if(!welkom.includes(mdata.id)) return
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;Fardan;;;\nFN:Fardan\nitem1.TEL;waid=6281337541779:6281337541779\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
num = anu.participants[0]
try {
ppimg = await Fardan.getProfilePicture(`${num.split('@')[0]}@c.us`)
} catch {
ppimg = 'https://api-helgazex.herokuapp.com/api/canvas/welcome2?username=${pushname}&groupname=${mdata.subject}&membercount=-&profile=${ppimg}&background=${ppimg}&apikey=kfL8EfHc'
}
let buff = await getBuffer(ppimg)
masuk =`Halo @${num.split('@')[0]}\nSelamat Datang Di ${mdata.subject}\n\n*Jangan Lupa Isi*\n*Nama* :\n*Umur* :\n*Gender* :\n*Askot* :\n\nKlik Button Di Bawah Untuk Memulai Bot\nNote Jika Tidak Ada Ketik .allmenu`
gbutsan = [{buttonId:'.menu',buttonText:{displayText:'COMMAND'},type:1}]
mhan = await Fardan.prepareMessage(mdata.id, buff, MessageType.image, {thumbnail: ppimg})
const buttonMessages = { imageMessage: mhan.message.imageMessage,
contentText: `${masuk}`,
footerText: `Created Fax`,
buttons: gbutsan,
headerType: 4 }
Fardan.sendMessage(mdata.id, buttonMessages, MessageType.buttonsMessage, {thumbnail: fs.readFileSync('./Fardan.jpg'), "contextInfo": { mentionedJid: [num]}, caption: 'Tes', quoted: fkontakk})
} else if (anu.action == 'remove') {
const welkom = JSON.parse(fs.readFileSync('./database/welkom.json'))
if(!welkom.includes(mdata.id)) return
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;Fardan;;;\nFN:Fardan\nitem1.TEL;waid=6281337541779:6281337541779\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
num = anu.participants[0]
try {
ppimg = await Fardan.getProfilePicture(`${num.split('@')[0]}@c.us`)
} catch {
ppimg = 'https://api-helgazex.herokuapp.com/api/canvas/welcome2?username=${pushname}&groupname=${mdata.subject}&membercount=-&profile=${ppimg}&background=${ppimg}&apikey=kfL8EfHc'
}
let buff = await getBuffer(ppimg)
keluar =`Selamat tinggal @${num.split('@')[0]}\nSemoga tentang disana`
gbutsan = [{buttonId:'.owner',buttonText:{displayText:'OWNER'},type:1}]
mhan = await Fardan.prepareMessage(mdata.id, buff, MessageType.image, {thumbnail: ppimg})
const buttonMessages = { imageMessage: mhan.message.imageMessage,
contentText: `${keluar}`,
footerText: `Created By Fax︎`,
buttons: gbutsan,
headerType: 4 }
Fardan.sendMessage(mdata.id, buttonMessages, MessageType.buttonsMessage, { thumbnail: fs.readFileSync('./Fardan.jpg'), "contextInfo": { mentionedJid: [num]}, caption: 'Tes', quoted: fkontakk})
} else if (anu.action == 'promote') {
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;Fardan;;;\nFN:Fardan\nitem1.TEL;waid=6281337541779:6281337541779\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
shp = '◦➛'
var thu = await Fardan.getStatus(anu.participants[0], MessageType.text)
num = anu.participants[0]
teks = `*P R O M O T E - D E T E C T E D*\n\n${shp} Username: @${num.split('@')[0]}\n\n${shp} Bio : ${thu.status}\n\n${shp} Time : ${moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss')}\n\n${shp} Group: ${mdata.subject}\n\nDon't break the rules!`
Fardan.sendMessage(mdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [num]}, quoted: fkontakk})
console.log(color('|TRM|'), color(`Promote Member ${num.split('@')[0]} In ${mdata.subject}`, 'cyan'))
}
else if (anu.action == 'demote') {
fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${mdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;Fardan;;;\nFN:Fardan\nitem1.TEL;waid=6281337541779:6281337541779\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
shp = '◦➛'
thu = await Fardan.getStatus(anu.participants[0], MessageType.text)
num = anu.participants[0]
teks = `*D E M O T E - D E T E C T E D*\n\n${shp} Username: @${num.split('@')[0]}\n\n${shp} Bio : ${thu.status}\n\n${shp} Time : ${moment.tz('Asia/Jakarta').format('DD/MM HH:mm:ss')}\n\n${shp} Group: ${mdata.subject}`
Fardan.sendMessage(mdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [num]}, quoted: fkontakk})
console.log(color('|TRM|'), color(`Demote Admin ${num.split('@')[0]} In ${mdata.subject}`, 'cyan'))
}
} catch (e) {
console.log('Error : %s', color(e, 'red'))
}
})
Fardan.on('group-update', async (anu) => {
const metdata = await Fardan.groupMetadata(anu.jid)
const fkontakk = { key: { fromMe: false, participant: `0@s.whatsapp.net`, ...(anu.jid ? { remoteJid: '6283136505591-1604595598@g.us' } : {})}, message: { "contactMessage":{"displayName": `${metdata.subject}`,"vcard":`BEGIN:VCARD\nVERSION:3.0\nN:2;Fardan;;;\nFN:Fardan\nitem1.TEL;waid=6282138919347:6282138919347\nitem1.X-ABLabel:Mobile\nEND:VCARD` }}}
if(anu.announce == 'false'){
teks = `- [ Group Opened ] -\n\n_Group telah dibuka oleh admin_\n_Sekarang semua member bisa mengirim pesan_`
Fardan.sendMessage(metdata.id, teks, MessageType.text, {quoted: fkontakk})
console.log(color('|TRM|'), color(`Group Opened In ${metdata.subject}`, 'cyan'))
}
else if(anu.announce == 'true'){
teks = `- [ Group Closed ] -\n\n_Group telah ditutup oleh admin_\n_Sekarang hanya admin yang dapat mengirim pesan_`
Fardan.sendMessage(metdata.id, teks, MessageType.text, {quoted: fkontakk})
console.log(color('|TRM|'), color(`Group Closed In ${metdata.subject}`, 'cyan'))
}
else if(!anu.desc == ''){
tag = anu.descOwner.split('@')[0] + '@s.whatsapp.net'
teks = `- [ Group Description Change ] -\n\nDeskripsi Group telah diubah oleh Admin @${anu.descOwner.split('@')[0]}\n• Deskripsi Baru : ${anu.desc}`
Fardan.sendMessage(metdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [tag]}, quoted: fkontakk})
console.log(color('|TRM|'), color(`Group Description Change In ${metdata.subject}`, 'cyan'))
}
else if(anu.restrict == 'false'){
teks = `- [ Group Setting Change ] -\n\nEdit Group info telah dibuka untuk member\nSekarang semua member dapat mengedit info Group Ini`
Fardan.sendMessage(metdata.id, teks, MessageType.text, {quoted: fkontakk})
console.log(color('|TRM|'), color(`Group Setting Change In ${metdata.subject}`, 'cyan'))
}
else if(anu.restrict == 'true'){
teks = `- [ Group Setting Change ] -\n\nEdit Group info telah ditutup untuk member\nSekarang hanya admin group yang dapat mengedit info Group Ini`
Fardan.sendMessage(metdata.id, teks, MessageType.text, {quoted: fkontakk})
console.log(color('|TRM|'), color(`Group Setting Change In ${metdata.subject}`, 'cyan'))
}
})
Fardan.on('CB:action,,call', async json => {
const callerId = json[2][0][1].from;
var vcard = 'BEGIN:VCARD\n' + 'VERSION:3.0\n' + 'FN:' + `${NamaOwner}` + '\n' + `ORG:Developer ${NamaBot}\n` + 'TEL;type=CELL;type=VOICE;waid=' + `${NomorOwner}` + ':+' + `${NomorOwner}` + '\n' + 'END:VCARD'
Fardan.sendMessage(callerId, "\`\`\`[ ! ] CALL DETECTED [ ! ]\`\`\`\n\n\`\`\`Anda Di Block Karena Telepon Bot , Silahkan Hubungi Developer Bot Untuk Membuka Block\`\`\`", MessageType.text)
Fardan.sendMessage(callerId, { displayname: `${NamaOwner}`, vcard: vcard}, MessageType.contact, {contextInfo: { externalAdReply:{title: `Developer ${NamaBot}`,body:"",previewType:"PHOTO",thumbnail:fs.readFileSync('./Fardan.jpg'),sourceUrl:`https://wa.me/6282138919347?text=Assalamualaikum`}}})
await sleep(5000)
await Fardan.blockUser(callerId, "add")
})
Fardan.on('message-delete', async (m) => {
if (!m.key.fromMe && !antidelete) {
if (!m.key.remoteJid == 'status@broadcast') return
m.message = (Object.keys(m.message)[0] === 'ephemeralMessage') ? m.message.ephemeralMessage.message : m.message
const jam = moment.tz('Asia/Jakarta').format('HH:mm:ss')
let d = new Date
let c = Fardan.chats.get(m.key.remoteJid)
let a = c.messages.dict[`${m.key.id}|${m.key.fromMe ? 1 : 0}`]
let co3ntent = Fardan.generateForwardMessageContent(a, false)
let c3type = Object.keys(co3ntent)[0]
let locale = 'id'
let gmt = new Date(0).getTime() - new Date('1 Januari 2021').getTime()
let weton = ['Pahing', 'Pon','Wage','Kliwon','Legi'][Math.floor(((d * 1) + gmt) / 84600000) % 5]
let week = d.toLocaleDateString(locale, { weekday: 'long' })
let calender = d.toLocaleDateString(locale, {
day: 'numeric',
month: 'long',
year: 'numeric'
})
Fardan.copyNForward(m.key.remoteJid, m.message)
Fardan.sendMessage(m.key.remoteJid, `▷\`\`\`Anti Delete\`\`\`
▢ \`\`\`Nama : @${m.participant.split("@")[0]}\`\`\`
▢ \`\`\`Tipe : ${c3type}\`\`\`
▢ \`\`\`Tanggal : ${jam} - ${week} ${weton} - ${calender}\`\`\``, MessageType.text, {quoted: m.message, contextInfo: {"mentionedJid": [m.participant]}})
}
})
}
function nocache(module, cb = () => { }) {
console.log('Module', `'${module}'`, 'is now being watched for changes')
fs.watchFile(require.resolve(module), async () => {
await uncache(require.resolve(module))
cb(module)
})
}
function uncache(module = '.') {
return new Promise((resolve, reject) => {
try {
delete require.cache[require.resolve(module)]
resolve()
} catch (e) {
reject(e)
}
})
}
starts()