ddbot.js-0374 4.4.0 → 4.4.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.
@@ -3,6 +3,7 @@ import { EventEmitter } from 'events';
3
3
  import * as Types from '../types.js';
4
4
  interface BotEvents {
5
5
  error: (...args: any[]) => void;
6
+ destroy: () => void;
6
7
  connect: (info: Types.ConnectionInfo) => void;
7
8
  disconnect: (reason: string | null, info: Types.ConnectionInfo) => void;
8
9
  rawconnect: (info: Types.ConnectionInfo) => void;
package/lib/core/core.js CHANGED
@@ -36,17 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.Bot = void 0;
37
37
  const Teeworlds = __importStar(require("teeworlds"));
38
38
  const events_1 = require("events");
39
- function DefaultIdentity(name = 'nameless tee') {
40
- return {
41
- name: name,
42
- clan: "",
43
- skin: "default",
44
- use_custom_color: 0,
45
- color_body: 0,
46
- color_feet: 0,
47
- country: 0
48
- };
49
- }
39
+ const ddutils_js_1 = require("../ddutils.js");
50
40
  class Bot extends events_1.EventEmitter {
51
41
  teeworlds;
52
42
  client = null;
@@ -71,7 +61,7 @@ class Bot extends events_1.EventEmitter {
71
61
  super();
72
62
  this.teeworlds = CustomTeeworlds;
73
63
  this.options = options;
74
- this.identity = identity ? identity : DefaultIdentity('nameless tee');
64
+ this.identity = identity ? identity : (0, ddutils_js_1.DefaultIdentity)('nameless tee');
75
65
  }
76
66
  error(...err) {
77
67
  //console.error(err);
@@ -206,7 +196,7 @@ class Bot extends events_1.EventEmitter {
206
196
  this.identity =
207
197
  typeof identity === 'object' && identity !== null
208
198
  ? { ...this.identity, ...identity }
209
- : DefaultIdentity(this.identity.name);
199
+ : (0, ddutils_js_1.DefaultIdentity)(this.identity.name);
210
200
  if (this.client && this.status.connect.connected) {
211
201
  this.client.game.ChangePlayerInfo(this.identity);
212
202
  }
@@ -320,6 +310,7 @@ class Bot extends events_1.EventEmitter {
320
310
  await this.disconnect();
321
311
  this.removeAllListeners();
322
312
  this._clientProxy = null;
313
+ this.emit('destroy');
323
314
  }
324
315
  on(event, listener) {
325
316
  return super.on(event, listener);
@@ -18,6 +18,7 @@ class BaseModule extends events_1.EventEmitter {
18
18
  if (options.offonDisconnect !== false) {
19
19
  this.bot.on('disconnect', this._onDisconnect);
20
20
  }
21
+ this.bot.on('destroy', () => this.destroy());
21
22
  }
22
23
  /**
23
24
  * Запускает модуль, если он ещё не запущен
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "teeworlds": "^2.5.11"
4
4
  },
5
5
  "name": "ddbot.js-0374",
6
- "version": "4.4.0",
6
+ "version": "4.4.1",
7
7
  "description": "ddbot.js — это Node.js проект для автоматизации и управления ботами.",
8
8
  "main": "./lib/index.js",
9
9
  "scripts": {