Skip to content

Commit

Permalink
add new fiture
Browse files Browse the repository at this point in the history
nulis
nulis2
slap
  • Loading branch information
Kry9toN committed Jan 19, 2021
1 parent cb428ce commit 2631cca
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 10 deletions.
1 change: 1 addition & 0 deletions command/help.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
})
return client.reply(text)
} else {
if (!client.cmd.has(args[0])) return client.reply('Perintah yang anda maksut tidak ada bro')
const text = client.cmd.get(args[0]).description
return client.reply(text)
}
Expand Down
18 changes: 18 additions & 0 deletions command/nulis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const { MessageType } = require('@adiwajshing/baileys')
const { getBuffer } = require('../utils/functions')
const { fetchJson } = require('../utils/fetcher')

module.exports = {
name: 'nulis',
aliases: ['n'],
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis _tulisan_',
execute (client, chat, pesan, args) {
const value = args.slice().join(' ')
fetchJson(`https://mhankbarbar.tech/nulis?text=${value}&apiKey=${client.apiKey}`, {method: 'get'})
.then(async (hasil) => {
client.reply(pesan.tunggu)
const buffer = await getBuffer(hasil.result)
client.sendMessage(client.from, buffer, MessageType.image, {quoted: chat, caption: pesan.berhasil})
}).catch((err) => console.log(err))
}
}
17 changes: 17 additions & 0 deletions command/nulis2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { MessageType } = require('@adiwajshing/baileys')
const { getBuffer } = require('../utils/functions')
const { fetchJson } = require('../utils/fetcher')

module.exports = {
name: 'nulis2',
aliases: ['n2'],
description: 'Untuk menuliskan di buku bot\nPenggunaan !nulis _tulisan_',
execute (client, chat, pesan, args) {
const value = args.slice().join(' ')
getBuffer(`https://api.zeks.xyz/api/nulis?text=${value}&apikey=administrator`)
.then((hasil) => {
client.reply(pesan.tunggu)
client.sendMessage(client.from, hasil, MessageType.image, {quoted: chat, caption: pesan.berhasil})
}).catch((err) => console.log(err))
}
}
24 changes: 24 additions & 0 deletions command/slap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
name: 'slap',
description: 'Untuk menampol orang\nPenggunaan !slap _tag_',
execute (client, chat, pesan, args) {
if (!client.isGroup) return client.reply(pesan.error.group)
if (chat.message.extendedTextMessage === undefined || chat.message.extendedTextMessage === null) return client.reply('Tag target yang ingin di tonjok!')
mentioned = chat.message.extendedTextMessage.contextInfo.mentionedJid
const tagList = []
const dari = client.sender
const target = mentioned[0]
tagList.push(dari, target)
const data = [
`@${dari.split('@')[0]} melempar *pisang busuk* ke @${target.split('@')[0]}`,
`@${dari.split('@')[0]} bersiap-siap untuk melempar *sekop* ke @${target.split('@')[0]}`,
`@${dari.split('@')[0]} manapar dengan keras @${target.split('@')[0]} dengan *50jt TON truk*`,
`@${dari.split('@')[0]} mulai *memukul* @${target.split('@')[0]} dengan sendok`,
`@${dari.split('@')[0]} menjatuhkan *meteor* ke @${target.split('@')[0]}`,
`@${dari.split('@')[0]} bersiap-siap *me-rasengan* @${target.split('@')[0]}`,
`@${dari.split('@')[0]} menulis nama @${target.split('@')[0]} di *death note*`
]
const dataslap = data[Math.floor(Math.random() * data.length)]
client.mentions(`${dataslap}`, tagList, true)
}
}
17 changes: 9 additions & 8 deletions krypton.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async function krypton () {

await client.on('chat-update', async (chat) => {
client.pingStart = chat.t
client.apiKey = 'EgUxT1qnZ8gtO8ArahNZ'
if (!chat.hasNewMessage) return
const prefix = '!'
chat = JSON.parse(JSON.stringify(chat)).messages[0]
Expand All @@ -91,16 +92,16 @@ async function krypton () {
const ownerNumber = ['6285892766102@s.whatsapp.net'] // replace this with your number
client.from = chat.key.remoteJid
client.isGroup = client.from.endsWith('@g.us')
const sender = client.isGroup ? chat.participant : chat.key.remoteJid
client.sender = client.isGroup ? chat.participant : chat.key.remoteJid
const groupMetadata = client.isGroup ? await client.groupMetadata(client.from) : ''
const groupName = client.isGroup ? groupMetadata.subject : ''
client.groupMembers = client.isGroup ? groupMetadata.participants : ''
const groupAdmins = client.isGroup ? getGroupAdmins(client.groupMembers) : ''
client.groupId = client.isGroup ? groupMetadata.jid : ''
client.isGroup = client.from.endsWith('@g.us')
client.isBotGroupAdmins = groupAdmins.includes(botNumber) || false
client.isGroupAdmins = groupAdmins.includes(sender) || false
client.isOwner = ownerNumber.includes(sender)
client.isGroupAdmins = groupAdmins.includes(client.sender) || false
client.isOwner = ownerNumber.includes(client.sender)
client.isUrl = (url) => {
// eslint-disable-next-line prefer-regex-literals
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'))
Expand All @@ -122,10 +123,10 @@ async function krypton () {
client.isQuotedSticker = type === 'extendedTextMessage' && content.includes('stickerMessage')

// Logging Message
if (!client.isGroup && isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'client.from', color(sender.split('@')[0]), 'args :', color(args.length))
if (!client.isGroup && !isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'client.from', color(sender.split('@')[0]), 'args :', color(args.length))
if (isCmd && client.isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'client.from', color(sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length))
if (!isCmd && client.isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'client.from', color(sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length))
if (!client.isGroup && isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'client.from', color(client.sender.split('@')[0]), 'args :', color(args.length))
if (!client.isGroup && !isCmd) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'client.from', color(client.sender.split('@')[0]), 'args :', color(args.length))
if (isCmd && client.isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;32mEXEC\x1b[1;37m]', time, color(commandName), 'client.from', color(client.sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length))
if (!isCmd && client.isGroup) console.log('\x1b[1;31m~\x1b[1;37m>', '[\x1b[1;31mRECV\x1b[1;37m]', time, color('Message'), 'client.from', color(client.sender.split('@')[0]), 'in', color(groupName), 'args :', color(args.length))

pesan = {
tunggu: '⌛ Sedang di Prosess ⌛',
Expand Down Expand Up @@ -189,4 +190,4 @@ async function krypton () {
})
}

krypton().catch((err) => console.log(err))
krypton().catch((err) => console.log('Error : %s', color(err, 'red')))
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"axios": "^0.21.1",
"wa-canvas": "git+https://github.com/Kry9toN/wa-canvas.git",
"release-it": "^14.2.2",
"cfonts": "^2.9.1"
"cfonts": "^2.9.1",
"node-fetch": "^2.6.1"
},
"devDependencies": {
"babel-eslint": "^10.1.0",
Expand Down
47 changes: 47 additions & 0 deletions utils/fetcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const fetch = require('node-fetch')
const fs = require('fs')

exports.getBase64 = getBase64 = async (url) => {
const response = await fetch(url, { headers: { 'User-Agent': 'okhttp/4.5.0' } });
if (!response.ok) throw new Error(`unexpected response ${response.statusText}`);
const buffer = await response.buffer();
const videoBase64 = `data:${response.headers.get('content-type')};base64,` + buffer.toString('base64');
if (buffer)
return videoBase64;
};

exports.getBuffer = getBuffer = async (url) => {
const res = await fetch(url, {headers: { 'User-Agent': 'okhttp/4.5.0'}, method: 'GET' })
const anu = fs.readFileSync('./src/emror.jpg')
if (!res.ok) return { type: 'image/jpeg', result: anu }
const buff = await res.buffer()
if (buff)
return { type: res.headers.get('content-type'), result: buff }
}

exports.fetchJson = fetchJson = (url, options) => new Promise(async (resolve, reject) => {
fetch(url, options)
.then(response => response.json())
.then(json => {
// console.log(json)
resolve(json)
})
.catch((err) => {
reject(err)
})
})


exports.fetchText = fetchText = (url, options) => new Promise(async (resolve, reject) => {
fetch(url, options)
.then(response => response.text())
.then(text => {
// console.log(text)
resolve(text)
})
.catch((err) => {
reject(err)
})
})

//exports.getBase64 = getBase64;
22 changes: 21 additions & 1 deletion utils/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,30 @@ const banner = cfonts.render(('KRYPTON|WHATSAPP|BOT'), {
lineHeight: 2
})

const getBuffer = async (url, options) => {
try {
options ? options : {}
const res = await axios({
method: "get",
url,
headers: {
'DNT': 1,
'Upgrade-Insecure-Request': 1
},
...options,
responseType: 'arraybuffer'
})
return res.data
} catch (e) {
console.log(`Error : ${e}`)
}
}

module.exports = {
start,
success,
processTime,
getGroupAdmins,
banner
banner,
getBuffer
}

0 comments on commit 2631cca

Please sign in to comment.