Spaces:
Paused
Paused
Update index.js
Browse files5 unmodified lines67891011121314151617181911 unmodified lines31323334353637383940414243444546474849505152535455566 unmodified lines636465666768697071727374757677787980818283845 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();app.get('/', (req, res) => res.send('Couple is trying to login... 💀'));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.`;try {const out = await hf.chatCompletion({model: "meta-llama/Llama-3.2-1B-Instruct",11 unmodified linesusername: name,auth: 'offline',version: false,checkTimeoutInterval: 60000});bot.loadPlugin(pathfinder);bot.loadPlugin(pvp);bot.on('spawn', () => {console.log(`${name} spawned successfully!`);const mcData = require('minecraft-data')(bot.version);bot.pathfinder.setMovements(new Movements(bot, mcData));setTimeout(() => {bot.chat(`/register CouplePass123 CouplePass123`);bot.chat(`/login CouplePass123`);}, 5000);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 {6 unmodified linesif (username === partnerName) {const p = isProtector ? "Protective BF" : "Shy GF";const reply = await chatAI(name, partnerName, p, message);setTimeout(() => bot.chat(reply), 3000);}});bot.on('end', (reason) => {console.log(`${name} disconnected: ${reason}`);// If throttled, wait 30 seconds, otherwise 15const waitTime = reason.toString().includes('throttled') ? 30000 : 15000;setTimeout(() => createBot(name, partnerName, isProtector, 0), waitTime);});bot.on('error', (err) => console.log(`Error for ${name}:`, 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 safe5 unmodified lines678910111213141516171811 unmodified lines3031323334353637383940414243444546474849505152535455565758596061626364656 unmodified lines72737475767778798081828384858687888990919293945 unmodified linesconst hf = new HfInference(process.env.HF_TOKEN);const app = express();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 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 linesusername: name,auth: 'offline',version: false,hideErrors: true, // Stops console spamcheckTimeoutInterval: 90000 // Increased for anarchy lag});bot.loadPlugin(pathfinder);bot.loadPlugin(pvp);bot.on('spawn', () => {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`);}, 2000);// Movement & Combat LoopsetInterval(() => {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) < 5);if (target) bot.pvp.attack(target);else if (partner) bot.pathfinder.setGoal(new goals.GoalFollow(partner, 2), true);} else {6 unmodified linesif (username === partnerName) {const p = isProtector ? "Protective BF" : "Shy GF";const reply = await chatAI(name, partnerName, p, message);setTimeout(() => bot.chat(reply), 3500);}});bot.on('end', (reason) => {console.log(`${name} disconnected: ${reason}. Reconnecting...`);setTimeout(() => createBot(name, partnerName, isProtector, 0), 20000);});bot.on('error', (err) => {if (err.code === 'ECONNREFUSED') return;console.log(`Error: ${err}`);});}, delay);}// Staggered login to avoid IP temporary banscreateBot('sweetily', 'aprenda', false, 0);createBot('aprenda', 'sweetily', true, 30000); // 30s gap to ensure GF is logged in
index.js+26-16