ddbot.js-0374 2.0.1 → 2.1.1

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 +15 -4
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "neiky-ddracebot.js": "^2.4.0"
6
6
  },
7
7
  "name": "ddbot.js-0374",
8
- "version": "2.0.1",
8
+ "version": "2.1.1",
9
9
  "description": "ddbot.js — это Node.js проект для автоматизации и управления ботами, а также работы с картами и логами.",
10
10
  "main": "./index.js",
11
11
  "scripts": {
package/src/bot/bot.js CHANGED
@@ -134,7 +134,7 @@ class BotManager extends EventEmitter {
134
134
  * @param {string} botName
135
135
  * @returns
136
136
  */
137
- async disconnectBot(botName) {
137
+ disconnectBot(botName) {
138
138
  logDebug('disconnectBot called with botName:', botName); // логируем вызов функции
139
139
  const botInfo = this.activeBots.get(botName); // получаем инфу о боте
140
140
  if (!botInfo) {
@@ -220,7 +220,7 @@ class BotManager extends EventEmitter {
220
220
  * @returns {object|null} - Объект клиента бота или null, если бот не найден
221
221
  */
222
222
  getBotClient(botName) {
223
- const botInfo = this.activeBots.get(botName); // получаем инфу о боте
223
+ const botInfo = this.getBotInfo(botName); // получаем инфу о боте
224
224
  return botInfo ? botInfo.client : null; // возвращаем клиент или null
225
225
  }
226
226
 
@@ -231,7 +231,7 @@ class BotManager extends EventEmitter {
231
231
  */
232
232
  removeBot(botName) {
233
233
  logDebug('removeBot called with botName:', botName); // логируем вызов функции
234
- const botInfo = this.activeBots.get(botName); // получаем инфу о боте
234
+ const botInfo = this.getBotInfo(botName); // получаем инфу о боте
235
235
  if (botInfo) {
236
236
  // Отключаем если подключен
237
237
  if (botInfo.isConnected) {
@@ -251,7 +251,7 @@ class BotManager extends EventEmitter {
251
251
  * @returns {object|null} - Объект бота с событиями или null, если бот не найден
252
252
  */
253
253
  getBot(botName) {
254
- const botInfo = this.activeBots.get(botName); // получаем инфу о боте
254
+ const botInfo = this.getBotInfo(botName); // получаем инфу о боте
255
255
  if (!botInfo) {
256
256
  return null; // бот не найден
257
257
  }
@@ -468,6 +468,17 @@ class BotManager extends EventEmitter {
468
468
  return player ? player.name : null;
469
469
  }
470
470
  }
471
+
472
+ /**
473
+ * Получение ID клиента бота
474
+ * @param {string} botName - Имя бота
475
+ * @returns {number|null|undefined} ID клиента бота или null если не найден, или ошибка.
476
+ */
477
+ getBotClientId(botName) {
478
+ const client = this.getBotClient(botName);
479
+ if (!client) return null;
480
+ return client.SnapshotUnpacker.OwnID;
481
+ }
471
482
  }
472
483
 
473
484
  module.exports = { BotManager, logDebuger }; // экспортируем BotManager и дебагер