Skip to content

Commit

Permalink
some features
Browse files Browse the repository at this point in the history
  • Loading branch information
LoL-Human committed Apr 4, 2021
1 parent 8024d5a commit ea6f634
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ config.json

test*.*
ocr
database/
6 changes: 6 additions & 0 deletions help/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ const help = (prefix) => {
├ • ${prefix}stickerwm
├ • ${prefix}broadcast
├ • ${prefix}hidetag
├ • ${prefix}tagstick
├ • ${prefix}clearall
├──「 Islami 」
├ • ${prefix}listsurah
Expand Down Expand Up @@ -90,7 +92,9 @@ const help = (prefix) => {
├ • ${prefix}jadwaltv channel
├ • ${prefix}jadwaltvnow
├ • ${prefix}jadwalbola
├ • ${prefix}qrreader
├ • ${prefix}heroml hero_name
├ • ${prefix}mlstalk id/server
├ • ${prefix}genshin character
├ • ${prefix}wikipedia query
├ • ${prefix}translate kode_negara text
Expand All @@ -111,6 +115,8 @@ const help = (prefix) => {
├──「 Entertainment 」
├ • ${prefix}asupan
├ • ${prefix}wancak
├ • ${prefix}tebakgambar
├ • ${prefix}canceltebakgambar
├──「 Creator 」
├ • ${prefix}ttp text
Expand Down
1 change: 0 additions & 1 deletion lib/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const axios = require('axios')
const spin = require('spinnies')
const Crypto = require('crypto')


const h2k = (number) => {
var SI_POSTFIXES = ["", " K", " M", " G", " T", " P", " E"]
var tier = Math.log10(Math.abs(number)) / 3 | 0
Expand Down
85 changes: 85 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const { getRandom } = require('./lib/function')
const { help, donate } = require('./help/help')
const { exit } = require('process')

async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}

async function starts() {
const lolhuman = new WAConnection()
lolhuman.logger.level = 'warn'
Expand Down Expand Up @@ -178,6 +182,14 @@ async function starts() {
case 'donate':
reply(donate(pushname2))
break
case 'clearall':
if (sender.split("@")[0] != owner) return reply("Command only for owner bot")
list_chat = await lolhuman.chats.all()
for (let chat of list_chat) {
lolhuman.modifyChat(chat.jid, "delete")
}
reply("success clear all chat")
break
case 'hidetag':
if (sender.split("@")[0] != owner) return reply("Command only for owner bot")
var value = args.join(" ")
Expand All @@ -194,6 +206,29 @@ async function starts() {
}
lolhuman.sendMessage(from, options, text)
break
case 'tagstick':
if (sender.split("@")[0] != owner) return reply("Command only for owner bot")
if ((isMedia && !lol.message.videoMessage || isQuotedSticker) && args.length == 0) {
const encmedia = isQuotedSticker ? JSON.parse(JSON.stringify(lol).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : lol
filePath = await lolhuman.downloadAndSaveMediaMessage(encmedia, filename = getRandom())
var value = args.join(" ")
var group = await lolhuman.groupMetadata(from)
var member = group['participants']
var mem = []
member.map(async adm => {
mem.push(adm.id.replace('c.us', 's.whatsapp.net'))
})
var options = {
contextInfo: { mentionedJid: mem },
quoted: lol
}
ini_buffer = fs.readFileSync(filePath)
lolhuman.sendMessage(from, ini_buffer, sticker, options)
fs.unlinkSync(filePath)
} else {
reply(`Tag sticker yang sudah dikirim`)
}
break
case 'broadcast':
if (sender.split("@")[0] != owner) return reply("Command only for owner bot")
list_chat = await lolhuman.chats.all()
Expand Down Expand Up @@ -928,6 +963,12 @@ async function starts() {
ini_icon = await getBuffer(get_result.icon)
lolhuman.sendMessage(from, ini_icon, image, { quoted: lol, caption: ini_txt })
break
case 'mlstalk':
if (args.length == 0) return reply(`Example: ${prefix + command} 84830127/2169`)
ml_id = args[0]
get_result = await fetchJson(`http://api.lolhuman.xyz/api/mobilelegend/${ml_id}?apikey=${apikey}`)
reply(get_result.result)
break
case 'genshin':
if (args.length == 0) return reply(`Example: ${prefix + command} jean`)
hero = args.join(" ")
Expand All @@ -941,6 +982,27 @@ async function starts() {
ini_voice = await getBuffer(get_result.cv[0].audio[0])
lolhuman.sendMessage(from, ini_voice, audio, { quoted: lol, mimetype: Mimetype.mp4Audio })
break
case 'qrreader':
if ((isMedia && !lol.message.videoMessage || isQuotedImage) && args.length == 0) {
const encmedia = isQuotedImage ? JSON.parse(JSON.stringify(lol).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : lol
const filePath = await lolhuman.downloadAndSaveMediaMessage(encmedia, filename = getRandom());
const form = new FormData();
const stats = fs.statSync(filePath);
const fileSizeInBytes = stats.size;
const fileStream = fs.createReadStream(filePath);
form.append('img', fileStream, { knownLength: fileSizeInBytes });
const options = {
method: 'POST',
credentials: 'include',
body: form
}
get_result = await fetchJson(`http://api.lolhuman.xyz/api/read-qr?apikey=${apikey}`, {...options })
fs.unlinkSync(filePath)
reply("Result: " + get_result.result)
} else {
reply(`Kirim gambar dengan caption ${prefix + command} atau tag gambar yang sudah dikirim`)
}
break
case 'wikipedia':
if (args.length == 0) return reply(`Example: ${prefix + command} Tahu`)
query = args.join(" ")
Expand Down Expand Up @@ -1550,6 +1612,29 @@ async function starts() {
reply(`Kirim gambar dengan caption ${prefix}sticker atau tag gambar yang sudah dikirim`)
}
break
case 'roundsticker':
if ((isMedia && !lol.message.videoMessage || isQuotedImage) && args.length == 0) {
const encmedia = isQuotedImage ? JSON.parse(JSON.stringify(lol).replace('quotedM', 'm')).message.extendedTextMessage.contextInfo : lol
filePath = await lolhuman.downloadAndSaveMediaMessage(encmedia)
file_name = getRandom('.webp')
request({
url: `http://api.lolhuman.xyz/api/convert/towebpwround?apikey=${apikey}`,
method: 'POST',
formData: {
"img": fs.createReadStream(filePath)
},
encoding: "binary"
}, function(error, response, body) {
fs.unlinkSync(filePath)
fs.writeFileSync(file_name, body, "binary")
ini_buff = fs.readFileSync(file_name)
lolhuman.sendMessage(from, ini_buff, sticker, { quoted: lol })
fs.unlinkSync(file_name)
});
} else {
reply(`Kirim gambar dengan caption ${prefix}sticker atau tag gambar yang sudah dikirim`)
}
break
case 'takestick':
if ((isMedia && !lol.message.videoMessage || isQuotedSticker)) {
if (args.length == 0) return reply(`Example: ${prefix + command} LoL|Human`)
Expand Down

0 comments on commit ea6f634

Please sign in to comment.