Skip to content

Commit

Permalink
Merge pull request #41 from Guru322/patch2
Browse files Browse the repository at this point in the history
chatbot fixed
  • Loading branch information
Guru322 authored Jun 14, 2023
2 parents 4d782c0 + fc5849d commit 3db8941
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 27 deletions.
38 changes: 26 additions & 12 deletions plugins/_chatbot.js
Original file line number Diff line number Diff line change
@@ -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);
}
42 changes: 27 additions & 15 deletions plugins/fun-simsimi.js
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3db8941

Please sign in to comment.