From 0279f9edd0d75eb775d9a875c3cddaba389bf12f Mon Sep 17 00:00:00 2001 From: Hokaf <162671743+enjaycorl@users.noreply.github.com> Date: Thu, 24 Apr 2025 02:25:38 +0800 Subject: [PATCH 1/2] Update ai.js --- script/commands/ai.js | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/script/commands/ai.js b/script/commands/ai.js index 0293cb0..4ff288b 100644 --- a/script/commands/ai.js +++ b/script/commands/ai.js @@ -1,6 +1,6 @@ module.exports.config = { name: "ai", - credits: "ryuko", + credits: "Opiar", version: '1.0.0', description: "talk with gemini 2.0 flash exp", prefix: false, @@ -12,7 +12,9 @@ module.exports.config = { "axios": "" } } + const axios = require("axios"); + module.exports.handleEvent = async function({api, event, botname }) { try { const ask = event.body?.toLowerCase() || ''; @@ -25,39 +27,33 @@ module.exports.handleEvent = async function({api, event, botname }) { .trim() .replace(/\s+([,.?!])/g, '$1'); - try { - const attachment = event.messageReply.attachments[0].url; - const res = await axios.get(`https://character.ryukodev.gleeze.com/api?name=gemini&message=${encodeURIComponent(processedAsk)}&imgUrl=${encodeURIComponent(attachment)}`); - const reply = res.data.message; - return api.sendMessage(reply, event.threadID, event.messageID); - } catch (err) { - const res = await axios.get(`https://character.ryukodev.gleeze.com/api?name=gemini&message=${encodeURIComponent(processedAsk)}`); - const reply = res.data.message; - return api.sendMessage(reply, event.threadID, event.messageID); - } + // Attempt to use the new message API first + const res = await axios.get(`https://opiar-e6fo.onrender.com/gemini?search=${encodeURIComponent(processedAsk)}`); + const reply = res.data.message; + + // Send the response back + return api.sendMessage(reply, event.threadID, event.messageID); } catch (error) { return api.sendMessage("failed to get a response from the api.", event.threadID, event.messageID); } } - } catch (error) {} + } catch (error) { + console.error(error); // Log the error for debugging + } }; + module.exports.run = async function({ api, event, args, botname }) { const ask = args.join(' '); if (!ask) { return api.sendMessage(`please provide a message`, event.threadID, event.messageID); } + try { - try { - const attachment = event.messageReply.attachments[0].url; - const res = await axios.get(`https://character.ryukodev.gleeze.com/api?name=gemini&message=${encodeURIComponent(ask)}&imgUrl=${encodeURIComponent(attachment)}`); - const reply = res.data.message; - return api.sendMessage(reply, event.threadID, event.messageID); - } catch (err) { - const res = await axios.get(`https://character.ryukodev.gleeze.com/api?name=gemini&message=${encodeURIComponent(ask)}`); - const reply = res.data.message; - return api.sendMessage(reply, event.threadID, event.messageID); - } + // Attempt to use the new message API first + const res = await axios.get(`https://opiar-e6fo.onrender.com/gemini?search=${encodeURIComponent(ask)}`); + const reply = res.data.message; + return api.sendMessage(reply, event.threadID, event.messageID); } catch (error) { return api.sendMessage("failed to get a response from the api.", event.threadID, event.messageID); } -} \ No newline at end of file +}; From 25a73460998cac4be3ebb4f4e9d1e5ea92897f4b Mon Sep 17 00:00:00 2001 From: Hokaf <162671743+enjaycorl@users.noreply.github.com> Date: Fri, 25 Apr 2025 03:57:51 +0800 Subject: [PATCH 2/2] Delete script/commands/ai.js --- script/commands/ai.js | 59 ------------------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 script/commands/ai.js diff --git a/script/commands/ai.js b/script/commands/ai.js deleted file mode 100644 index 4ff288b..0000000 --- a/script/commands/ai.js +++ /dev/null @@ -1,59 +0,0 @@ -module.exports.config = { - name: "ai", - credits: "Opiar", - version: '1.0.0', - description: "talk with gemini 2.0 flash exp", - prefix: false, - premium: true, - permission: 0, - category: "without prefix", - cooldowns: 0, - dependencies: { - "axios": "" - } -} - -const axios = require("axios"); - -module.exports.handleEvent = async function({api, event, botname }) { - try { - const ask = event.body?.toLowerCase() || ''; - if (ask.includes(botname.toLowerCase())) { - try { - const escapedBotname = botname.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - const processedAsk = ask - .replace(new RegExp(escapedBotname, 'gi'), '') - .replace(/\s+/g, ' ') - .trim() - .replace(/\s+([,.?!])/g, '$1'); - - // Attempt to use the new message API first - const res = await axios.get(`https://opiar-e6fo.onrender.com/gemini?search=${encodeURIComponent(processedAsk)}`); - const reply = res.data.message; - - // Send the response back - return api.sendMessage(reply, event.threadID, event.messageID); - } catch (error) { - return api.sendMessage("failed to get a response from the api.", event.threadID, event.messageID); - } - } - } catch (error) { - console.error(error); // Log the error for debugging - } -}; - -module.exports.run = async function({ api, event, args, botname }) { - const ask = args.join(' '); - if (!ask) { - return api.sendMessage(`please provide a message`, event.threadID, event.messageID); - } - - try { - // Attempt to use the new message API first - const res = await axios.get(`https://opiar-e6fo.onrender.com/gemini?search=${encodeURIComponent(ask)}`); - const reply = res.data.message; - return api.sendMessage(reply, event.threadID, event.messageID); - } catch (error) { - return api.sendMessage("failed to get a response from the api.", event.threadID, event.messageID); - } -};