forked from RyuukaBotzz/RyuBotzS2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
189 lines (171 loc) ยท 6.6 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
189
//Function Module
const {
WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange
} = require('@adiwajshing/baileys')
const fs = require('fs')
const fetch = require('node-fetch')
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'))
const { OwnerNumber, BotName, OwnerName } = require('./setting.json')
const { welkam, goodbye } = require('./lib/welkam.js')
//Media
thumb = fs.readFileSync('./media/thumb.jpg')
//Auto Update For Ryuu.js
require('./Ryuu.js')
nocache('./Ryuu.js', module => console.log(`${module} telah di update!`))
//Function Start & Browser
const starts = async (Ryuu = new WAConnection()) => {
Ryuu.logger.level = 'warn'
Ryuu.version = [2, 2143, 3]
Ryuu.browserDescription = [ 'RyuBotz', 'Safari', '3.0' ]
Ryuu.on('qr', () => {
console.log(color('[','white'), color('!','red'), color(']','white'), color(' Scan Qrnya Kak Waktu Cuma 20 Detik !!'))
})
//Function Send Button Image
const sendButImage = async (from, context, fotext, img, but) => {
gam = img
jadinya = await Ryuu.prepareMessage(from, gam, MessageType.image)
buttonMessagesI = {
imageMessage: jadinya.message.imageMessage,
contentText: context,
footerText: fotext,
buttons: but,
headerType: 4
}
Ryuu.sendMessage(from, buttonMessagesI, MessageType.buttonsMessage)
}
//Connecting Running Bot
fs.existsSync('./QrRyuu.json') && Ryuu.loadAuthInfo('./QrRyuu.json')
Ryuu.on('connecting', () => {
start('2', 'Menghubungkan ...')
})
//Connect Done
Ryuu.on('open', () => {
success('2', 'Bot Sudah Terhububung, Selamat Memakai Bot')
Ryuu.sendMessage(`${OwnerNumber}@s.whatsapp.net`, `*Halo Owner ${BotName} ๐*\n\nBot Sekarang Sudah Tersambung Dan Siap Untuk Dipakai ๐ค๐\n\nJika Terjadi Emror Hubungi Developer\n\nJangan Lupa Ucapkan Terima Kasih Kepada Developer Bot Serta Jangan Lupa Subrek Youtube Ryuuka Botz`, MessageType.text, {contextInfo: { forwardingScore: 508, isForwarded: true, externalAdReply:{title: "Developer Bot",body:"",previewType:"PHOTO",thumbnail:fs.readFileSync('./media/thumb.jpg'),sourceUrl:"https://wa.me/6283891921787?text=Assalamualaikum"}}})
})
//Auto Join To Group
await Ryuu.connect({timeoutMs: 30*1000})
fs.writeFileSync('./QrRyuu.json', JSON.stringify(Ryuu.base64EncodedAuthInfo(), null, '\t'))
teks = `https://chat.whatsapp.com/BhOYdoWNRFC4n4bdsEexlV`
Ryuu.query({ json:["action", "invite", `${teks.replace('https://chat.whatsapp.com/','')}`]})
console.log(color('[ WARN ]', 'yellow'), color('BOT MEMASUKI GROUP โข Ryuuka Botz Official โข', 'yellow'))
//Function Update Welcome And Leave
Ryuu.on('chat-update', async (message) => {
require('./Ryuu.js')(Ryuu, message, _welkom)
})
Ryuu.on("group-participants-update", async (anu) => {
const isWelkom = _welkom.includes(anu.jid)
try {
groupMet = await Ryuu.groupMetadata(anu.jid)
groupMembers = groupMet.participants
groupAdmins = getGroupAdmins(groupMembers)
mem = anu.participants[0]
console.log(anu)
//Getting Profile Picture User
try {
pp_user = await Ryuu.getProfilePicture(mem)
} catch (e) {
pp_user = "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png?q=60"
}
//Getting Profile Picture Group
try {
pp_grup = await Ryuu.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"
}
// Auto Send Message Moment Bot Add To Group
if (anu.action == 'add' && mem.includes(Ryuu.user.jid)) {
Ryuu.sendMessage(anu.jid, '```Haloo Semua ๐ Terima Kasih sudah Mengundangku, Jika ingin Menggunakan Bot Ketik .menu```', 'conversation')
}
//Text Welcome
if (!isWelkom) return
if (anu.action == 'add') {
num = anu.participants[0]
mdata = await Ryuu.groupMetadata(anu.jid)
memeg = mdata.participants.length
let v = Ryuu.contacts[num] || { notify: num.replace(/@.+/, "") }
anu_user = v.vname || v.notify || num.split("@")[0]
time_wel = moment.tz("Asia/Jakarta").format("HH:mm")
try {
ppimg = await Ryuu.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'
}
image = 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://telegra.ph/file/bf8079fc05fcc8b51cf32.jpg`
)
teks = `๐๐ฎ๐น๐ผ ๐๐ฎ๐ธ *@${num.split('@')[0]}*\n๐ฆ๐ฒ๐น๐ฎ๐บ๐ฎ๐ ๐๐ฎ๐๐ฎ๐ป๐ด ๐๐ถ ๐๐ฟ๐ผ๐๐ฝ ${mdata.subject}\n\n`
but = [
{ buttonId: '.welcomedekkk', buttonText: { displayText: 'WELCOME ๐' }, type: 1 }
]
let buff = await getBuffer(ppimg)
sendButImage(mdata.id, teks+welkam(), `*ยฉ Whatsapp | ${mdata.subject}*`, image, but)
//Text Remove
} else if (anu.action == 'remove') {
num = anu.participants[0]
mdata = await Ryuu.groupMetadata(anu.jid)
memeg = mdata.participants.length
let w = Ryuu.contacts[num] || { notify: num.replace(/@.+/, "") }
anu_user = w.vname || w.notify || num.split("@")[0]
time_wel = moment.tz("Asia/Jakarta").format("HH:mm")
try {
ppimg = await Ryuu.getProfilePicture(`${num.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'
}
imagee = 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://telegra.ph/file/bf8079fc05fcc8b51cf32.jpg`
)
tekss = `๐ฌ๐ฎ๐ต๐ต ๐ฆ๐ถ *@${num.split('@')[0]}* ๐๐ฒ๐น๐๐ฎ๐ฟ\n\n`
butt = [
{ buttonId: '.remove', buttonText: { displayText: 'GOODBYE ๐' }, type: 1 }
]
let buff = await getBuffer(ppimg)
sendButImage(mdata.id, tekss+goodbye(), `*ยฉ Whatsapp | ${mdata.subject}*`, imagee, butt)
}
} 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()