Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const prefix = "mem!";
- const botname = "MemphisAI (" + prefix + "ask)";
- const version = "1.0.1";
- const update = "April 13th, 2025";
- var uses = 0;
- const PUTER_JS_URL = "https://js.puter.com/v2/";
- function sendMsg(msg) {
- setTimeout(() => {
- socket.emit("talk", { text: msg });
- }, 1100);
- }
- async function queryPuterAPI(inputText) {
- try {
- const response = await puter.ai.chat(inputText);
- return response || "The AI couldn't generate a proper response.";
- } catch (error) {
- console.error("Error querying Puter.js API:", error);
- return "Sorry, I couldn't process your request.";
- }
- }
- const script = document.createElement("script");
- script.src = PUTER_JS_URL;
- document.head.appendChild(script);
- setTimeout(() => {
- socket.emit("command", { list: ["name", botname] });
- }, 1000);
- setTimeout(() => {
- sendMsg("MemphisAI is online. Type " + prefix + "ask {question} to interact with AI.");
- }, 2000);
- socket.on("talk", async (message) => {
- if (message.text.startsWith(prefix + "ask")) {
- const userQuery = message.text.substring(prefix.length + 3).trim();
- if (!userQuery) {
- sendMsg("Please provide a question or prompt after '" + prefix + "ask'.");
- return;
- }
- sendMsg("- Processing your query...");
- const aiResponse = await queryPuterAPI(userQuery);
- sendMsg(`**AI Response:** ${aiResponse}`);
- uses++;
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement