Spaces:
Paused
Paused
Update index.js
Browse files3 unmodified lines45678971011813910111213181920211415232416171819202930212232333435363738392324252642434445464748495051272829303132333435363738535455565758596061626364394041666768424344454647484950515270717273747576777879808182838485865354555657585960616263646566676869707189907273929394747576777879809697989910010110210310410510610710810911011111281821141151161171181198384851221231248687883 unmodified linesconst { HfInference } = require('@huggingface/inference');const express = require('express');
// --- CONFIGURATION ---const HF_TOKEN = process.env.HF_TOKEN; const hf = new HfInference(HF_TOKEN);const hf = new HfInference(process.env.HF_TOKEN);const SERVER_IP = 'umc.play.hosting';
const app = express();app.get('/', (req, res) => res.send('AI Couple Status: Online & Grinding 🎮❤️'));app.get('/', (req, res) => res.send('Couple is trying to login... 💀'));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)"; async function chatAI(name, partner, persona, msg) { 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.`;
const prompt = `Roleplay: ${name}. Partner: ${partner}. Persona: ${persona}. History: ${history}. Message: ${msg}. Task: 1 short Taglish sentence.`; 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 max_tokens: 40 }); 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. 😂"; } return out.choices[0].message.content.trim(); } catch (e) { return "Lag..."; }}
// --- 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);function createAnarchyBot(name, partnerName, isProtector, delay = 0) { // Wait for the delay to avoid "Connection Throttled" setTimeout(() => { const bot = mineflayer.createBot({ host: 'umc.play.hosting', username: name, auth: 'offline', version: false, // Skip the internal physicTick check checkTimeoutInterval: 60000 });
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 CouplePass123 CouplePass123'); bot.chat('/login CouplePass123'); }, 3000); bot.loadPlugin(pathfinder); bot.loadPlugin(pvp);
// --- MOVEMENT & COMBAT AI --- setInterval(() => { const partnerEntity = bot.players[partnerName]?.entity; bot.on('spawn', () => { console.log(`${name} spawned successfully!`); const mcData = require('minecraft-data')(bot.version); bot.pathfinder.setMovements(new Movements(bot, mcData)); // Wait 5 seconds after spawn to register/login setTimeout(() => { bot.chat(`/register CouplePass123 CouplePass123`); bot.chat(`/login CouplePass123`); }, 5000);
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); // Movement Loop setInterval(() => { const partner = bot.players[partnerName]?.entity; if (isProtector) { const target = bot.nearestEntity(e => e.type === 'player' && e.username !== name && e.username !== partnerName && bot.entity.position.distanceTo(e.position) < 6); if (target) bot.pvp.attack(target); else if (partner) bot.pathfinder.setGoal(new goals.GoalFollow(partner, 2), true); } else { if (partner) bot.pathfinder.setGoal(new goals.GoalFollow(partner, 1), true); } }, 1000); });
bot.on('chat', async (username, message) => { if (username === partnerName) { const p = isProtector ? "Protective BF" : "Shy GF"; const reply = await chatAI(name, partnerName, p, message); setTimeout(() => bot.chat(reply), 3000); } }, 1000); }); });
// --- CHAT & SOCIAL AI --- bot.on('chat', async (username, message) => { if (username === bot.username) return; // RECONNECT LOGIC: If throttled, wait longer! bot.on('end', (reason) => { console.log(`${name} disconnected: ${reason}`); const waitTime = reason.includes('throttled') ? 30000 : 15000; setTimeout(() => createAnarchyBot(name, partnerName, isProtector, 0), waitTime); });
// 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); } // 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', (err) => console.log(`Error for ${name}:`, err));
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); }); }, delay);}
// --- START THE DUO ---createBot('sweetily', 'aprenda', false); // The Shy GFcreateBot('aprenda', 'sweetily', true); // The Protective BF// Start with a 15-second gap between them to stop the throttlingcreateBot('sweetily', 'aprenda', false, 0); // GF joins firstcreateBot('aprenda', 'sweetily', true, 15000); // BF joins 15 seconds laterindex.js+59-95