nonogamer9

BonziSeek (DeepSeek R1 For BonziWorld)

Jan 25th, 2026
1,122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 2.42 KB | Source Code | 0 0
  1. const prefix = "!";
  2. const botname = "BonziSeek (" + prefix + "ask)";
  3. const version = "1.0.1";
  4. const update = "April 13th, 2025";
  5. var uses = 0;
  6.  
  7. const OPENROUTER_API_KEY = "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";
  8. const OPENROUTER_API_URL = "https://openrouter.ai/api/v1/chat/completions";
  9.  
  10. const FREE_MODEL = "deepseek/deepseek-r1-0528:free";
  11.  
  12. async function queryOpenRouterAPI(inputText) {
  13.     try {
  14.         const response = await fetch(OPENROUTER_API_URL, {
  15.             method: "POST",
  16.             headers: {
  17.                 "Authorization": `Bearer ${OPENROUTER_API_KEY}`,
  18.                 "Content-Type": "application/json",
  19.                 "HTTP-Referer": window.location.href,
  20.                 "X-Title": "BonziSeek"
  21.             },
  22.             body: JSON.stringify({
  23.                 model: FREE_MODEL,
  24.                 messages: [{ role: "user", content: inputText }],
  25.                 max_tokens: 1000,
  26.                 temperature: 0.7
  27.             })
  28.         });
  29.  
  30.         const data = await response.json();
  31.        
  32.         if (response.ok) {
  33.             return data.choices[0].message.content;
  34.         } else {
  35.             console.error("API Error:", data);
  36.             if (response.status === 400) {
  37.                 return "❌ Model format issue. Visit https://openrouter.ai/models?free";
  38.             }
  39.             if (response.status === 402) {
  40.                 return "❌ **402**: Add $1 or verify phone: https://openrouter.ai/keys";
  41.             }
  42.             return `❌ Error ${response.status}: ${data.error?.message || 'Unknown error'}`;
  43.         }
  44.     } catch (error) {
  45.         console.error("Network error:", error);
  46.         return "❌ Network error. Check connection.";
  47.     }
  48. }
  49.  
  50. function sendMsg(msg) {
  51.     setTimeout(() => socket.emit("talk", { text: msg }), 1100);
  52. }
  53.  
  54. setTimeout(() => socket.emit("command", { list: ["name", botname] }), 1000);
  55. setTimeout(() => sendMsg("BonziSeek is online! DeepSeek R1 For BonziWorld! Type !ask {question} to ask DeepSeek R1!"), 2000);
  56.  
  57. socket.on("talk", async (msg) => {
  58.     if (msg.text.startsWith(prefix + "ask")) {
  59.         const query = msg.text.substring(prefix.length + 4).trim();
  60.         if (!query) return sendMsg("❓ `!ask your question` please");
  61.  
  62.         sendMsg("- DeepSeek R1 is thinking...");
  63.         const response = await queryOpenRouterAPI(query);
  64.         sendMsg(response);
  65.         uses++;
  66.     }
  67. });
  68.  
Advertisement
Add Comment
Please, Sign In to add comment