-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathBarBar.js
216 lines (194 loc) · 10.9 KB
/
BarBar.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
const {
MessageType,
Mimetype
} = require("@adiwajshing/baileys")
const {
readFileSync: read,
writeFileSync: write,
unlinkSync: remove
} = require("fs")
const upimg = require("./lib/upimg")
const anteiku = require("./lib/antei")
const { getBuffer } = require("./lib/functions")
const { print } = require("./utils/col")
const { captcha, sticker, tiktok, yt, xnxx } = require("./plugins")
const lang = require("./languages")
const moment = require("moment-timezone")
const settings = JSON.parse(read("./src/settings.json"))
moment.tz.setDefault('Asia/Jakarta').locale("id")
let bhs = settings.lang
let prefix = settings.prefix
module.exports = msgHndlr = async (BarBar, mek) => {
try {
const { from, sender, pushname, body, quoted, timestamp, type, isGroup, isMedia, id, fromMe, getMedia, mentions } = mek
const help = new lang[bhs](prefix)
const anteicodes = new anteiku(settings.anteikey) // signup to antei.codes if you want to get token/apikey
const cmd = body && body.startsWith(prefix) ? body.slice(prefix.length).trim().split(/ +/).shift().toLowerCase() : ""
const isCmd = body && body.startsWith(prefix) ? true : false
const args = body ? body.trim().split(/ +/).slice(1) : []
const time = moment(timestamp * 1000).format("DD/MM/YY HH:mm:ss")
const groupMetadata = isGroup ? await BarBar.groupMetadata(from) : ""
const groupId = isGroup ? groupMetadata.id : ""
const groupName = isGroup ? groupMetadata.subject : ""
const groupAdmins = isGroup ? await BarBar.getGroupAdmins(groupId) : []
const groupMembers = isGroup ? groupMetadata.participants : []
const botIsAdminGroup = isGroup ? groupAdmins.includes(BarBar.user.jid) : false
//if (BarBar.captcha && BarBar.captcha[sender] && isGroup && type === "buttonsResponseMessage") captcha.handleCaptcha(BarBar, mek)
const isQuotedImage = quoted && quoted.type === MessageType.image
const isQuotedVideo = quoted && quoted.type === MessageType.video
const isQuotedAudio = quoted && quoted.type === MessageType.audio
const isQuotedDocument = quoted && quoted.type === MessageType.document
const isQuotedSticker = quoted && quoted.type === MessageType.sticker
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 isOwner = settings.owner.includes(sender)
if (isGroup && isCmd) print(`𓄵green|❑𓄳 ${time} 𓄵green|${cmd}𓄳 from 𓄵blue|${pushname}𓄳 on 𓄵purple|${groupName}𓄳`)
if (!isGroup && isCmd) print(`𓄵green|❑𓄳 ${time} 𓄵green|${cmd}𓄳 from 𓄵blue|${pushname}𓄳`)
if (isGroup && !isCmd) print(`𓄵red|❑𓄳 ${time} 𓄵darkYellow|${isMedia && (type !== MessageType.video || type !== MessageType.image) ? type.slice(0, type.match("Message").index) : body.length > 20 ? body.slice(0,20)+"..." : body}𓄳 from 𓄵blue|${pushname}𓄳 on 𓄵purple|${groupName}𓄳`)
if (!isGroup && !isCmd) print(`𓄵red|❑𓄳 ${time} 𓄵darkYellow|${isMedia && (type !== MessageType.video || type !== MessageType.image) ? type.slice(0, type.match("Message").index) : body.length > 20 ? body.slice(0,20)+"..." : body}𓄳 from 𓄵blue|${pushname}𓄳`)
switch (cmd) {
/* -------> [ Help and Menu ] <-------*/
case "help":
return BarBar.sendListMsg(from, help.help(pushname), "Menu", help.menuList())
case "ping":
return BarBar.sendText(from, "Pong!!")
/* --------> [ End ] <-----------*/
/* -------> [ Owner ] <-----------*/
case "prefix":
if (!isOwner || args.length === 0) return
prefix = args[0]
settings.prefix = prefix
write("./src/settings.json", JSON.stringify(settings, null, 4))
return BarBar.sendText(from, `Prefix replaced to : ${prefix}`)
case "setlang":
if (!isOwner || args.length === 0) return
switch (args[0].toLowerCase()) {
case "ind":
case "en":
bhs = args[0].toLowerCase()
settings.lang = bhs
write("./src/settings.json", JSON.stringify(settings, null, 4))
return BarBar.sendText(from, "Done")
default:
return
}
/* -------> [ End ] <------- */
/* -----> [ Sticker Maker ] <----- */
case "stiker":
case "sticker":
case "s":
if ((isMedia && type === MessageType.image || isQuotedImage) || (isMedia && type === MessageType.video || isQuotedVideo) && args.length !== 0) {
let su = body.slice(cmd.length+prefix.length).trim().split("|")
let opt = {}
opt.name = su[0]
opt.author = su[1]
opt.categories = su.length > 2 ? [su[2]] : [""]
return await sticker.wm(BarBar, mek, help.err(cmd).sticker, opt)
} else if ((isMedia && type === MessageType.image || isQuotedImage) || (isMedia && type === MessageType.video || isQuotedVideo)) {
return await sticker.basic(BarBar, mek, help.err(cmd).sticker)
}
return mek.reply(help.err(cmd).sticker[3])
case "stikerburn":
case "stickerburn":
case "sburn":
if (isMedia && type === MessageType.image || isQuotedImage) return await sticker.burning(BarBar, mek, anteicodes, help.err(cmd).sticker)
return mek.reply(help.err(cmd).sticker[0])
case "stikerlight":
case "stickerlight":
case "slight":
if (isMedia && type === MessageType.image || isQuotedImage) return await sticker.lightning(BarBar, mek, anteicodes, help.err(cmd).sticker)
return mek.reply(help.err(cmd).sticker[0])
case "ttp":
if (quoted && quoted.body) return sticker.ttp(BarBar, mek, quoted.body, anteicodes, help.err(cmd).sticker)
if (args.length === 0) return mek.reply(help.err(cmd).sticker[1])
return await sticker.ttp(BarBar, mek, args.join(" "), anteicodes, help.err(cmd).sticker)
case "attp":
if (quoted && quoted.body) return sticker.attp(BarBar, mek, quoted.body, anteicodes, help.err(cmd).sticker)
if (args.length === 0) return mek.reply(help.err(cmd).sticker[1])
return await sticker.attp(BarBar, mek, args.join(" "), anteicodes, help.err(cmd).sticker)
/* ------> [ End ] <------ */
/* ------> [ Downloader ] <-------*/
case "tiktok":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("tiktok.com")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await tiktok.tiktod(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "tikvid":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("tiktok.com")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await tiktok.tikvid(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "tikaud":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("tiktok.com")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await tiktok.tikaud(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "tweet":
case "twitter":
return mek.reply("Sedang dalam proses perkembangan")
/* TODO */
case "yt":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("youtu")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await yt.yt(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "yta":
case "ytmp3":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("youtu")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await yt.yta(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "ytv":
case "ytmp4":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("youtu")) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await yt.ytv(BarBar, mek, args[0], anteicodes, help)
} else {
return mek.reply(help.err().invalid)
}
case "xnxx":
if (args.length === 0) return mek.reply(help.err(cmd).deel)
if (isUrl(args[0]) && args[0].includes("xnxx")) {
if (args.length === 1) {
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await xnxx.xnxx(BarBar, mek, args[0], anteicodes, help)
} else if (args.length === 2) {
switch (args[1].toLowerCase()) {
case "sd":
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await xnxx.sd(BarBar, mek, args[0], anteicodes, help)
case "hd":
isGroup ? mek.reply(help.wait()) : BarBar.sendText(from, help.wait())
return await xnxx.hd(BarBar, mek, args[0], anteicodes, help)
default:
return
}
}
} else {
return mek.reply(help.err().invalid)
}
/* -------> [ End ] <-------- */
default:
return
}
} catch (e) {
print(`Error : 𓄵red|${e}𓄳`)
}
}