hackchat-engine 1.1.16 → 1.1.18

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.
@@ -14,7 +14,13 @@ class UpdateUser extends AbstractEvent {
14
14
  const { client } = this;
15
15
  const user = client.users.get(data.userid);
16
16
 
17
- user.updateUser(data);
17
+ if (user) {
18
+ user.updateUser(data);
19
+ }
20
+
21
+ if (client.myUser && client.myUser.userid === data.userid) {
22
+ client.myUser.updateUser(data);
23
+ }
18
24
 
19
25
  return user;
20
26
  }
package/package.json CHANGED
@@ -59,5 +59,5 @@
59
59
  "lintfix": "eslint --fix --ignore-path .gitignore .",
60
60
  "test": "echo \"Error: no test specified\" && exit 1"
61
61
  },
62
- "version": "1.1.16"
62
+ "version": "1.1.18"
63
63
  }
@@ -125,6 +125,12 @@ class User {
125
125
  * @type {number}
126
126
  */
127
127
  this.permissionLevel = data.level || false;
128
+
129
+ /**
130
+ * User's ui effect
131
+ * @type {number}
132
+ */
133
+ this.userEffect = data.effect || 0;
128
134
  }
129
135
 
130
136
  /**
@@ -253,6 +259,15 @@ class User {
253
259
  return this.permissionLevel;
254
260
  }
255
261
 
262
+ /**
263
+ * User's ui effect
264
+ * @type {number}
265
+ * @readonly
266
+ */
267
+ get effect() {
268
+ return this.userEffect;
269
+ }
270
+
256
271
  /**
257
272
  * Patch new user info sent from server
258
273
  * @param {object} data User object sent from server
@@ -261,10 +276,12 @@ class User {
261
276
  updateUser(data) {
262
277
  if (data.channel) {
263
278
  this.channels.add(data.channel);
279
+ this.channel = data.channel;
264
280
  }
265
281
 
266
- if (data.trip) this.usertrip = data.trip;
267
- if (data.hash) this.userhash = data.hash;
282
+ if (typeof data.trip !== 'undefined') this.usertrip = data.trip;
283
+ if (typeof data.hash !== 'undefined') this.userhash = data.hash;
284
+ if (typeof data.effect !== 'undefined') this.userEffect = data.effect;
268
285
 
269
286
  this.username = data.nick;
270
287
  this.userlevel = data.uType;
@@ -1,5 +1,5 @@
1
1
  import AbstractHandler from './AbstractHandler.js';
2
- import { Events } from '../../../util/Constants.js';
2
+ import { Events, Status } from '../../../util/Constants.js';
3
3
 
4
4
  /**
5
5
  * Handles a new chat message that has been broadcast within a channel
@@ -15,19 +15,21 @@ class SessionHandler extends AbstractHandler {
15
15
  const { client } = this.packetRouter;
16
16
 
17
17
  client.readyAt = new Date();
18
- const t = client.setTimeout(() => {
19
- client.ws.connection.triggerReady();
20
- }, 1);
21
18
 
22
- client.once('ready', () => {
23
- client.setMaxListeners(10);
24
- client.clearTimeout(t);
25
- });
19
+ if (client.status !== Status.READY) {
20
+ const t = client.setTimeout(() => {
21
+ client.ws.connection.triggerReady();
22
+ }, 1);
23
+
24
+ client.once(Events.READY, () => {
25
+ client.clearTimeout(t);
26
+ });
27
+ }
26
28
 
27
29
  const response = client.events.Session.handle(packet);
28
30
 
29
31
  /**
30
- * Emitted when a message is sent in a channel
32
+ * Emitted when a session packet is received
31
33
  * @event Client#session
32
34
  * @param {SessionStruct} session Full session details
33
35
  */