const axios = require("axios"); const simsim = "https://simsimi-api-tjb1.onrender.com"; const typing = async (api, threadID, ms = 3000) => { try { if (typeof api.sendTypingIndicator === "function") { await api.sendTypingIndicator(threadID, true); await new Promise(resolve => setTimeout(resolve, ms)); await api.sendTypingIndicator(threadID, false); } } catch {} }; module.exports = { config: { name: "baby", aliases: ["mari", "maria", "hippi", "xan", "bby", "bbz"], version: "3.6", author: "rX (fixed by GPT)", countDown: 0, role: 0, shortDescription: "Full Mirai-style Baby AI", longDescription: "Teachable AI + autoteach + list/msg/edit/remove + typing", category: "box chat", guide: { en: "{p}baby [message]\n{p}baby teach [q] - [a]\n{p}baby autoteach on/off\n{p}baby list\n{p}baby msg [trigger]\n{p}baby edit [q] - [old] - [new]\n{p}baby remove/rm [q] - [a]" } }, onStart: async function ({ api, event, args, message, usersData }) { const senderID = event.senderID; const senderName = await usersData.getName(senderID); const threadID = event.threadID; const query = args.join(" ").trim().toLowerCase(); try { // no text => random reply if (!query) { await typing(api, threadID, 2000); const ran = ["Bolo baby ๐Ÿ’–", "Hea baby ๐Ÿ˜š", "Yes I'm here ๐Ÿ˜˜", "Ki khobor janu? ๐Ÿฅฐ"]; return message.reply(ran[Math.floor(Math.random() * ran.length)], (err, info) => { if (!err) global.GoatBot.onReply.set(info.messageID, { commandName: "baby" }); }); } // AUTOTEACH TOGGLE if (args[0] === "autoteach") { const mode = args[1]?.toLowerCase(); if (!["on","off"].includes(mode)) return message.reply("Use: baby autoteach on/off"); const status = mode === "on"; await axios.post(`${simsim}/setting`, { autoTeach: status }, { timeout: 10000 }); return message.reply(`โœ… Auto teach now ${status ? "ON ๐ŸŸข" : "OFF ๐Ÿ”ด"}`); } // LIST if (args[0] === "list") { const res = await axios.get(`${simsim}/list`, { timeout: 10000 }); return message.reply( `โ•ญโ”€โ•ผ๐ŸŒŸ ๐๐š๐›๐ฒ ๐€๐ˆ ๐’๐ญ๐š๐ญ๐ฎ๐ฌ โ”œ ๐Ÿ“ ๐“๐ž๐š๐œ๐ก๐ž๐ ๐๐ฎ๐ž๐ฌ๐ญ๐ข๐จ๐ง๐ฌ: ${res.data.totalQuestions || 0} โ”œ ๐Ÿ“ฆ ๐’๐ญ๐จ๐ซ๐ž๐ ๐‘๐ž๐ฉ๐ฅ๐ข๐ž๐ฌ: ${res.data.totalReplies || 0} โ•ฐโ”€โ•ผ๐Ÿ‘ค ๐ƒ๐ž๐ฏ: rX ๐€๐›๐๐ฎ๐ฅ๐ฅ๐š๐ก` ); } // MSG if (args[0] === "msg") { const trigger = args.slice(1).join(" ").trim(); if (!trigger) return message.reply("Use: baby msg [trigger]"); const res = await axios.get(`${simsim}/simsimi-list?ask=${encodeURIComponent(trigger)}`, { timeout: 10000 }); if (!res.data.replies?.length) return message.reply("โŒ No replies found for this trigger."); const formatted = res.data.replies.map((rep, i) => `โžค ${i+1}. ${rep}`).join("\n"); return message.reply( `๐Ÿ“Œ ๐—ง๐—ฟ๐—ถ๐—ด๐—ด๐—ฒ๐—ฟ: ${trigger.toUpperCase()} ๐Ÿ“‹ ๐—ง๐—ผ๐˜๐—ฎ๐—น ๐—ฅ๐—ฒ๐—ฝ๐—น๐—ถ๐—ฒ๐˜€: ${res.data.total || res.data.replies.length} โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ” ${formatted}` ); } // TEACH if (args[0] === "teach") { const parts = query.replace(/^teach\s+/i, "").split(" - "); if (parts.length < 2) return message.reply("Use: baby teach question - answer"); const [ask, ans] = parts.map(s => s.trim()); const res = await axios.get(`${simsim}/teach?ask=${encodeURIComponent(ask)}&ans=${encodeURIComponent(ans)}&senderName=${encodeURIComponent(senderName)}&senderID=${senderID}`, { timeout: 10000 }); return message.reply(res.data.message || "โœ… Taught successfully!"); } // EDIT if (args[0] === "edit") { const parts = query.replace(/^edit\s+/i, "").split(" - "); if (parts.length < 3) return message.reply("Use: baby edit question - old reply - new reply"); const [ask, oldR, newR] = parts.map(s => s.trim()); const res = await axios.get(`${simsim}/edit?ask=${encodeURIComponent(ask)}&old=${encodeURIComponent(oldR)}&new=${encodeURIComponent(newR)}`, { timeout: 10000 }); return message.reply(res.data.message || "โœ… Edited successfully!"); } // REMOVE / RM if (["remove","rm"].includes(args[0])) { const parts = query.replace(/^(remove|rm)\s+/i, "").split(" - "); if (parts.length < 2) return message.reply("Use: baby remove question - answer"); const [ask, ans] = parts.map(s => s.trim()); const res = await axios.get(`${simsim}/delete?ask=${encodeURIComponent(ask)}&ans=${encodeURIComponent(ans)}`, { timeout: 10000 }); return message.reply(res.data.message || "โœ… Removed successfully!"); } // Normal chat await typing(api, threadID, 2000); const res = await axios.get(`${simsim}/simsimi?text=${encodeURIComponent(query)}&senderName=${encodeURIComponent(senderName)}`, { timeout: 15000 }); let responses = Array.isArray(res.data.response) ? res.data.response : [res.data.response || "Hmm baby ๐Ÿ˜š"]; for (const r of responses) { await new Promise(resolve => { message.reply(r, (err, info) => { if (!err) global.GoatBot.onReply.set(info.messageID, { commandName: "baby" }); resolve(); }); }); } } catch (err) { console.error("Baby command error:", err.message); message.reply("โŒ Error: " + (err.message.includes("404") ? "Feature not available (backend issue)" : err.message)); } }, onReply: async function ({ api, event, message, usersData }) { const text = event.body?.trim(); if (!text) return; const senderName = await usersData.getName(event.senderID); try { await typing(api, event.threadID, 2000); const res = await axios.get(`${simsim}/simsimi?text=${encodeURIComponent(text)}&senderName=${encodeURIComponent(senderName)}`, { timeout: 15000 }); const replies = Array.isArray(res.data.response) ? res.data.response : [res.data.response]; for (const r of replies) { await message.reply(r, (err, info) => { if (!err) global.GoatBot.onReply.set(info.messageID, { commandName: "baby" }); }); } } catch (err) { console.error("onReply error:", err.message); } }, onChat: async function ({ api, event, message, usersData }) { const raw = event.body ? event.body.toLowerCase().trim() : ""; if (!raw) return; const senderID = event.senderID; const senderName = await usersData.getName(senderID); const threadID = event.threadID; try { // triggers only const triggers = ["baby","bby","xan","bbz","mari","เฆฎเฆพเฆฐเฆฟเฆฏเฆผเฆพ","bot"]; if (triggers.includes(raw)) { await typing(api, threadID, 5000); const funny = [ "๐˜ฌ๐˜ช ๐˜๐˜ฐ๐˜ช๐˜ด๐˜ฆ ๐˜‘๐˜ข๐˜ฏ ๐˜ฃ๐˜ฐ๐˜ญ๐˜ฐ ๐Ÿ˜ฟ", "๐˜Œ๐˜ต๐˜ฐ ๐˜‹๐˜ข๐˜ฌ๐˜ฐ ๐˜’๐˜ฆ๐˜ฏ ๐˜š๐˜ถ๐˜ฏ๐˜ด๐˜ช ๐˜›๐˜ฐ ๐Ÿ™†โ€โ™€๏ธ", "๐˜Œ๐˜ต๐˜ฐ ๐˜‰๐˜ฐ๐˜ต ๐˜‰๐˜ฐ๐˜ต ๐˜’๐˜ฐ๐˜ณ๐˜ญ๐˜ฆ ๐˜“๐˜ฆ๐˜ข๐˜ท๐˜ฆ ๐˜•๐˜ช๐˜ฎ๐˜ถ ๐Ÿ™‚", "๐˜›๐˜ถ๐˜ฎ๐˜ช ๐˜‹๐˜ข๐˜ฌ๐˜ญ๐˜ฆ๐˜ช ๐˜Š๐˜ฐ๐˜ญ๐˜ฆ ๐˜ˆ๐˜ด๐˜ช ๐Ÿ™†โ€โ™€๏ธ", "เฆ“เฆ‡ เฆœเฆพเฆจ เฆเฆคเง‹เฆฌเฆพเฆฐ เฆกเฆพเฆ•เง‹ เฆ•เง‡เฆจ ๐Ÿฅน", "เฆ†เฆฎเฆพเฆ•เง‡ เฆจเฆพ เฆกเง‡เฆ•เง‡ เฆ†เฆ•เฆพเฆถ เฆญเฆพเฆ‡ เฆ•เง‡ เฆชเงเฆฐเง‹เฆชเง‹เฆœ เฆ•เฆฐ ๐ŸŒท๐Ÿซถ", "เฆนเงเฆฎ เฆฌเฆฒเง‹ เฆชเฆพเฆ–เฆฟ ๐Ÿซถ๐Ÿค ", "เฆคเงเฆฎเฆพเฆฐเง‡ เฆฐเฆพเฆ‡เฆคเง‡ เฆญเฆพเฆฒเง‹เฆฌเฆพเฆธเฆฟ ๐Ÿ˜˜", "เฆ†เฆฎเฆพเฆ•เง‡ เฆกเฆพเฆ•เฆ›เง‹? ๐Ÿ™‚" ]; return message.reply(funny[Math.floor(Math.random() * funny.length)], (err, info) => { if (!err) global.GoatBot.onReply.set(info.messageID, { commandName: "baby" }); }); } // prefixes const prefixes = ["baby ","bby ","xan ","bbz ","mari ","เฆฎเฆพเฆฐเฆฟเฆฏเฆผเฆพ ","bot "]; const prefix = prefixes.find(p => raw.startsWith(p)); if (prefix) { const q = raw.replace(prefix,"").trim(); if (!q) return; await typing(api, threadID, 2000); const res = await axios.get(`${simsim}/simsimi?text=${encodeURIComponent(q)}&senderName=${encodeURIComponent(senderName)}`, { timeout: 15000 }); const replies = Array.isArray(res.data.response) ? res.data.response : [res.data.response]; for (const r of replies) { await message.reply(r, (err, info) => { if (!err) global.GoatBot.onReply.set(info.messageID, { commandName: "baby" }); }); } return; } // AUTO-TEACH from reply if (event.messageReply) { try { const setting = await axios.get(`${simsim}/setting`, { timeout: 8000 }); if (setting.data?.autoTeach) { const ask = event.messageReply.body?.toLowerCase().trim(); const ans = raw.trim(); if (ask && ans && ask !== ans) { setTimeout(async () => { try { await axios.get(`${simsim}/teach?ask=${encodeURIComponent(ask)}&ans=${encodeURIComponent(ans)}&senderName=${encodeURIComponent(senderName)}`, { timeout: 10000 }); } catch {} }, 500); } } } catch {} } } catch (err) { console.error("onChat error:", err.message); } } };