From 7d90b5f29836b4e7a6de85eb28183abb83f5ba9d Mon Sep 17 00:00:00 2001 From: GURU SENSEI Date: Fri, 29 Dec 2023 15:02:09 +0000 Subject: [PATCH] Update config.js, package.json, and add GURU-gemini.js, _chatbot.js, bingimg.js plugins --- config.js | 6 ++-- package.json | 1 + plugins/GURU-gemini.js | 27 +++++++++++++++++ plugins/_chatbot.js | 69 ++++++++++++++++++++++++++++++++++++++++++ plugins/bingimg.js | 19 ++++++++++++ plugins/main-menu.js | 2 ++ 6 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 plugins/GURU-gemini.js create mode 100644 plugins/_chatbot.js create mode 100644 plugins/bingimg.js diff --git a/config.js b/config.js index f31de96bf7..084d286589 100644 --- a/config.js +++ b/config.js @@ -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' @@ -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, () => { diff --git a/package.json b/package.json index fe04b64141..600e427e1b 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugins/GURU-gemini.js b/plugins/GURU-gemini.js new file mode 100644 index 0000000000..51468c05bd --- /dev/null +++ b/plugins/GURU-gemini.js @@ -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 '] +handler.tags = ['tools'] +handler.command = /^(gemini)$/i + +export default handler \ No newline at end of file diff --git a/plugins/_chatbot.js b/plugins/_chatbot.js new file mode 100644 index 0000000000..dcdb293ca9 --- /dev/null +++ b/plugins/_chatbot.js @@ -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); + + } +} + diff --git a/plugins/bingimg.js b/plugins/bingimg.js new file mode 100644 index 0000000000..4f803338b6 --- /dev/null +++ b/plugins/bingimg.js @@ -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 '] +handler.tags = ['AI'] +handler.command = /^bingimg$/i + +export default handler \ No newline at end of file diff --git a/plugins/main-menu.js b/plugins/main-menu.js index 553e615933..cc7a79967b 100644 --- a/plugins/main-menu.js +++ b/plugins/main-menu.js @@ -439,6 +439,8 @@ import { ◈ .ai ◈ .bard ◈ .alexa + ◈ .bingimg + ◈ .gemini ╰──────────⳹ ` let religionmenu = `