hackchat-engine 1.1.2 → 1.1.3

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/README.md CHANGED
@@ -1,48 +1,60 @@
1
- # hackchat-engine
2
-
3
- A NodeJS and browser friendly JavaScript library used to interact with a hackchat server.
4
-
5
- # Installation
6
-
7
- ## Prerequisites
8
-
9
- - [node.js 14.15](https://nodejs.org/en/download/package-manager/) or higher
10
- - [npm 6](https://nodejs.org/en/download/package-manager/) or higher
11
-
12
- ## Install
13
-
14
- `npm i hackchat-engine`
15
-
16
- # Usage
17
-
18
- ## Minimum Usage
19
-
20
- ```javascript
21
- const { Client } = require('hackchat-engine');
22
- const hcClient = new Client();
23
-
24
- const testName = 'testBot';
25
- const testPass = 'testBot';
26
- const testChannel = 'programming';
27
-
28
- hcClient.on('connected', () => console.log('Connected!'));
29
-
30
- hcClient.on('session', (payload) => {
31
- console.log(payload);
32
- hcClient.join(testName, testPass, testChannel);
33
- });
34
-
35
- hcClient.on('channelJoined', (payload) => {
36
- console.log(payload);
37
- hcClient.say(testChannel, 'Bep boop i r bot');
38
- });
39
-
40
- hcClient.on('message', (payload) => {
41
- console.log(payload);
42
- hcClient.say(testChannel, 'No u');
43
- });
44
- ```
45
-
46
- ## Advanced Usage
47
-
48
- ** Need to update this **
1
+ # hackchat-engine
2
+
3
+ A NodeJS and browser friendly JavaScript library used to interact with a hackchat server.
4
+
5
+ # Installation
6
+
7
+ ## Prerequisites
8
+
9
+ - [node.js 14.15](https://nodejs.org/en/download/package-manager/) or higher
10
+ - [npm 6](https://nodejs.org/en/download/package-manager/) or higher
11
+
12
+ ## Install
13
+
14
+ `npm i hackchat-engine`
15
+
16
+ # Usage
17
+
18
+ ## Minimum Usage
19
+
20
+ ```javascript
21
+ const { Client } = require('hackchat-engine');
22
+ const hcClient = new Client();
23
+
24
+ const testName = 'testBot';
25
+ const testPass = 'testBot';
26
+ const testChannel = 'programming';
27
+
28
+ hcClient.on('connected', () => console.log('Connected!'));
29
+
30
+ hcClient.on('session', (payload) => {
31
+ console.log(payload);
32
+ hcClient.join(testName, testPass, testChannel);
33
+ });
34
+
35
+ hcClient.on('channelJoined', (payload) => {
36
+ console.log(payload);
37
+ hcClient.say(testChannel, 'Bep boop i r bot');
38
+ });
39
+
40
+ hcClient.on('message', (payload) => {
41
+ console.log(payload);
42
+ hcClient.say(testChannel, 'No u');
43
+ });
44
+ ```
45
+
46
+ ## Advanced Usage
47
+
48
+ ** Need to update this, still **
49
+
50
+ ### Changing the connection
51
+
52
+ By default, this engine will connect to 'wss://hack.chat/chat-ws'. To change this, add a `ws.gateway` property to the `options` object, for example:
53
+
54
+ ```javascript
55
+ const hcClient = new Client({
56
+ ws: {
57
+ gateway: 'ws://1.1.1.1:6060/',
58
+ }
59
+ });
60
+ ```
package/package.json CHANGED
@@ -1,6 +1,5 @@
1
1
  {
2
2
  "_from": "hackchat-engine@^1.0.9",
3
- "_id": "hackchat-engine@1.0.9",
4
3
  "_inBundle": false,
5
4
  "_integrity": "sha512-uxyU4HBAs8L4hQktdtvTP/3drbJHQvjkeQDdonglAffHIPtZ1pgU9W/ScNXNCFEyqDAo/QSVikfXp0wMmLtzeQ==",
6
5
  "_location": "/hackchat-engine",
@@ -60,5 +59,5 @@
60
59
  "lintfix": "eslint --fix --ignore-path .gitignore .",
61
60
  "test": "echo \"Error: no test specified\" && exit 1"
62
61
  },
63
- "version": "1.1.2"
62
+ "version": "1.1.3"
64
63
  }
@@ -49,6 +49,14 @@ class SessionStruct {
49
49
  * @type {boolean}
50
50
  */
51
51
  this.restored = data.restored;
52
+
53
+ // add non-standard properties
54
+ const dataKeys = Object.keys(data);
55
+ for (let i = 0, j = dataKeys.length; i < j; i++) {
56
+ if (dataKeys[i] !== 'cmd' && dataKeys[i] !== 'time') {
57
+ this[dataKeys[i]] = data[dataKeys[i]];
58
+ }
59
+ }
52
60
  }
53
61
  }
54
62