/** * ======================================================== * Name: QwertyBot AI - Multimodal & Code Generator Scraper * * Cara Download: * curl -sL "https://code.vamxapi.my.id/snippet/raw/qwertybot-ai" -o qwertybot-ai.js * * Cara Eksekusi: * node qwertybot-ai.js "Jelaskan konsep asynchronous JavaScript" * * Author: Vamz Spectre * Source: https://vamxapi.my.id * ======================================================== */ /** * Available Models: * - "gemini-flash-lite-latest" : qwertybot 4.0 Standard (Fast & Stable) * - "gemini-3.1-flash-lite" : qwertybot 4.5 Turbo (Lightweight & Dynamic) * - "gemini-3.1-pro-preview" : qwertybot 5.0 Pro (Complex Reasoning & Deep Analysis) */ async function qwertybot(message, options = {}) { const { model = "gemini-flash-lite-latest", sessionId = null, sessionCode = null, ownerId = "guest_" + Math.random().toString(36).substring(2, 10) + Date.now().toString(36), files = [] // Array of { buffer: Buffer|Uint8Array, filename: string, type: string } } = options; let activeSessionId = sessionId; let activeSessionCode = sessionCode; // 1. Inisialisasi sesi jika belum ada if (!activeSessionId || !activeSessionCode) { const sessionRes = await fetch("https://qwertybot.biz.id/api/sessions/new", { method: "POST", headers: { "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" }, body: JSON.stringify({ title: "Percakapan Baru", ownerId }) }); if (!sessionRes.ok) { throw new Error(`Failed to create session with status: ${sessionRes.status}`); } const sessionData = await sessionRes.json(); if (!sessionData?.success || !sessionData?.session) { throw new Error("Failed to initialize session: " + JSON.stringify(sessionData)); } activeSessionId = sessionData.session.id; activeSessionCode = sessionData.session.sessionCode; } // 2. Susun Payload Chat (Multipart / FormData) const form = new FormData(); form.append("sessionId", activeSessionId); form.append("sessionCode", activeSessionCode); form.append("message", message); form.append("ownerId", ownerId); form.append("isLoggedIn", "false"); form.append("selectedModel", model); form.append("adminToken", ""); // Optional: Lampiran File (Gambar, Dokumen, Audio) if (Array.isArray(files) && files.length > 0) { for (const item of files) { if (item.buffer) { const blob = new Blob([item.buffer], { type: item.type || "application/octet-stream" }); form.append("files", blob, item.filename || "file"); } } } // 3. Kirim Request Chat const chatRes = await fetch("https://qwertybot.biz.id/api/chat", { method: "POST", headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36" }, body: form }); if (!chatRes.ok) { throw new Error(`Chat request failed with status: ${chatRes.status}`); } const chatData = await chatRes.json(); if (!chatData?.success) { throw new Error("QwertyBot error: " + (chatData?.error || "Unknown error")); } return { success: true, sessionId: activeSessionId, sessionCode: activeSessionCode, ownerId, model, result: chatData.botMessage?.content || "", rawMessage: chatData.botMessage, quota: chatData.quota }; } /** * CLI Runner: * Langsung eksekusi jika dijalankan via terminal: node qwertybot-ai.js "prompt" */ const argPrompt = process.argv[2]; if (argPrompt) { qwertybot(argPrompt) .then(result => { console.log(JSON.stringify(result, null, 2)); }) .catch(err => { console.error(JSON.stringify({ success: false, error: err.message }, null, 2)); process.exit(1); }); } else if (process.argv[1] && process.argv.length <= 2) { console.log("Usage: node qwertybot-ai.js \"\""); } if (typeof module !== "undefined" && module.exports) { module.exports = { qwertybot, default: qwertybot }; }