-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Guru322/patch2
chatbot fixed
- Loading branch information
Showing
2 changed files
with
53 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |