forked from LoL-Human/Case-WA-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
347 lines (333 loc) · 19.1 KB
/
script.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
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
/*
* Tambahin nama author lah
* Author MhankBarBar, Farhan
* Tambahin ya Cape Gan ngefix² Yg Ga work
* Jan numpang nama doank
- What's New?
* New Features
*/
// KALO NGUBAH YG TELITI NTAR GA WORK MALAH NYALAHIN HADEHH
// DAN YG NYURI TANPA KASIH CREDIT INGAT BRO LU SAMPAH🚮
const {
WAConnection,
MessageType,
Presence,
Mimetype,
GroupSettingChange
} = require('@adiwajshing/baileys')
const fs = require("fs")
const axios = require('axios')
const request = require('request')
const moment = require('moment-timezone')
const { apikey, prefix } = JSON.parse(fs.readFileSync('./config.json'))
const { fetchJson, getBuffer } = require('./lib/fetcher')
const { color } = require('./lib/color')
const { help, bahasa, donate } = require('./help/help')
async function starts() {
const lolhuman = new WAConnection()
lolhuman.logger.level = 'warn'
lolhuman.on('qr', () => {
console.log(color('[', 'red'), color('!', 'yellow'), color(']', 'red'), color(' Scan the qr code above', 'green'))
})
fs.existsSync('./lolhuman.json') && lolhuman.loadAuthInfo('./lolhuman.json')
lolhuman.on('connecting', () => {
const time_connecting = moment.tz('Asia/Jakarta').format('HH:mm:ss')
console.log(color(time_connecting, "white"), color("[ STATS ]", "aqua"), "Connecting...")
})
lolhuman.on('open', () => {
const time_connect = moment.tz('Asia/Jakarta').format('HH:mm:ss')
console.log(color(time_connect, "white"), color("[ STATS ]", "aqua"), "Connected")
})
await lolhuman.connect({ timeoutMs: 30 * 1000 })
fs.writeFileSync('./lolhuman.json', JSON.stringify(lolhuman.base64EncodedAuthInfo(), null, '\t'))
lolhuman.on('chat-update', async(lol) => {
const time = moment.tz('Asia/Jakarta').format('HH:mm:ss')
try {
if (!lol.hasNewMessage) return
lol = JSON.parse(JSON.stringify(lol)).messages[0]
if (!lol.message) return
if (lol.key && lol.key.remoteJid == 'status@broadcast') return
if (lol.key.fromMe) return
global.prefix
const content = JSON.stringify(lol.message)
const from = lol.key.remoteJid
const type = Object.keys(lol.message)[0]
const insom = from.endsWith('@g.us')
const nameReq = insom ? lol.participant : lol.key.remoteJid
pushname2 = lolhuman.contacts[nameReq] != undefined ? lolhuman.contacts[nameReq].vname || lolhuman.contacts[nameReq].notify : undefined
const { text, extendedText, contact, location, liveLocation, image, video, sticker, document, audio, product } = MessageType
pesan = type === 'conversation' ? lol.message.conversation : lol.message.extendedTextMessage.text
body = (type === 'conversation' && pesan.startsWith(prefix)) ? pesan : (type == 'imageMessage') && lol.message.imageMessage.caption.startsWith(prefix) ? lol.message.imageMessage.caption : (type == 'videoMessage') && lol.message.videoMessage.caption.startsWith(prefix) ? lol.message.videoMessage.caption : (type == 'extendedTextMessage') && lol.message.extendedTextMessage.text.startsWith(prefix) ? lol.message.extendedTextMessage.text : ''
budy = (type === 'conversation') ? pesan : (type === 'extendedTextMessage') ? lol.message.extendedTextMessage.text : ''
var Link = (type === 'conversation' && pesan) ? pesan : (type == 'imageMessage') && lol.message.imageMessage.caption ? lol.message.imageMessage.caption : (type == 'videoMessage') && lol.message.videoMessage.caption ? lol.message.videoMessage.caption : (type == 'extendedTextMessage') && lol.message.extendedTextMessage.text ? lol.message.extendedTextMessage.text : ''
const messagesLink = Link.slice(0).trim().split(/ +/).shift().toLowerCase()
const command = body.slice(1).trim().split(/ +/).shift().toLowerCase()
const args = body.trim().split(/ +/).slice(1)
const argsjoin = args.join(' ')
const isCmd = body.startsWith(prefix)
lolhuman.chatRead(from)
const botNumber = lolhuman.user.jid
const isGroup = from.endsWith('@g.us')
const sender = isGroup ? lol.participant : lol.key.remoteJid
const groupMetadata = isGroup ? await lolhuman.groupMetadata(from) : ''
const groupName = isGroup ? groupMetadata.subject : ''
const totalchat = await lolhuman.chats.all()
const isUrl = (url) => {
return url.match(new RegExp(/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/, 'gi'))
}
const reply = (teks) => {
lolhuman.sendMessage(from, teks, text, { quoted: lol })
}
const sendMess = (hehe, teks) => {
lolhuman.sendMessage(hehe, teks, text)
}
const costum = (pesan, tipe, target, target2) => {
lolhuman.sendMessage(from, pesan, tipe, { quoted: { key: { fromMe: false, participant: `${target}`, ...(from ? { remoteJid: from } : {}) }, message: { conversation: `${target2}` } } })
}
const mentions = (teks, memberr, id) => {
(id == null || id == undefined || id == false) ? lolhuman.sendMessage(from, teks.trim(), extendedText, { contextInfo: { "mentionedJid": memberr } }): lolhuman.sendMessage(from, teks.trim(), extendedText, { quoted: lol, contextInfo: { "mentionedJid": memberr } })
}
colors = ['red', 'white', 'black', 'blue', 'yellow', 'green', 'aqua']
const isMedia = (type === 'imageMessage' || type === 'videoMessage')
const isQuotedImage = type === 'extendedTextMessage' && content.includes('imageMessage')
const isQuotedVideo = type === 'extendedTextMessage' && content.includes('videoMessage')
const isQuotedSticker = type === 'extendedTextMessage' && content.includes('stickerMessage')
if (!isGroup && !isCmd) console.log(color(time, "white"), color("[ PRIVATE ]", "aqua"), color(pesan, "white"), "from", color(sender.split('@')[0], "yellow"))
if (isGroup && !isCmd) console.log(color(time, "white"), color("[ GROUP ]", "aqua"), color(pesan, "white"), "from", color(sender.split('@')[0], "yellow"), "in", color(groupName, "yellow"))
if (isGroup && isCmd) console.log(color(time, "white"), color("[ COMMAND ]", "aqua"), color(pesan, "white"), "from", color(sender.split('@')[0], "yellow"), "in", color(groupName, "yellow"))
if (isCmd) console.log(color(time, "white"), color("[ COMMAND ]", "aqua"), color(pesan, "white"), "from", color(sender.split('@')[0], "yellow"))
switch (command) {
case 'help':
reply(help(prefix))
break
case 'donate':
reply(donate(pushname2))
break
case 'alquran':
if (args.length < 1) return reply('_Example: !alquran 108_')
urls = `http://api.lolhuman.xyz/api/quran/${args[0]}?apikey=${apikey}`
quran = await fetchJson(urls)
result = quran.result
ayat = result.ayat
txt = `QS. ${result.surah} : 1-${ayat.length}\n\n`
for (var x in ayat) {
test = ayat[x]
arab = test.arab
nomor = test.ayat
latin = test.latin
indo = test.indonesia
txt += `${arab}\n${nomor}. ${latin}\n${indo}\n\n`
}
txt = txt.replace(/<u>/g, "").replace(/<\/u>/g, "")
txt = txt.replace(/<strong>/g, "").replace(/<\/strong>/g, "")
txt = txt.replace(/<u>/g, "").replace(/<\/u>/g, "")
reply(txt)
break
case 'quotes':
quotes = await fetchJson(`http://api.lolhuman.xyz/api/random/quotes?apikey=${apikey}`)
quotes = quotes.result
author = quotes.by
quotes = quotes.quote
reply(`_${quotes}_\n\n*― ${author}*`)
break
case 'quotesdilan':
quotedilan = await fetchJson(`http://api.lolhuman.xyz/api/quotes/dilan?apikey=${apikey}`)
reply(quotedilan.result)
break
case 'jadwaltv':
channel = args[0]
tvnow = await fetchJson(`http://api.lolhuman.xyz/api/jadwaltv/${channel}?apikey=${apikey}`)
tvnow = tvnow.result
txt = `Jadwal TV ${channel.toUpperCase()}\n`
for (var x in tvnow) {
txt += `${x} - ${tvnow[x]}\n`
}
reply(txt)
break
case 'nhentai':
henid = args[0]
get_result = await fetchJson(`http://api.lolhuman.xyz/api/nhentai/${henid}?apikey=${apikey}`)
get_result = get_result.result
txt = `Title Romaji : ${get_result.title_romaji}\n`
txt += `Title Native : ${get_result.title_native}\n`
txt += `Read Online : ${get_result.read}\n`
get_info = get_result.info
txt += `Parodies : ${get_info.parodies}\n`
txt += `Character : ${get_info.characters.join(", ")}\n`
txt += `Tags : ${get_info.tags.join(", ")}\n`
txt += `Artist : ${get_info.artists}\n`
txt += `Group : ${get_info.groups}\n`
txt += `Languager : ${get_info.languages.join(", ")}\n`
txt += `Categories : ${get_info.categories}\n`
txt += `Pages : ${get_info.pages}\n`
txt += `Uploaded : ${get_info.uploaded}\n`
reply(txt)
break
case 'nhentaipdf':
henid = args[0]
get_result = await fetchJson(`http://api.lolhuman.xyz/api/nhentai/${henid}?apikey=${apikey}`)
get_result = get_result.result
buffer = await getBuffer(get_result.file_pdf)
lolhuman.sendMessage(from, buffer, document, { quoted: lol, mimetype: Mimetype.pdf })
break
case 'yaoi':
buffer = await getBuffer(`http://api.lolhuman.xyz/api/random/nsfw/yaoi?apikey=${apikey}`)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'yuri':
img = await fetchJson(`http://api.lolhuman.xyz/api/random2/yuri?apikey=${apikey}`)
img = img.result
buffer = await getBuffer(img)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'wancak':
buffer = await getBuffer(`http://api.lolhuman.xyz/api/onecak?apikey=${apikey}`)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'ephoto1':
txt = args.join(" ")
buffer = await getBuffer(`http://api.lolhuman.xyz/api/ephoto1/wetglass?apikey=${apikey}&text=${txt}`)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'ephoto2':
txt1 = args[0]
txt2 = args[1]
buffer = await getBuffer(`http://api.lolhuman.xyz/api/ephoto2/codwarzone?apikey=${apikey}&text1=${txt1}&text2=${txt2}`)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'photoeditor':
url = args[0]
buffer = await getBuffer(`http://api.lolhuman.xyz/api/editor/fisheye?apikey=${apikey}&img=${url}`)
lolhuman.sendMessage(from, buffer, image, { quoted: lol })
break
case 'kusonime':
url = args[0]
get_result = await fetchJson(`http://api.lolhuman.xyz/api/kusonime?apikey=${apikey}&url=${url}`)
get_result = get_result.result
txt = `Title : ${get_result.title}\n`
txt += `Japanese : ${get_result.japanese}\n`
txt += `Genre : ${get_result.genre}\n`
txt += `Seasons : ${get_result.seasons}\n`
txt += `Producers : ${get_result.producers}\n`
txt += `Type : ${get_result.type}\n`
txt += `Status : ${get_result.status}\n`
txt += `Total Episode : ${get_result.total_episode}\n`
txt += `Score : ${get_result.score}\n`
txt += `Duration : ${get_result.duration}\n`
txt += `Released On : ${get_result.released_on}\n`
txt += `Desc : ${get_result.desc}\n`
link_dl = get_result.link_dl
for (var x in link_dl) {
txt += `\n${x}\n`
for (var y in link_dl[x]) {
txt += `${y} - ${link_dl[x][y]}\n`
}
}
buffer = await getBuffer(get_result.thumbnail)
lolhuman.sendMessage(from, buffer, image, { quoted: lol, caption: txt })
break
case 'kusonimesearch':
query = args.join(" ")
get_result = await fetchJson(`http://api.lolhuman.xyz/api/kusonimesearch?apikey=${apikey}&query=${query}`)
get_result = get_result.result
txt = `Title : ${get_result.title}\n`
txt += `Japanese : ${get_result.japanese}\n`
txt += `Genre : ${get_result.genre}\n`
txt += `Seasons : ${get_result.seasons}\n`
txt += `Producers : ${get_result.producers}\n`
txt += `Type : ${get_result.type}\n`
txt += `Status : ${get_result.status}\n`
txt += `Total Episode : ${get_result.total_episode}\n`
txt += `Score : ${get_result.score}\n`
txt += `Duration : ${get_result.duration}\n`
txt += `Released On : ${get_result.released_on}\n`
txt += `Desc : ${get_result.desc}\n`
link_dl = get_result.link_dl
for (var x in link_dl) {
txt += `\n${x}\n`
for (var y in link_dl[x]) {
txt += `${y} - ${link_dl[x][y]}\n`
}
}
buffer = await getBuffer(get_result.thumbnail)
lolhuman.sendMessage(from, buffer, image, { quoted: lol, caption: txt })
break
case 'otakudesu':
url = args[0]
get_result = await fetchJson(`http://api.lolhuman.xyz/api/otakudesu?apikey=${apikey}&url=${url}`)
get_result = get_result.result
txt = `Title : ${get_result.title}\n`
txt += `Japanese : ${get_result.japanese}\n`
txt += `Judul : ${get_result.judul}\n`
txt += `Type : ${get_result.type}\n`
txt += `Episode : ${get_result.episodes}\n`
txt += `Aired : ${get_result.aired}\n`
txt += `Producers : ${get_result.producers}\n`
txt += `Genre : ${get_result.genres}\n`
txt += `Duration : ${get_result.duration}\n`
txt += `Studios : ${get_result.status}\n`
txt += `Rating : ${get_result.rating}\n`
txt += `Credit : ${get_result.credit}\n`
get_link = get_result.link_dl
for (var x in get_link) {
txt += `\n\n*${get_link[x].title}*\n`
for (var y in get_link[x].link_dl) {
info = get_link[x].link_dl[y]
txt += `\n\`\`\`Reso : \`\`\`${info.reso}\n`
txt += `\`\`\`Size : \`\`\`${info.size}\n`
txt += `\`\`\`Link : \`\`\`\n`
down_link = info.link_dl
for (var z in down_link) {
txt += `${z} - ${down_link[z]}\n`
}
}
}
reply(txt)
break
case 'otakudesusearch':
query = args.join(" ")
get_result = await fetchJson(`http://api.lolhuman.xyz/api/otakudesusearch?apikey=${apikey}&query=${query}`)
get_result = get_result.result
txt = `Title : ${get_result.title}\n`
txt += `Japanese : ${get_result.japanese}\n`
txt += `Judul : ${get_result.judul}\n`
txt += `Type : ${get_result.type}\n`
txt += `Episode : ${get_result.episodes}\n`
txt += `Aired : ${get_result.aired}\n`
txt += `Producers : ${get_result.producers}\n`
txt += `Genre : ${get_result.genres}\n`
txt += `Duration : ${get_result.duration}\n`
txt += `Studios : ${get_result.status}\n`
txt += `Rating : ${get_result.rating}\n`
txt += `Credit : ${get_result.credit}\n`
get_link = get_result.link_dl
for (var x in get_link) {
txt += `\n\n*${get_link[x].title}*\n`
for (var y in get_link[x].link_dl) {
info = get_link[x].link_dl[y]
txt += `\n\`\`\`Reso : \`\`\`${info.reso}\n`
txt += `\`\`\`Size : \`\`\`${info.size}\n`
txt += `\`\`\`Link : \`\`\`\n`
down_link = info.link_dl
for (var z in down_link) {
txt += `${z} - ${down_link[z]}\n`
}
}
}
reply(txt)
break
default:
if (body.startsWith(`${prefix}${command}`)) {
reply(`Sorry bro, command *${prefix}${command}* gk enek nggon list *${prefix}help*`)
}
if (!isGroup) {
simi = await fetchJson(`http://api.lolhuman.xyz/api/simi?apikey=${apikey}&text=${body}`)
reply(simi.result)
}
}
} catch (e) {
console.log(color(time, "white"), color("[ ERROR ]", "aqua"), color(e, 'red'), color("in", "red"), color(e.stack, "red"))
}
})
}
starts()