Spaces:
Paused
Paused
Update bot.js
Browse files
bot.js
CHANGED
|
@@ -85,10 +85,21 @@ connect: (client) => {
|
|
| 85 |
|
| 86 |
try { sshClient.end(); } catch(e) {}
|
| 87 |
|
| 88 |
-
//
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
}
|
| 93 |
};
|
| 94 |
|
|
@@ -411,11 +422,15 @@ connect: (client) => {
|
|
| 411 |
});
|
| 412 |
|
| 413 |
bot.on("end", () => {
|
|
|
|
|
|
|
|
|
|
| 414 |
logger.warn("Bağlantı koptu. Tüm zamanlayıcılar sıfırlanıyor...");
|
| 415 |
stopPeriodicHomeChecks();
|
| 416 |
botIsReady = false;
|
| 417 |
baglantiTuru = "Yok";
|
| 418 |
bot = null;
|
|
|
|
| 419 |
if (config.utils && config.utils["auto-reconnect"]) {
|
| 420 |
setTimeout(() => createBot(), config.utils["auto-reconnect-delay"]);
|
| 421 |
}
|
|
|
|
| 85 |
|
| 86 |
try { sshClient.end(); } catch(e) {}
|
| 87 |
|
| 88 |
+
// Zamanlayıcıları temizle
|
| 89 |
+
stopPeriodicHomeChecks();
|
| 90 |
+
|
| 91 |
+
// ÖNEMLİ: Eğer bot nesnesi oluştup sunucuya hiç bağlanamadıysa,
|
| 92 |
+
// end eventi tetiklenmeyeceği için yeniden başlatmayı burada kendimiz tetikliyoruz.
|
| 93 |
+
if (config.utils && config.utils["auto-reconnect"]) {
|
| 94 |
+
logger.info(`[Bağlantı] ${config.utils["auto-reconnect-delay"]} ms sonra yeniden denenecek...`);
|
| 95 |
+
setTimeout(() => {
|
| 96 |
+
// Eski botun listener'larını temizleyip boşa çıkaralım
|
| 97 |
+
if (bot) {
|
| 98 |
+
try { bot.removeAllListeners(); } catch(e){}
|
| 99 |
+
bot = null;
|
| 100 |
+
}
|
| 101 |
+
createBot();
|
| 102 |
+
}, config.utils["auto-reconnect-delay"]);
|
| 103 |
}
|
| 104 |
};
|
| 105 |
|
|
|
|
| 422 |
});
|
| 423 |
|
| 424 |
bot.on("end", () => {
|
| 425 |
+
if (isFinished) return;
|
| 426 |
+
isFinished = true;
|
| 427 |
+
|
| 428 |
logger.warn("Bağlantı koptu. Tüm zamanlayıcılar sıfırlanıyor...");
|
| 429 |
stopPeriodicHomeChecks();
|
| 430 |
botIsReady = false;
|
| 431 |
baglantiTuru = "Yok";
|
| 432 |
bot = null;
|
| 433 |
+
|
| 434 |
if (config.utils && config.utils["auto-reconnect"]) {
|
| 435 |
setTimeout(() => createBot(), config.utils["auto-reconnect-delay"]);
|
| 436 |
}
|