ddbot.js-0374 3.1.5 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/bot/bot.js +10 -2
package/package.json
CHANGED
package/src/bot/bot.js
CHANGED
|
@@ -309,6 +309,7 @@ class BotManager extends EventEmitter {
|
|
|
309
309
|
_setupBotEvents(botName, client) {
|
|
310
310
|
logDebug('_setupBotEvents called for botName:', botName); // логируем вызов функции
|
|
311
311
|
let chatinterval = null; // интервал для чата
|
|
312
|
+
let timeout = false;
|
|
312
313
|
|
|
313
314
|
this.on(`${botName}:disconnected`, (reason) => {
|
|
314
315
|
logDebug('internal "disconnected" event received for botName:', botName);
|
|
@@ -325,6 +326,7 @@ class BotManager extends EventEmitter {
|
|
|
325
326
|
if (!botInfo) {
|
|
326
327
|
return; // бот не найден фак
|
|
327
328
|
} else {
|
|
329
|
+
timeout = false;
|
|
328
330
|
client.movement.FlagScoreboard(true); // для пинга
|
|
329
331
|
botInfo.isConnected = true; // обновляем статус
|
|
330
332
|
}
|
|
@@ -343,8 +345,9 @@ class BotManager extends EventEmitter {
|
|
|
343
345
|
clearInterval(chatinterval); // очищаем интервал чата
|
|
344
346
|
}
|
|
345
347
|
|
|
346
|
-
if (botInfo.parameter.reconnect && (botInfo.parameter.reconnectAttempts>0 || botInfo.parameter.reconnectAttempts===-1)) {
|
|
348
|
+
if (!timeout && (botInfo.parameter.reconnect && (botInfo.parameter.reconnectAttempts>0 || botInfo.parameter.reconnectAttempts===-1))) {
|
|
347
349
|
if (botInfo.parameter.reconnectAttempts!==-1)botInfo.parameter.reconnectAttempts--;
|
|
350
|
+
timeout = true;
|
|
348
351
|
|
|
349
352
|
let reconnectTime = 10000;
|
|
350
353
|
logDebug('base reconnect time is '+reconnectTime+'ms');
|
|
@@ -375,6 +378,7 @@ class BotManager extends EventEmitter {
|
|
|
375
378
|
client.connect();
|
|
376
379
|
this.emit(`${botName}:reconnect`, reconnectTime);
|
|
377
380
|
logDebug(`${botName} reconnect now`);
|
|
381
|
+
timeout = false;
|
|
378
382
|
}, reconnectTime);
|
|
379
383
|
} else {
|
|
380
384
|
this.emit(`${botName}:disconnect`, reason);
|
|
@@ -403,7 +407,7 @@ class BotManager extends EventEmitter {
|
|
|
403
407
|
const playerInfo = client.SnapshotUnpacker.getObjPlayerInfo(client_id);
|
|
404
408
|
const character = client.SnapshotUnpacker.getObjCharacter(client_id);
|
|
405
409
|
|
|
406
|
-
if (clientInfo && clientInfo.name && playerInfo && playerInfo.
|
|
410
|
+
if (clientInfo && clientInfo.name && playerInfo && playerInfo.team !== -1) {
|
|
407
411
|
playerMap.set(client_id, {
|
|
408
412
|
client_id,
|
|
409
413
|
name: clientInfo.name,
|
|
@@ -495,6 +499,10 @@ class BotManager extends EventEmitter {
|
|
|
495
499
|
if (!client) return null;
|
|
496
500
|
return client.SnapshotUnpacker.OwnID;
|
|
497
501
|
}
|
|
502
|
+
|
|
503
|
+
getlogDebuger() {
|
|
504
|
+
return logDebuger;
|
|
505
|
+
}
|
|
498
506
|
}
|
|
499
507
|
|
|
500
508
|
module.exports = { BotManager, logDebuger }; // экспортируем BotManager и дебагер
|