Skip to content

Commit

Permalink
Update config.js, package.json, and add GURU-gemini.js, _chatbot.js, …
Browse files Browse the repository at this point in the history
…bingimg.js plugins
  • Loading branch information
Guru322 committed Dec 29, 2023
1 parent 59845ef commit 7d90b5f
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ global.botname = 'ᴛʜᴇ ɢᴜʀᴜ-ʙᴏᴛ'
global.premium = 'true'
global.packname = 'GURU┃ᴮᴼᵀ'
global.author = '@Asliguru'
global.menuvid = 'https://telegra.ph/file/085c4b1068f0f4f8db970.mp4'
global.menuvid = 'https://i.imgur.com/AjDzGgG.mp4'
global.igfg = '▢ Follow on Instagram\nhttps://www.instagram.com/asli_guru69\n'
global.dygp = 'https://chat.whatsapp.com/BibVE6tUICp3qOm2a1Ur8f'
global.dygp = 'https://chat.whatsapp.com/BFfD1C0mTDDDfVdKPkxRAA'
global.fgsc = 'https://github.com/Guru322/GURU-BOT'
global.fgyt = 'https://youtube.com/@Asliguru'
global.fgpyp = 'https://youtube.com/@Asliguru'
Expand All @@ -72,7 +72,7 @@ global.error = '❌'
global.xmoji = '🔥'

global.multiplier = 69
global.maxwarn = '3' // máxima advertencias
global.maxwarn = '3'

let file = fileURLToPath(import.meta.url)
watchFile(file, () => {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"file-type": "^18.0.0",
"fluent-ffmpeg": "^2.1.2",
"formdata-node": "^5.0.0",
"@google/generative-ai":"0.1.3",
"heroku-client": "^3.1.0",
"human-readable": "^0.2.1",
"instagram-url-direct": "^1.0.12",
Expand Down
27 changes: 27 additions & 0 deletions plugins/GURU-gemini.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {GoogleGenerativeAI} from '@google/generative-ai'

const genAI = new GoogleGenerativeAI('AIzaSyDJC5a882ruaC4XL6ejY1yhgRkN-JNQKg8');


let handler = async (m, { conn, text, args, usedPrefix, command }) => {
try {
if (!text) throw `uhm.. what do you want to say?`
m.react('🤖')
const model = genAI.getGenerativeModel({ model: "gemini-pro" });

const prompt = text

const result = await model.generateContent(prompt);
const response = result.response;
const textt = response.text();
m.reply(textt)
} catch (error) {
console.error(error);
m.reply('Oops! Something went wrong. , we are trying had to fix it asap');
}
}
handler.help = ['gemini <text>']
handler.tags = ['tools']
handler.command = /^(gemini)$/i

export default handler
69 changes: 69 additions & 0 deletions plugins/_chatbot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import fetch from 'node-fetch';
import axios from 'axios';

export async function before(m, { conn }) {
try {
if (m.isBaileys && m.fromMe) {
return true;
}

if (!m.isGroup) {
return false;
}

const users = global.db.data.users;
const chats = global.db.data.chats;

const user = global.db.data.users[m.sender];
const chat = global.db.data.chats[m.chat];
let name = conn.getName(m.sender)
if (m.mtype === 'protocolMessage' || m.mtype === 'pollUpdateMessage' || m.mtype === 'reactionMessage' || m.mtype === 'stickerMessage') {
return;
}

if (!m.msg || !m.message || m.key.remoteJid !== m.chat || users[m.sender].banned || chats[m.chat].isBanned) {
return;
}

if (!m.quoted ||!m.quoted.isBaileys) return

if (!chat.chatbot) {
return true;
}

const msg = encodeURIComponent(m.text);
console.log(msg)

const response = await axios.post('https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=AIzaSyDJC5a882ruaC4XL6ejY1yhgRkN-JNQKg8', {
contents: [{
parts: [{
text: msg
}]
}]
});

const data = response.data;
if (data.candidates && data.candidates.length > 0) {
const candidate = data.candidates[0];
const content = candidate.content;


let reply = content.parts[0].text;
if (reply) {
reply = reply.replace(/Google/gi, 'Guru');
reply = reply.replace(/a large language model/gi, botname);

m.reply(reply);
}

} else {

m.reply("No suitable response from the API.");

}
} catch (error) {
console.log(error);

}
}

19 changes: 19 additions & 0 deletions plugins/bingimg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import fetch from 'node-fetch'

let handler = async (m, { conn, text }) => {
if (!text) throw 'What do you want to create?'
m.react(rwait)
let msg = encodeURIComponent(text)
let res = await fetch(`https://aemt.me/bingimg?text=${msg}`)
let data = await res.json()
console.log(data)
let buffer = data.result
conn.sendFile(m.chat, buffer, 'image.png', `${text}`, m)
m.react(done)
}

handler.help = ['bingimg <query>']
handler.tags = ['AI']
handler.command = /^bingimg$/i

export default handler
2 changes: 2 additions & 0 deletions plugins/main-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ import {
◈ .ai
◈ .bard
◈ .alexa
◈ .bingimg
◈ .gemini
╰──────────⳹
`
let religionmenu = `
Expand Down

0 comments on commit 7d90b5f

Please sign in to comment.