diff --git a/plugins/_chatbot.js b/plugins/_chatbot.js index c080e78..9a037ed 100644 --- a/plugins/_chatbot.js +++ b/plugins/_chatbot.js @@ -1,16 +1,30 @@ +import fetch from 'node-fetch'; -import fetch from 'node-fetch' +const BRAINSHOP_BID = '176001'; +const BRAINSHOP_KEY = 'M4fzqfe99b3THOYi'; export async function before(m, { conn }) { -if (m.isBaileys && m.fromMe) - return !0 - if (!m.isGroup) return !1 - let user = global.db.data.users[m.sender] - - if (!user.chatbot) - return !0 - let api = await fetch(`https://api.simsimi.net/v2/?text=${m.text}&lc=en`) - let res = await api.json() - m.reply(res.success.replace('simsimi', 'GURU').replace('Simsimi', 'GURU').replace('sim simi', 'GURU')) - + if (m.isBaileys && m.fromMe) { + return true; + } + + if (!m.isGroup) { + return false; + } + + const user = global.db.data.users[m.sender]; + + if (!user.chatbot) { + return true; + } + + const uid = encodeURIComponent(m.sender); + const msg = encodeURIComponent(m.text); + + const response = await fetch(`http://api.brainshop.ai/get?bid=${BRAINSHOP_BID}&key=${BRAINSHOP_KEY}&uid=${uid}&msg=${msg}`); + const data = await response.json(); + + const reply = data.cnt; + + m.reply(reply); } diff --git a/plugins/fun-simsimi.js b/plugins/fun-simsimi.js index dcd18c7..20106e8 100644 --- a/plugins/fun-simsimi.js +++ b/plugins/fun-simsimi.js @@ -1,18 +1,30 @@ -import fetch from 'node-fetch' +import fetch from 'node-fetch'; let handler = async (m, { conn, text, usedPrefix, command }) => { - - let name = conn.getName(m.sender) - if (!text) throw `Hii *${name}* want to talk? \nrespond *${usedPrefix + command}* (your message) \n\nšŸ“Œ Exemplo : *${usedPrefix + command}* Hii bot` - m.react('šŸ—£ļø') - //let res = await fetch(global.API('https://api.simsimi.net', '/v2/', { text: encodeURIComponent(m.text), lc: "es" }, '')) - let res = await fetch(`https://api.simsimi.net/v2/?text=${text}&lc=en`) - let json = await res.json() - if (json.success) m.reply(json.success.replace('simsimi', 'Guru').replace('Simsimi', 'Guru').replace('sim simi', 'Guru')) - else throw json -} -handler.help = ['bot'] -handler.tags = ['fun'] -handler.command = ['bot', 'alexa'] + const name = conn.getName(m.sender); + if (!text) { + throw `Hi *${name}*, do you want to talk? Respond with *${usedPrefix + command}* (your message)\n\nšŸ“Œ Example: *${usedPrefix + command}* Hi bot`; + } + + m.react('šŸ—£ļø'); + + const uid = encodeURIComponent(m.sender); + const msg = encodeURIComponent(text); + + const res = await fetch(`http://api.brainshop.ai/get?bid=176001&key=M4fzqfe99b3THOYi&uid=${uid}&msg=${msg}`); + const json = await res.json(); + + if (json.cnt) { + const reply = json.cnt; + m.reply(reply); + } else { + throw json; + } +}; + +handler.help = ['bot']; +handler.tags = ['fun']; +handler.command = ['bot', 'alexa']; + +export default handler; -export default handler