Advertisement
samiroexpikachu

Gemini flash

Jun 9th, 2024 (edited)
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const a = require("axios"),
  2.       t = require("tinyurl");
  3.  
  4. global.api = {
  5.   s: "https://samirxpikachu.onrender.com"
  6. };
  7.  
  8. const fm = {
  9.   ' ': ' ',
  10.   'a': '๐š', 'b': '๐›', 'c': '๐œ', 'd': '๐', 'e': '๐ž', 'f': '๐Ÿ', 'g': '๐ ', 'h': '๐ก',
  11.   'i': '๐ข', 'j': '๐ฃ', 'k': '๐ค', 'l': '๐ฅ', 'm': '๐ฆ', 'n': '๐ง', 'o': '๐จ', 'p': '๐ฉ', 'q': '๐ช',
  12.   'r': '๐ซ', 's': '๐ฌ', 't': '๐ญ', 'u': '๐ฎ', 'v': '๐ฏ', 'w': '๐ฐ', 'x': '๐ฑ', 'y': '๐ฒ', 'z': '๐ณ',
  13.   'A': '๐€', 'B': '๐', 'C': '๐‚', 'D': '๐ƒ', 'E': '๐„', 'F': '๐…', 'G': '๐†', 'H': '๐‡',
  14.   'I': '๐ˆ', 'J': '๐‰', 'K': '๐Š', 'L': '๐‹', 'M': '๐Œ', 'N': '๐', 'O': '๐Ž', 'P': '๐', 'Q': '๐',
  15.   'R': '๐‘', 'S': '๐’', 'T': '๐“', 'U': '๐”', 'V': '๐•', 'W': '๐–', 'X': '๐—', 'Y': '๐˜', 'Z': '๐™',
  16. };
  17.  
  18. function ctf(t) {
  19.   let ct = '';
  20.   for (let c of t) {
  21.     ct += fm[c] || c;
  22.   }
  23.   return ct;
  24. }
  25.  
  26. function cba(t) {
  27.   return t.replace(/\*(.*?)\*/g, (m, p1) => ctf(p1));
  28. }
  29.  
  30. module.exports = {
  31.   config: {
  32.     name: "gemini",
  33.     aliases: ["bard"],
  34.     version: "1.0",
  35.     author: "Samir OE",
  36.     countDown: 5,
  37.     role: 0,
  38.     category: "๐—”๐—œ"
  39.   },
  40.   onStart: async function({
  41.     message: m,
  42.     event: e,
  43.     args: r,
  44.     commandName: n
  45.   }) {
  46.     try {
  47.       let s;
  48.       const i = e.senderID;
  49.       if ("message_reply" === e.type && ["photo", "sticker"].includes(e.messageReply.attachments?.[0]?.type)) {
  50.         s = await t.shorten(e.messageReply.attachments[0].url);
  51.       } else {
  52.         const o = r.join(" "),
  53.               c = await a.get(`${global.api.s}/Gemini?text=${encodeURIComponent(o)}&uid=${i}`);
  54.         if (c.data && c.data.candidates && c.data.candidates.length > 0) {
  55.           const t = c.data.candidates[0].content.parts[0].text,
  56.                 e = `${cba(t)}`;
  57.           m.reply({
  58.             body: e
  59.           }, (r, o) => {
  60.             global.GoatBot.onReply.set(o.messageID, {
  61.               commandName: n,
  62.               messageID: o.messageID,
  63.               author: i
  64.             })
  65.           })
  66.         }
  67.       }
  68.       if (!s) return void console.error("Error: Invalid message or attachment type");
  69.       const d = `${global.api.s}/telegraph?url=${encodeURIComponent(s)}&senderId=${i}`,
  70.             p = await a.get(d),
  71.             u = p.data.result.link,
  72.             o = r.join(" "),
  73.             f = `${global.api.s}/gemini-pro?text=${encodeURIComponent(o)}&url=${encodeURIComponent(u)}`;
  74.       m.reply({
  75.         body: (await a.get(f)).data
  76.       })
  77.     } catch (t) {
  78.       console.error("Error:", t.message)
  79.     }
  80.   },
  81.   onReply: async function({
  82.     message: m,
  83.     event: e,
  84.     Reply: r,
  85.     args: n
  86.   }) {
  87.     try {
  88.       let {
  89.         author: o,
  90.         commandName: c
  91.       } = r;
  92.       if (e.senderID !== o) return;
  93.       const i = n.join(" "),
  94.             d = await a.get(`${global.api.s}/Gemini?text=${encodeURIComponent(i)}&uid=${e.senderID}`);
  95.       if (d.data && d.data.candidates && d.data.candidates.length > 0) {
  96.         const t = d.data.candidates[0].content.parts[0].text,
  97.               r = `${cba(t)}`;
  98.         m.reply({
  99.           body: r
  100.         }, (t, n) => {
  101.           global.GoatBot.onReply.set(n.messageID, {
  102.             commandName: c,
  103.             messageID: n.messageID,
  104.             author: e.senderID
  105.           })
  106.         })
  107.       }
  108.     } catch (t) {
  109.       console.error("Error:", t.message)
  110.     }
  111.   }
  112. }
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement