Artboxbonzu

Untitled

Nov 21st, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. const prefix = "hit!";
  2. const botname = "Hitbot (a? + prefix + "ask)";
  3. const version = "1.0.0.0";
  4.  
  5. const PUTER_JS_URL = "https://js.puter.com/v2/";
  6.  
  7. function sendMsg(msg) {
  8. setTimeout(() => {
  9. socket.emit("talk", { text: msg });
  10. }, 1100);
  11. }
  12.  
  13. async function queryPuterAPI(inputText) {
  14. try {
  15. const response = await puter.ai.chat(inputText);
  16. return response || "The AI couldn't generate a proper response.";
  17. } catch (error) {
  18. console.error("Error querying Puter.js API:", error);
  19. return "Sorry, I couldn't process your request.";
  20. }
  21. }
  22.  
  23. const script = document.createElement("script");
  24. script.src = PUTER_JS_URL;
  25. document.head.appendChild(script);
  26.  
  27. setTimeout(() => {
  28. socket.emit("command", { list: ["name", botname] });
  29. }, 1000);
  30.  
  31. setTimeout(() => {
  32. sendMsg("MemphisAI is online. Type " + prefix + "ask {question} to interact with AI.");
  33. }, 2000);
  34.  
  35. socket.on("talk", async (message) => {
  36. if (message.text.startsWith(prefix + "ask")) {
  37. const userQuery = message.text.substring(prefix.length + 3).trim();
  38. if (!userQuery) {
  39. sendMsg("Please provide a question or prompt after '" + prefix + "ask'.");
  40. return;
  41. }
  42.  
  43. sendMsg("- Processing your query...");
  44.  
  45. const aiResponse = await queryPuterAPI(userQuery);
  46. sendMsg(`**AI Response:** ${aiResponse}`);
  47. uses++;
  48. }
  49. });
  50.  
Advertisement
Add Comment
Please, Sign In to add comment