forked from mahmud-aura/HINATA
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprompt.js
More file actions
44 lines (38 loc) · 1.38 KB
/
Copy pathprompt.js
File metadata and controls
44 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const axios = require("axios");
const baseApiUrl = async () => {
const base = await axios.get("https://raw.githubusercontent.com/mahmudx7/exe/main/baseApiUrl.json");
return base.data.mahmud;
};
module.exports = {
config: {
name: "prompt",
aliases: ["p"],
version: "1.7",
author: "MahMUD",
category: "ai",
guide: {
en: "{pn} reply with an image",
},
},
onStart: async function ({ api, args, event }) {
const apiUrl = `${await baseApiUrl()}/api/prompt`;
let prompt = args.join(" ") || "Describe this image";
if (event.type === "message_reply" && event.messageReply.attachments[0]?.type === "photo") {
try {
const response = await axios.post(apiUrl, {
imageUrl: event.messageReply.attachments[0].url,
prompt
}, {
headers: { "Content-Type": "application/json", "author": module.exports.config.author }
});
const reply = response.data.error || response.data.response || "No response";
api.sendMessage(reply, event.threadID, event.messageID);
return api.setMessageReaction("🪽", event.messageID, () => {}, true);
} catch (error) {
api.sendMessage("An error occurred. Please try again later.", event.threadID, event.messageID);
return api.setMessageReaction("❌", event.messageID, () => {}, true);
}
}
api.sendMessage("Please reply with an image.", event.threadID, event.messageID);
}
};