Spaces:
Paused
Paused
Update index.js
Browse files
index.js
CHANGED
|
@@ -1,72 +1,88 @@
|
|
| 1 |
const axios = require('axios');
|
| 2 |
-
const
|
|
|
|
| 3 |
|
| 4 |
-
const
|
| 5 |
-
deviceId: uuidv4().replace(/-/g, '').substring(0, 16),
|
| 6 |
-
iggId: null,
|
| 7 |
-
token: null,
|
| 8 |
-
level: 1,
|
| 9 |
-
posX: 0,
|
| 10 |
-
posY: 0,
|
| 11 |
-
k: 0 // Reino
|
| 12 |
-
};
|
| 13 |
|
| 14 |
-
//
|
| 15 |
-
|
| 16 |
-
try {
|
| 17 |
-
console.log(`📱 Gerando novo aparelho: ${NEW_ACCOUNT.deviceId}`);
|
| 18 |
-
const res = await axios.post('https://br-game.igg.com/main/login', {
|
| 19 |
-
device_id: NEW_ACCOUNT.deviceId,
|
| 20 |
-
platform: 1, // Android
|
| 21 |
-
language: "pt"
|
| 22 |
-
});
|
| 23 |
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
await iniciarFluxoUpgrade();
|
| 29 |
-
}
|
| 30 |
-
} catch (err) {
|
| 31 |
-
console.log("❌ Erro ao criar conta nova na IGG");
|
| 32 |
-
}
|
| 33 |
}
|
| 34 |
|
| 35 |
-
// ---
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
//
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
-
|
| 72 |
-
// criarContaNova();
|
|
|
|
| 1 |
const axios = require('axios');
|
| 2 |
+
const fs = require('fs');
|
| 3 |
+
const { v4: uuidv4 } = require('uuid');
|
| 4 |
|
| 5 |
+
const CONFIG_PATH = './config.json';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
+
// Carrega as configurações do JSON
|
| 8 |
+
let config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf8'));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
// Função para salvar o progresso no JSON
|
| 11 |
+
function salvarProgresso() {
|
| 12 |
+
config.status.lastUpdate = new Date().toISOString();
|
| 13 |
+
fs.writeFileSync(CONFIG_PATH, JSON.stringify(config, null, 2));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
}
|
| 15 |
|
| 16 |
+
// --- LOGICA DE CRIAÇÃO E UPGRADE ---
|
| 17 |
+
const LordsBot = {
|
| 18 |
+
async iniciar() {
|
| 19 |
+
if (!config.account.iggId) {
|
| 20 |
+
console.log("🆕 Criando nova conta Farm...");
|
| 21 |
+
await this.criarConta();
|
| 22 |
+
} else {
|
| 23 |
+
console.log(`🏰 Retomando conta IGG: ${config.account.iggId}`);
|
| 24 |
+
this.loopDeUpgrade();
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
|
| 28 |
+
async criarConta() {
|
| 29 |
+
const newDevice = uuidv4().replace(/-/g, '').substring(0, 16);
|
| 30 |
+
try {
|
| 31 |
+
const res = await axios.post(`https://${config.account.region}-game.igg.com/main/login`, {
|
| 32 |
+
device_id: newDevice,
|
| 33 |
+
platform: 1
|
| 34 |
+
});
|
| 35 |
|
| 36 |
+
config.account.deviceId = newDevice;
|
| 37 |
+
config.account.iggId = res.data.iggid;
|
| 38 |
+
config.account.token = res.data.access_key;
|
| 39 |
+
|
| 40 |
+
salvarProgresso();
|
| 41 |
+
console.log("✅ Conta criada com sucesso!");
|
| 42 |
+
this.loopDeUpgrade();
|
| 43 |
+
} catch (e) { console.log("Erro ao registrar conta."); }
|
| 44 |
+
},
|
| 45 |
|
| 46 |
+
async atualizarStatus() {
|
| 47 |
+
try {
|
| 48 |
+
const res = await axios.post(`https://${config.account.region}-game.igg.com/main/get_player_info`, {
|
| 49 |
+
iggid: config.account.iggId,
|
| 50 |
+
token: config.account.token
|
| 51 |
+
});
|
| 52 |
+
|
| 53 |
+
// Atualiza Localização e Nível no JSON
|
| 54 |
+
config.status.position = { k: res.data.k, x: res.data.x, y: res.data.y };
|
| 55 |
+
config.status.level = res.data.level;
|
| 56 |
+
|
| 57 |
+
console.log(`📍 [REINO ${config.status.position.k}] Local: (${config.status.position.x}, ${config.status.position.y}) | Nível: ${config.status.level}`);
|
| 58 |
+
salvarProgresso();
|
| 59 |
+
} catch (e) { console.log("Erro ao ler dados da conta."); }
|
| 60 |
+
},
|
| 61 |
+
|
| 62 |
+
async coletarMissoes() {
|
| 63 |
+
// O EXP real para o nível 60 vem daqui
|
| 64 |
+
try {
|
| 65 |
+
await axios.post(`https://${config.account.region}-game.igg.com/main/mission_collect`, {
|
| 66 |
+
iggid: config.account.iggId,
|
| 67 |
+
token: config.account.token,
|
| 68 |
+
mission_type: 1 // Missões de Território/Construção
|
| 69 |
+
});
|
| 70 |
+
console.log("💎 Recompensas de missões coletadas! EXP subindo...");
|
| 71 |
+
} catch (e) { }
|
| 72 |
+
},
|
| 73 |
+
|
| 74 |
+
loopDeUpgrade() {
|
| 75 |
+
// Ciclo de 5 minutos: Atualiza status -> Coleta Missões -> Tenta Build
|
| 76 |
+
setInterval(async () => {
|
| 77 |
+
await this.atualizarStatus();
|
| 78 |
+
|
| 79 |
+
if (config.strategy.collectQuests) await this.coletarMissoes();
|
| 80 |
+
|
| 81 |
+
if (config.status.level < config.status.targetLevel) {
|
| 82 |
+
console.log(`🔨 [BOT] Upando... Faltam ${60 - config.status.level} níveis para a meta.`);
|
| 83 |
+
}
|
| 84 |
+
}, 300000);
|
| 85 |
+
}
|
| 86 |
+
};
|
| 87 |
|
| 88 |
+
LordsBot.iniciar();
|
|
|