forked from KRIZ-SER/kriz-ser-ofc
-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathmain.js
More file actions
187 lines (172 loc) ยท 7.62 KB
/
main.js
File metadata and controls
187 lines (172 loc) ยท 7.62 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
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 { 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.version = [3,3234,9]
bosco.logger.level = 'warn'
console.log(color(figlet.textSync('KRIZ SER OFC', {
font: 'Standard',
horizontalLayout: 'default',
vertivalLayout: 'default',
width: 80,
whitespaceBreak: false
}), 'yellow'))
console.log(color('[KRIZ ]', 'cyan'), color('WELCOME', 'white'))
console.log(color('[SER]', 'cyan'), color('BOT RUNNING', 'yellow'))
bosco.browserDescription = ["KRIZ SER OFC - [KRIZ -SER]", "edge", "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'))
// 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("0@s.whatsapp.net", buff, MessageType.location,{ thumbnail: buff})
const bosco2 = bosco1.message["ephemeralMessage"] ? bosco1.message.ephemeralMessage : bosco1
teks = `*๐๐๐ ๐๐๐ ๐๐๐ ๐๐ ๐ฐ๐๐๐๐*
@${num.split('@')[0]}
`
promoteBut = [{buttonId:`hm`,buttonText:{displayText:'๐๐จ๐ง๐ ๐ซ๐๐ญ๐ฌ ๐๐ซ๐ฎ๐ก..!'},type:1}]
promoteButt = { contentText: `${teks}`, footerText: `โ๐ฃ๐ ๐๐ ๐ฅ๐ ๐ป๐๐๐ฅ๐๐๐ฅ๐๐`, 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("0@s.whatsapp.net", buff, MessageType.location,{ thumbnail: buff})
const bosco4 = bosco3.message["ephemeralMessage"] ? bosco3.message.ephemeralMessage : bosco3
teks = `*๐๐๐ ๐๐๐ ๐๐ ๐๐๐๐๐๐ ๐๐ ๐ฐ๐๐๐๐*
@${num.split('@')[0]}
`
demoteBut = [{buttonId:`hm`,buttonText:{displayText:'๐๐๐ญ๐ญ๐๐ซ ๐๐ฎ๐๐ค ๐๐๐ฑ๐ญ ๐๐ข๐ฆ๐'},type:1}]
demoteButt = { contentText: `${teks}`, footerText: `๐ป๐๐๐ ๐ฅ๐ ๐ป๐๐๐ฅ๐๐๐ฅ๐๐`, 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: "0@s.whatsapp.net",
remoteJid: "0@s.whatsapp.net"},message: {"groupInviteMessage": {"groupJid": "6288213840883-1616169743@g.us","inviteCode": "mememteeeekkeke","groupName": "Alphabot", "caption": `โ ๏ธ ๐ฒ๐น๐ฐ๐ - ๐บ๐ฌ๐น โ ๏ธ`, 'jpegThumbnail': fs.readFileSync(`ds.jpg`)}}}
metdata = await bosco.groupMetadata(anu.jid)
if(anu.announce == 'false'){
teks = `*[ ๐ฎ๐น๐ถ๐ผ๐ท ๐ถ๐ท๐ฌ๐ต๐ฌ๐ซ ]*\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 = `*[ ๐ฎ๐น๐ถ๐ผ๐ท ๐ช๐ณ๐ถ๐บ๐ฌ๐ซ ]*\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 = `*[ ๐ฎ๐น๐ถ๐ผ๐ท ๐ซ๐ฌ๐บ๐ช๐น๐ฐ๐ท๐ป๐ฐ๐ถ๐ต ๐ช๐ฏ๐จ๐ต๐ฎ๐ฌ ]*\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 = `*[ ๐ฎ๐น๐ถ๐ผ๐ท ๐บ๐ฌ๐ป๐ป๐ฐ๐ต๐ฎ ๐ช๐ฏ๐จ๐ต๐ฎ๐ฌ ]*\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 = `*[ ๐ฎ๐น๐ถ๐ผ๐ท ๐บ๐ฌ๐ป๐ป๐ฐ๐ต๐ฎ ๐ช๐ฏ๐จ๐ต๐ฎ๐ฌ ]*\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()