javascript
59 lines ยท 1,283 chars
import axios from "axios";
import te from "../../src/lib/ourin-error.js";
const pluginConfig = {
name: "ai",
alias: ["ask"],
category: "ai",
description: "Chat dengan AI Claude",
usage: ".claude <pertanyaan>",
example: ".claude apa itu javascript",
isOwner: false,
isPremium: false,
isGroup: false,
isPrivate: false,
cooldown: 5,
energi: 1,
isEnabled: true,
};
async function askClaude(query) {
const url = `https://api.azbry.com/api/ai/claude?q=${encodeURIComponent(query)}`;
const res = await axios.get(url, {
timeout: 120000,
headers: {
"user-agent": "Mozilla/5.0",
accept: "application/json",
},
});
if (!res.data?.status || !res.data?.result) {
throw new Error("Claude AI gagal merespon");
}
return res.data.result;
}
async function handler(m, { text }) {
if (!text) {
return m.reply(
`๐ค *AI*\n\nMasukkan pertanyaan\n\nContoh:\n\`${m.prefix}ai halo\``,
);
}
m.react("๐");
try {
const result = await askClaude(text);
m.react("โ
");
m.reply(result);
} catch (error) {
console.log(error);
m.react("โข");
m.reply(te(m.prefix, m.command, m.pushName));
}
}
export { pluginConfig as config, handler };