Spaces:
Paused
Paused
Update index.js
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566const mineflayer = require('mineflayer');const express = require('express');const app = express();// HF Keep-Aliveapp.get('/', (req, res) => res.send('The Couple is Online! ❤️'));app.listen(7860);const createPartner = (username, password, personality) => {const bot = mineflayer.createBot({host: 'mastercraftph.net',username: username,auth: 'offline'});bot.on('spawn', () => {setTimeout(() => {bot.chat(`/register ${password} ${password}`);bot.chat(`/login ${password}`);}, 3000);});personality(bot);bot.on('end', () => setTimeout(() => createPartner(username, password, personality), 10000));return bot;};// --- 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);}});// Reaction when someone hits herbot.on('health', () => {if (bot.health < 20) {bot.chat("Hala! May pumapalo sa akin! Tulong!! 😭");}});};// --- THE PROTECTIVE BOYFRIEND (aprenda) ---const protectiveBoyfriend = (bot) => {bot.on('chat', (username, message) => {// Argument Triggerif (username === 'sweetily' && message.includes('nakakatakot')) {setTimeout(() => bot.chat("Nandito naman ako eh. Hindi ka nila mahahawakan habang buhay pa ako. ⚔️"), 2000);}// Defending her from othersif (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}});};// Initialize Bothconst gf = createPartner('sweetily', 'CouplePass123', shyGirlfriend);const bf = createPartner('aprenda', 'CouplePass123', protectiveBoyfriend);123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124const 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');// --- 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 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: 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 MastercraftPHsetTimeout(() => {bot.chat('/register CouplePass123 CouplePass123');bot.chat('/login CouplePass123');}, 3000);// --- MOVEMENT & COMBAT AI ---setInterval(() => {const partnerEntity = bot.players[partnerName]?.entity;if (isProtector) {// BOYFRIEND LOGIC: Defend GF and stay closeconst 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 combatif (partnerEntity) {bot.pathfinder.setGoal(new goals.GoalFollow(partnerEntity, 4), true);}}}, 1000);});// --- CHAT & SOCIAL AI ---bot.on('chat', async (username, message) => {if (username === bot.username) return;// Interaction between the coupleif (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);}// 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);}});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 BF
index.js+103-45