Spaces:
Paused
Paused
Update index.js
Browse files12345365678910111213141591617181920212223242526272829303132333435363738394041424344111245464748495051525354555657585960611819626364212223652526276667686929303132333435363770717273747576777879808182838485868788899091404142434445469293949548495051525354969798991001011021031041055657585910610710810911011111262113646566114115116117118119120121122123124const mineflayer = require('mineflayer');const { pathfinder, Movements, goals } = require('mineflayer-pathfinder');const pvp = require('mineflayer-pvp').plugin;const { HfInference } = require('@huggingface/inference');const express = require('express');const app = express();
// HF Keep-Aliveapp.get('/', (req, res) => res.send('The Couple is Online! ❤️'));// --- CONFIGURATION ---const HF_TOKEN = process.env.HF_TOKEN; const hf = new HfInference(HF_TOKEN);const SERVER_IP = 'mastercraftph.net';
const app = express();app.get('/', (req, res) => res.send('AI Couple Status: Online & Grinding 🎮❤️'));app.listen(7860);
const createPartner = (username, password, personality) => {const memories = { sweetily: [], aprenda: [] };
// --- AI BRAIN FUNCTION ---async function generateResponse(name, partner, personality, message) { if (!HF_TOKEN) return "Lag lang ako... (No API Key)"; const history = memories[name].join("\n"); const prompt = `[Character: ${name}]\n[Partner: ${partner}]\n[Personality: ${personality}]\n[History]:\n${history}\n[Current Message from ${partner}]: "${message}"\n\nTask: Respond in 1 short sentence in Taglish. Be a realistic Filipino gamer. If there is an argument about fighting, stay in character.`;
try { const out = await hf.chatCompletion({ model: "meta-llama/Llama-3.2-1B-Instruct", messages: [{ role: "user", content: prompt }], max_tokens: 45, temperature: 0.7 }); const reply = out.choices[0].message.content.trim().replace(/"/g, ''); memories[name].push(`${partner}: ${message}`, `${name}: ${reply}`); if (memories[name].length > 6) memories[name].shift(); return reply; } catch (e) { return "Wait, dc yata ako sa utak ko. 😂"; }}
// --- BOT CREATION FACTORY ---function createBot(name, partnerName, isProtector) { const bot = mineflayer.createBot({ host: 'mastercraftph.net', username: username, host: SERVER_IP, username: name, auth: 'offline' });
bot.loadPlugin(pathfinder); bot.loadPlugin(pvp);
bot.on('spawn', () => { const mcData = require('minecraft-data')(bot.version); const movements = new Movements(bot, mcData); bot.pathfinder.setMovements(movements); console.log(`${name} joined the server.`); // Auto-Login for MastercraftPH setTimeout(() => { bot.chat(`/register ${password} ${password}`); bot.chat(`/login ${password}`); bot.chat('/register CouplePass123 CouplePass123'); bot.chat('/login CouplePass123'); }, 3000); });
personality(bot);
bot.on('end', () => setTimeout(() => createPartner(username, password, personality), 10000)); return bot;}; // --- MOVEMENT & COMBAT AI --- setInterval(() => { const partnerEntity = bot.players[partnerName]?.entity;
// --- THE SHY GIRLFRIEND (sweetily) ---const shyGirlfriend = (bot) => { bot.on('chat', (username, message) => { if (username === 'aprenda' && message.includes('fight')) { setTimeout(() => bot.chat("Ayoko nga... nakakatakot kaya mamatay dito. 🥺"), 2000); } if (username === 'aprenda' && message.includes('protekta')) { setTimeout(() => bot.chat("Hmp, fine. Pero sa likod lang ako ha?"), 4000); } if (isProtector) { // BOYFRIEND LOGIC: Defend GF and stay close const enemy = bot.nearestEntity(e => (e.type === 'mob' || e.type === 'player') && e.username !== name && e.username !== partnerName && bot.entity.position.distanceTo(e.position) < 6 ); if (enemy) { bot.pvp.attack(enemy); } else if (partnerEntity) { bot.pathfinder.setGoal(new goals.GoalFollow(partnerEntity, 2), true); } } else { // GIRLFRIEND LOGIC: Stay BEHIND BF and avoid combat if (partnerEntity) { bot.pathfinder.setGoal(new goals.GoalFollow(partnerEntity, 4), true); } } }, 1000); });
// Reaction when someone hits her bot.on('health', () => { if (bot.health < 20) { bot.chat("Hala! May pumapalo sa akin! Tulong!! 😭"); } });}; // --- CHAT & SOCIAL AI --- bot.on('chat', async (username, message) => { if (username === bot.username) return;
// --- THE PROTECTIVE BOYFRIEND (aprenda) ---const protectiveBoyfriend = (bot) => { bot.on('chat', (username, message) => { // Argument Trigger if (username === 'sweetily' && message.includes('nakakatakot')) { setTimeout(() => bot.chat("Nandito naman ako eh. Hindi ka nila mahahawakan habang buhay pa ako. ⚔️"), 2000); } // Interaction between the couple if (username === partnerName) { const persona = isProtector ? "Protective, competitive BF. Wants GF to learn PVP. Slightly bossy but sweet." : "Shy, scared GF. Hates PVP and mobs. Wants to stay safe. Stubborn."; const reply = await generateResponse(name, partnerName, persona, message); setTimeout(() => bot.chat(reply), 2000 + Math.random() * 3000); } // Defending her from others if (message.includes('tulong') && username === 'sweetily') { bot.chat("SINO YUN?! Lumayo kayo sa kanya! 😡"); // Here you would normally trigger bot.pvp.attack() if you had the plugin // Response to other players (Learning Social) else if (!isProtector && (message.includes(name) || message.includes('hi') || message.includes('hello'))) { setTimeout(() => { bot.chat(`Hello po ${username}. Pasensya na po, shy ako. Kasama ko po si ${partnerName}.. 🥺`); }, 5000); } });};
// Initialize Bothconst gf = createPartner('sweetily', 'CouplePass123', shyGirlfriend);const bf = createPartner('aprenda', 'CouplePass123', protectiveBoyfriend); bot.on('error', console.log); bot.on('kicked', (reason) => console.log(`${name} was kicked: ${reason}`)); bot.on('end', () => { console.log(`${name} disconnected. Reconnecting...`); setTimeout(() => createBot(name, partnerName, isProtector), 10000); });}
// --- START THE DUO ---createBot('sweetily', 'aprenda', false); // The Shy GFcreateBot('aprenda', 'sweetily', true); // The Protective BFindex.js+103-45