ddbot.js-0374 3.1.0 → 3.1.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/bot/bot.js +9 -7
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "teeworlds": "^2.5.8"
6
6
  },
7
7
  "name": "ddbot.js-0374",
8
- "version": "3.1.0",
8
+ "version": "3.1.2",
9
9
  "description": "ddbot.js — это Node.js проект для автоматизации и управления ботами, а также работы с картами и логами.",
10
10
  "main": "./index.js",
11
11
  "scripts": {
package/src/bot/bot.js CHANGED
@@ -129,6 +129,7 @@ class BotManager extends EventEmitter {
129
129
  logDebug('connectBot called with botName:', botName); // логируем вызов функции
130
130
  const botInfo = this.getBotInfo(botName); // получаем инфу о боте
131
131
  if (!botInfo) {
132
+ logDebug('bot not found')
132
133
  return false; // бот не найден
133
134
  }
134
135
  try {
@@ -305,10 +306,12 @@ class BotManager extends EventEmitter {
305
306
  let chatinterval = null; // интервал для чата
306
307
 
307
308
  this.on(`${botName}:disconnected`, (reason) => {
309
+ logDebug('internal "disconnected" event received for botName:', botName);
308
310
  clearInterval(chatinterval);
309
311
  });
310
312
 
311
313
  this.on(`${botName}:disconnect`, (reason) => {
314
+ logDebug('internal "disconnect" event received for botName:', botName);
312
315
  clearInterval(chatinterval);
313
316
  });
314
317
 
@@ -317,6 +320,7 @@ class BotManager extends EventEmitter {
317
320
  if (!botInfo) {
318
321
  return; // бот не найден фак
319
322
  } else {
323
+ client.movement.FlagScoreboard(true); // для пинга
320
324
  botInfo.isConnected = true; // обновляем статус
321
325
  }
322
326
  this.emit(`${botName}:connect`); // емитим событие коннекта1
@@ -392,9 +396,7 @@ class BotManager extends EventEmitter {
392
396
  for (let client_id = 0; client_id < 64; client_id++) {
393
397
  const clientInfo = client.SnapshotUnpacker.getObjClientInfo(client_id);
394
398
  const playerInfo = client.SnapshotUnpacker.getObjPlayerInfo(client_id);
395
- const ddnetChar = client.SnapshotUnpacker.getObjExDDNetCharacter
396
- ? client.SnapshotUnpacker.getObjExDDNetCharacter(client_id)
397
- : null;
399
+ const character = client.SnapshotUnpacker.getObjCharacter(client_id);
398
400
 
399
401
  if (clientInfo && clientInfo.name && playerInfo && playerInfo.m_Team !== -1) {
400
402
  playerMap.set(client_id, {
@@ -402,10 +404,10 @@ class BotManager extends EventEmitter {
402
404
  name: clientInfo.name,
403
405
  clan: clientInfo.clan || '',
404
406
  country: clientInfo.country || -1,
405
- team: playerInfo.m_Team,
407
+ team: playerInfo.team,
406
408
  skin: clientInfo.skin || 'default',
407
- x: ddnetChar ? ddnetChar.m_X : null,
408
- y: ddnetChar ? ddnetChar.m_Y : null
409
+ x: character ? character.character_core.x : null,
410
+ y: character ? character.character_core.y : null
409
411
  });
410
412
  }
411
413
  }
@@ -427,7 +429,7 @@ class BotManager extends EventEmitter {
427
429
  const msgraw = msg; // ориг для чата на всякий
428
430
  const text = msg.message; // само сообщение
429
431
  const client_id = msg.client_id; // айди отправителя
430
- const autormsg = msg.client_id === -1 ? "system" : this.getPlayerName(botName, client_id) || (msg.utilisateur?.InformationDuBot?.name || null) // имя отправителя
432
+ const autormsg = msg.client_id === -1 ? "system" : this.getPlayerName(botName, client_id) || (msg.author?.ClientInfo?.name || null) // имя отправителя
431
433
  const team = msg.team; // команда отправителя
432
434
 
433
435
  // фильтрация дубликатов сообщений