teeworlds 2.5.3 → 2.5.5

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,12 +1,13 @@
1
1
  # Teeworlds Client
2
2
  Library to connect a bot to a Teeworlds server.
3
3
 
4
- https://gitlab.com/swarfey/teeworlds-client/-/tree/main/
4
+ # Links
5
+ https://github.com/swarfeya/teeworlds-library-ts/tree/main
5
6
  https://www.npmjs.com/package/teeworlds
6
7
 
7
8
  # Documentation
8
- You can find an documentation to what most components do in the [docs/documentation.md](https://gitlab.com/swarfey/teeworlds-client/-/blob/main/docs/documentation.md).
9
- You can also find a few examples inside of the [docs/examples](https://gitlab.com/swarfey/teeworlds-client/-/tree/main/docs/examples) directory.
9
+ You can find an documentation to what most components do in the [docs/documentation.md](https://github.com/swarfeya/teeworlds-library-ts/blob/main/docs/documentation.md).
10
+ You can also find a few examples inside of the [docs/examples](https://github.com/swarfeya/teeworlds-library-ts/tree/main/docs/examples) directory.
10
11
 
11
12
  # Projects using this library
12
13
  Note: If you have or know any projects running using this library, please contact me so i can add them, or PR them yourself.
@@ -365,4 +365,7 @@ You can find some of the examples in the [docs/examples](docs/examples/) folder.
365
365
  *Note:* If you have or know any projects running using this library, please contact me so i can add them, or PR them yourself.
366
366
 
367
367
  * A discord which is bridging all discord messages and ingame messages (currently closed source): https://discord.gg/MSYcjYvU6e
368
+ * DDNet / Teeworlds Chat Client, no game, just chatting by kiocode: https://github.com/k-i-o/CChat.TW
369
+ * https://github.com/vitorblue007/DDnet-chatbot
370
+ * https://github.com/Siraxa/DDNetSpectate/tree/master
368
371
 
package/index.js CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Client = void 0;
18
- var client_1 = require("./lib/client");
19
- Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
20
- __exportStar(require("./lib/MsgPacker"), exports);
21
- __exportStar(require("./lib/MsgUnpacker"), exports);
22
- __exportStar(require("./lib/snapshot"), exports);
23
- __exportStar(require("./lib/huffman"), exports);
24
- __exportStar(require("./lib/UUIDManager"), exports);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Client = void 0;
18
+ var client_1 = require("./lib/client");
19
+ Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
20
+ __exportStar(require("./lib/MsgPacker"), exports);
21
+ __exportStar(require("./lib/MsgUnpacker"), exports);
22
+ __exportStar(require("./lib/snapshot"), exports);
23
+ __exportStar(require("./lib/huffman"), exports);
24
+ __exportStar(require("./lib/UUIDManager"), exports);
package/lib/MsgPacker.js CHANGED
@@ -1,55 +1,46 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MsgPacker = void 0;
4
- var MsgPacker = /** @class */ (function () {
5
- function MsgPacker(msg, sys, flag) {
6
- this.result = Buffer.from([2 * msg + (sys ? 1 : 0)]);
7
- this.sys = sys;
8
- this.flag = flag;
9
- }
10
- MsgPacker.prototype.AddString = function (str) {
11
- this.result = Buffer.concat([this.result, Buffer.from(str), Buffer.from([0x00])]);
12
- };
13
- MsgPacker.prototype.AddBuffer = function (buffer) {
14
- this.result = Buffer.concat([this.result, buffer]);
15
- };
16
- MsgPacker.prototype.AddInt = function (i) {
17
- var result = [];
18
- var pDst = (i >> 25) & 0x40;
19
- var i = i ^ (i >> 31);
20
- pDst |= i & 0x3f;
21
- i >>= 6;
22
- if (i) {
23
- pDst |= 0x80;
24
- result.push(pDst);
25
- while (true) {
26
- pDst++;
27
- pDst = i & (0x7f);
28
- i >>= 7;
29
- pDst |= (Number(i != 0)) << 7;
30
- result.push(pDst);
31
- if (!i)
32
- break;
33
- }
34
- }
35
- else
36
- result.push(pDst);
37
- this.result = Buffer.concat([this.result, Buffer.from(result)]);
38
- };
39
- Object.defineProperty(MsgPacker.prototype, "size", {
40
- get: function () {
41
- return this.result.byteLength;
42
- },
43
- enumerable: false,
44
- configurable: true
45
- });
46
- Object.defineProperty(MsgPacker.prototype, "buffer", {
47
- get: function () {
48
- return this.result;
49
- },
50
- enumerable: false,
51
- configurable: true
52
- });
53
- return MsgPacker;
54
- }());
55
- exports.MsgPacker = MsgPacker;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsgPacker = void 0;
4
+ class MsgPacker {
5
+ constructor(msg, sys, flag) {
6
+ this.result = Buffer.from([2 * msg + (sys ? 1 : 0)]);
7
+ this.sys = sys;
8
+ this.flag = flag;
9
+ }
10
+ AddString(str) {
11
+ this.result = Buffer.concat([this.result, Buffer.from(str), Buffer.from([0x00])]);
12
+ }
13
+ AddBuffer(buffer) {
14
+ this.result = Buffer.concat([this.result, buffer]);
15
+ }
16
+ AddInt(i) {
17
+ var result = [];
18
+ var pDst = (i >> 25) & 0x40;
19
+ var i = i ^ (i >> 31);
20
+ pDst |= i & 0x3f;
21
+ i >>= 6;
22
+ if (i) {
23
+ pDst |= 0x80;
24
+ result.push(pDst);
25
+ while (true) {
26
+ pDst++;
27
+ pDst = i & (0x7f);
28
+ i >>= 7;
29
+ pDst |= (Number(i != 0)) << 7;
30
+ result.push(pDst);
31
+ if (!i)
32
+ break;
33
+ }
34
+ }
35
+ else
36
+ result.push(pDst);
37
+ this.result = Buffer.concat([this.result, Buffer.from(result)]);
38
+ }
39
+ get size() {
40
+ return this.result.byteLength;
41
+ }
42
+ get buffer() {
43
+ return this.result;
44
+ }
45
+ }
46
+ exports.MsgPacker = MsgPacker;
@@ -1,53 +1,52 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MsgUnpacker = exports.unpackString = exports.unpackInt = void 0;
4
- var decoder = new TextDecoder('utf-8');
5
- function unpackInt(pSrc) {
6
- var srcIndex = 0;
7
- var sign = ((pSrc[srcIndex] >> 6) & 1);
8
- var result = (pSrc[srcIndex] & 63);
9
- while (srcIndex <= 4) {
10
- if ((pSrc[srcIndex] & 128) === 0)
11
- break;
12
- srcIndex++;
13
- result |= ((pSrc[srcIndex] & 127)) << (6 + 7 * (srcIndex - 1));
14
- }
15
- result ^= -sign;
16
- return { result: result, remaining: pSrc.slice(srcIndex + 1) };
17
- }
18
- exports.unpackInt = unpackInt;
19
- function unpackString(pSrc) {
20
- var result = pSrc.slice(0, pSrc.indexOf(0));
21
- pSrc = pSrc.slice(pSrc.indexOf(0) + 1, pSrc.length);
22
- return { result: decoder.decode(new Uint8Array(result)), remaining: pSrc };
23
- }
24
- exports.unpackString = unpackString;
25
- var MsgUnpacker = /** @class */ (function () {
26
- function MsgUnpacker(pSrc) {
27
- this.remaining = pSrc;
28
- }
29
- MsgUnpacker.prototype.unpackInt = function () {
30
- // let unpacked;
31
- // if (!_unpacked) {
32
- var unpacked = unpackInt(this.remaining);
33
- this.remaining = unpacked.remaining;
34
- // } else {
35
- // unpacked = {result: this.remaining[0]};
36
- // this.remaining = this.remaining.slice(1);
37
- // }
38
- return unpacked.result;
39
- };
40
- MsgUnpacker.prototype.unpackString = function () {
41
- var unpacked = unpackString(this.remaining);
42
- this.remaining = unpacked.remaining;
43
- return unpacked.result;
44
- };
45
- /** @param size - size in bytes */
46
- MsgUnpacker.prototype.unpackRaw = function (size) {
47
- var unpacked = this.remaining.slice(0, size);
48
- this.remaining = this.remaining.slice(size);
49
- return unpacked;
50
- };
51
- return MsgUnpacker;
52
- }());
53
- exports.MsgUnpacker = MsgUnpacker;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MsgUnpacker = void 0;
4
+ exports.unpackInt = unpackInt;
5
+ exports.unpackString = unpackString;
6
+ const decoder = new TextDecoder('utf-8');
7
+ function unpackInt(pSrc) {
8
+ var srcIndex = 0;
9
+ const sign = ((pSrc[srcIndex] >> 6) & 1);
10
+ var result = (pSrc[srcIndex] & 63);
11
+ while (srcIndex <= 4) {
12
+ if ((pSrc[srcIndex] & 128) === 0)
13
+ break;
14
+ srcIndex++;
15
+ result |= ((pSrc[srcIndex] & 127)) << (6 + 7 * (srcIndex - 1));
16
+ }
17
+ result ^= -sign;
18
+ return { result, remaining: pSrc.slice(srcIndex + 1) };
19
+ }
20
+ function unpackString(pSrc) {
21
+ var result = pSrc.slice(0, pSrc.indexOf(0));
22
+ pSrc = pSrc.slice(pSrc.indexOf(0) + 1, pSrc.length);
23
+ return { result: decoder.decode(new Uint8Array(result)), remaining: pSrc };
24
+ }
25
+ class MsgUnpacker {
26
+ constructor(pSrc) {
27
+ this.remaining = pSrc;
28
+ }
29
+ unpackInt() {
30
+ // let unpacked;
31
+ // if (!_unpacked) {
32
+ let unpacked = unpackInt(this.remaining);
33
+ this.remaining = unpacked.remaining;
34
+ // } else {
35
+ // unpacked = {result: this.remaining[0]};
36
+ // this.remaining = this.remaining.slice(1);
37
+ // }
38
+ return unpacked.result;
39
+ }
40
+ unpackString() {
41
+ let unpacked = unpackString(this.remaining);
42
+ this.remaining = unpacked.remaining;
43
+ return unpacked.result;
44
+ }
45
+ /** @param size - size in bytes */
46
+ unpackRaw(size) {
47
+ let unpacked = this.remaining.slice(0, size);
48
+ this.remaining = this.remaining.slice(size);
49
+ return unpacked;
50
+ }
51
+ }
52
+ exports.MsgUnpacker = MsgUnpacker;
@@ -1,50 +1,44 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UUIDManager = exports.createTwMD5Hash = void 0;
4
- var crypto_1 = require("crypto");
5
- var createTwMD5Hash = function (name) {
6
- var hash = (0, crypto_1.createHash)("md5")
7
- .update(Buffer.from([0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb, 0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29]))
8
- .update(name)
9
- .digest();
10
- hash[6] &= 0x0f;
11
- hash[6] |= 0x30;
12
- hash[8] &= 0x3f;
13
- hash[8] |= 0x80;
14
- return hash;
15
- };
16
- exports.createTwMD5Hash = createTwMD5Hash;
17
- // [{name: string, hash: Buffer}, ..]
18
- var UUIDManager = /** @class */ (function () {
19
- function UUIDManager(pOffset, pSnapshot) {
20
- if (pOffset === void 0) { pOffset = 65536; }
21
- if (pSnapshot === void 0) { pSnapshot = false; }
22
- this.uuids = [];
23
- this.offset = pOffset;
24
- this.snapshot = pSnapshot;
25
- }
26
- UUIDManager.prototype.LookupUUID = function (hash) {
27
- return this.uuids.find(function (a) { return a.hash.compare(hash) == 0; });
28
- };
29
- UUIDManager.prototype.LookupName = function (name) {
30
- return this.uuids.find(function (a) { return a.name === name; });
31
- };
32
- UUIDManager.prototype.LookupType = function (ID) {
33
- if (!this.snapshot) {
34
- return this.uuids[ID - this.offset];
35
- }
36
- else {
37
- return this.uuids.find(function (a) { return a.type_id == ID; });
38
- }
39
- };
40
- UUIDManager.prototype.RegisterName = function (name, type_id) {
41
- if (type_id === void 0) { type_id = this.offset - this.uuids.length; }
42
- this.uuids.push({
43
- name: name,
44
- hash: (0, exports.createTwMD5Hash)(name),
45
- type_id: type_id
46
- });
47
- };
48
- return UUIDManager;
49
- }());
50
- exports.UUIDManager = UUIDManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UUIDManager = exports.createTwMD5Hash = void 0;
4
+ const crypto_1 = require("crypto");
5
+ const createTwMD5Hash = (name) => {
6
+ let hash = (0, crypto_1.createHash)("md5")
7
+ .update(Buffer.from([0xe0, 0x5d, 0xda, 0xaa, 0xc4, 0xe6, 0x4c, 0xfb, 0xb6, 0x42, 0x5d, 0x48, 0xe8, 0x0c, 0x00, 0x29]))
8
+ .update(name)
9
+ .digest();
10
+ hash[6] &= 0x0f;
11
+ hash[6] |= 0x30;
12
+ hash[8] &= 0x3f;
13
+ hash[8] |= 0x80;
14
+ return hash;
15
+ };
16
+ exports.createTwMD5Hash = createTwMD5Hash;
17
+ // [{name: string, hash: Buffer}, ..]
18
+ class UUIDManager {
19
+ constructor(pOffset = 65536, pSnapshot = false) {
20
+ this.uuids = [];
21
+ this.offset = pOffset;
22
+ this.snapshot = pSnapshot;
23
+ }
24
+ LookupUUID(hash) {
25
+ return this.uuids.find(a => a.hash.compare(hash) == 0);
26
+ }
27
+ LookupName(name) {
28
+ return this.uuids.find(a => a.name === name);
29
+ }
30
+ LookupType(ID) {
31
+ if (!this.snapshot) {
32
+ return this.uuids[ID - this.offset];
33
+ }
34
+ else {
35
+ return this.uuids.find(a => a.type_id == ID);
36
+ }
37
+ }
38
+ RegisterName(name, type_id = this.offset - this.uuids.length) {
39
+ this.uuids.push({
40
+ name, hash: (0, exports.createTwMD5Hash)(name), type_id
41
+ });
42
+ }
43
+ }
44
+ exports.UUIDManager = UUIDManager;