Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const prefix = "!";
- const botname = "BonziSeek (" + prefix + "ask)";
- const version = "1.0.1";
- const update = "April 13th, 2025";
- var uses = 0;
- const OPENROUTER_API_KEY = "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";
- const OPENROUTER_API_URL = "https://openrouter.ai/api/v1/chat/completions";
- const FREE_MODEL = "deepseek/deepseek-r1-0528:free";
- async function queryOpenRouterAPI(inputText) {
- try {
- const response = await fetch(OPENROUTER_API_URL, {
- method: "POST",
- headers: {
- "Authorization": `Bearer ${OPENROUTER_API_KEY}`,
- "Content-Type": "application/json",
- "HTTP-Referer": window.location.href,
- "X-Title": "BonziSeek"
- },
- body: JSON.stringify({
- model: FREE_MODEL,
- messages: [{ role: "user", content: inputText }],
- max_tokens: 1000,
- temperature: 0.7
- })
- });
- const data = await response.json();
- if (response.ok) {
- return data.choices[0].message.content;
- } else {
- console.error("API Error:", data);
- if (response.status === 400) {
- return "❌ Model format issue. Visit https://openrouter.ai/models?free";
- }
- if (response.status === 402) {
- return "❌ **402**: Add $1 or verify phone: https://openrouter.ai/keys";
- }
- return `❌ Error ${response.status}: ${data.error?.message || 'Unknown error'}`;
- }
- } catch (error) {
- console.error("Network error:", error);
- return "❌ Network error. Check connection.";
- }
- }
- function sendMsg(msg) {
- setTimeout(() => socket.emit("talk", { text: msg }), 1100);
- }
- setTimeout(() => socket.emit("command", { list: ["name", botname] }), 1000);
- setTimeout(() => sendMsg("BonziSeek is online! DeepSeek R1 For BonziWorld! Type !ask {question} to ask DeepSeek R1!"), 2000);
- socket.on("talk", async (msg) => {
- if (msg.text.startsWith(prefix + "ask")) {
- const query = msg.text.substring(prefix.length + 4).trim();
- if (!query) return sendMsg("❓ `!ask your question` please");
- sendMsg("- DeepSeek R1 is thinking...");
- const response = await queryOpenRouterAPI(query);
- sendMsg(response);
- uses++;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment