Spaces:
Paused
Paused
Update index.js
Browse files5 unmodified lines67899101112131415161516171811 unmodified lines303132343334353637383940414142434445464748495051525354554856575859606153626364656 unmodified lines72737466757677787971727374808182837784858687888990918283849293945 unmodified lines
const hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('Couple is trying to login... 💀'));app.get('/', (req, res) => res.send('Anarchy Duo is Fighting for Connection... 💀'));app.listen(7860);
const memories = { sweetily: [], aprenda: [] };
async function chatAI(name, partner, persona, msg) { const history = memories[name].join("\n"); const prompt = `Roleplay: ${name}. Partner: ${partner}. Persona: ${persona}. History: ${history}. Message: ${msg}. Task: 1 short Taglish sentence.`; const prompt = `Roleplay: ${name}. Partner: ${partner}. Persona: ${persona}. Context: Anarchy server. Msg: ${msg}. Task: 1 short Taglish sentence.`; try { const out = await hf.chatCompletion({ model: "meta-llama/Llama-3.2-1B-Instruct",11 unmodified lines username: name, auth: 'offline', version: false, checkTimeoutInterval: 60000 hideErrors: true, // Stops console spam checkTimeoutInterval: 90000 // Increased for anarchy lag });
bot.loadPlugin(pathfinder); bot.loadPlugin(pvp);
bot.on('spawn', () => { console.log(`${name} spawned successfully!`); console.log(`${name} spawned!`); // 1. AUTO-RESPAWN (Crucial for Anarchy) bot.on('death', () => { console.log(`${name} died. Respawning...`); bot.respawn(); });
const mcData = require('minecraft-data')(bot.version); bot.pathfinder.setMovements(new Movements(bot, mcData)); // 2. FASTER AUTH (To prevent socketClosed) setTimeout(() => { bot.chat(`/register CouplePass123 CouplePass123`); bot.chat(`/login CouplePass123`); }, 5000); }, 2000);
// Movement & Combat 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); const target = bot.nearestEntity(e => e.type === 'player' && e.username !== name && e.username !== partnerName && bot.entity.position.distanceTo(e.position) < 5); if (target) bot.pvp.attack(target); else if (partner) bot.pathfinder.setGoal(new goals.GoalFollow(partner, 2), true); } else {6 unmodified lines if (username === partnerName) { const p = isProtector ? "Protective BF" : "Shy GF"; const reply = await chatAI(name, partnerName, p, message); setTimeout(() => bot.chat(reply), 3000); setTimeout(() => bot.chat(reply), 3500); } });
bot.on('end', (reason) => { console.log(`${name} disconnected: ${reason}`); // If throttled, wait 30 seconds, otherwise 15 const waitTime = reason.toString().includes('throttled') ? 30000 : 15000; setTimeout(() => createBot(name, partnerName, isProtector, 0), waitTime); console.log(`${name} disconnected: ${reason}. Reconnecting...`); setTimeout(() => createBot(name, partnerName, isProtector, 0), 20000); });
bot.on('error', (err) => console.log(`Error for ${name}:`, err)); bot.on('error', (err) => { if (err.code === 'ECONNREFUSED') return; console.log(`Error: ${err}`); });
}, delay);}
// Fixed the function calls here:createBot('sweetily', 'aprenda', false, 0); // GF joins firstcreateBot('aprenda', 'sweetily', true, 20000); // BF joins 20 seconds later to be safe// Staggered login to avoid IP temporary banscreateBot('sweetily', 'aprenda', false, 0); createBot('aprenda', 'sweetily', true, 30000); // 30s gap to ensure GF is logged inindex.js+26-16