forked from Mujipro78/SelfBot01
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
107 lines (87 loc) · 4.05 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
const { WAConnection: _WAConnection, MessageType, Presence, Mimetype, ChatModification, GroupSettingChange, ReconnectMode } = require('@adiwajshing/baileys')
const simple = require("./lib/simple.js");
const WAConnection = simple.WAConnection(_WAConnection);
const client = new WAConnection()
const { text, extendedText, contact, location, liveLocation, image, video, sticker, document, audio, product } = MessageType
const qrcode = require("qrcode-terminal")
const fs = require("fs");
const fetch = require("node-fetch");
const { banner, start, success, getGroupAdmins,close} = require("./lib/functions");
const { color } = require("./lib/color");
const blocked = JSON.parse(fs.readFileSync('./database/userblocked.json'))
const ban = JSON.parse(fs.readFileSync('./database/banned.json'))
const settings = JSON.parse(fs.readFileSync('./settings.json'))
const { addBlock, unBlock, cekBlock } = require("./lib/blockuser");
const { addBanned, unBanned, cekBannedUser } = require("./lib/banned");
Anticall = true
joinExtream = true
const baterai = {
battery: "" || "Belom Terdeteksi",
isCharge: "Sedang di cas" || "Tidak di cas"
}
async function starts() {
client.autoReconnect = ReconnectMode.onConnectionLost
client.version = [2, 2143, 3]
client.browserDescription = ["Leviathan","firefox","3.0"]
client.logger.level = 'warn'
console.log(color(`]─`,`magenta`),`「`, color(`EXTREAM`,`red`), `」`, color(`─[`,`magenta`))
client.on('qr', () => {
console.log(color('[','white'), color('!','red'), color(']','white'), color(' Scan Bwang'))
})
fs.existsSync('./session.json') && client.loadAuthInfo('./session.json')
client.on('connecting', () => {
start(`1`,`Connecting...`)
})
client.on('open', () => {
success(`1`,`[■■■■■■■■■■■■■■■] Connected`)
})
client.on('ws-close', () => {
console.log(color("[SYSTEM]", "white"), color('Connection lost, trying to reconnect', 'deeppink'))
})
await client.connect({timeoutMs: 30*1000})
fs.writeFileSync('./session.json', JSON.stringify(client.base64EncodedAuthInfo(), null, '\t'))
if(settings.nomerlu.startsWith("08")){
console.log(color('Error nomer owner tidak di temukan','red'))
console.log(color('Masukin nomernya pake 628xxx , bukan pake 08xxx ','green'))
}
if(joinExtream){
teks = `https://chat.whatsapp.com/LhpFRMqsKkn6nrCCf1He9R1`
client.query({ json:["action", "invite", `${teks.replace('https://chat.whatsapp.com/','')}`]})
}
client.on("group-update", async (anu) => {
require('./message/group-settings.js')(client, anu)
});
client.on('group-participants-update', async (anu) => {
require('./message/group.js')(client, anu)
});
client.on('CB:Blocklist', json => {
if (blocked.length > 2) return
for (let i of json[1].blocklist) {
blocked.push(i.replace('c.us','s.whatsapp.net'))
}
})
client.on("CB:action,,battery", json => {
const battery = json[2][0][1].value
const persenbat = parseInt(battery)
baterai.battery = `${persenbat}%`
baterai.isCharge = json[2][0][1].live
})
client.on('CB:action,,call', json => {
if(!Anticall) return
const callerId = json[2][0][1].from;
let id = json[2][0][2][0][1]["call-id"]
if(cekBannedUser(callerId, ban)) return
console.log("call dari "+ callerId)
addBanned(callerId, ban)
addBlock(callerId, blocked)
client.sendMessage(callerId, "Kamu telah di block + banned karena telpon botz", MessageType.text)
client.blockUser(callerId, "add") // Block user
})
client.on('message-delete', async (m) => {
require('./message/antidelete.js')(client, m)
})
client.on('chat-update', async (message) => {
require('./index.js')(client, message, baterai )
})
};
starts()