bancho.js 0.10.0-rc.9 → 0.10.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,55 @@
2
2
 
3
3
  ## Version 0.10
4
4
 
5
+ ### Version 0.10.1
6
+
7
+ - **BanchoLobby: Fix beatmap never being refreshed from API**
8
+
9
+ ### Version 0.10.0
10
+
11
+ #### Highlights
12
+
13
+ - **BREAKING CHANGES**
14
+ - BanchoChannel#channelMembers is now a Map instead of a plain object.
15
+ - Following rate-limiting refactoring (see highlights below), the `limiterPublic` BanchoClient option is no longer supported.
16
+ Realistically this should never have been implemented, as bots are not supposed to ever send messages publicly (understand public channels like #osu, or every channel that are not PMs and multiplayer lobbies).
17
+ - The mods array is now initialized to `null` in `BanchoLobby`'s constructor instead of an empty array.
18
+
19
+ - **BanchoUser instances are now garbage-collected**
20
+ If you joined public channels like #osu, you will eventually get hundreds of thousands users registered, which inevitably caused some out-of-memory issues.
21
+ We fixed them by garbage-collecting these instances when they are no longer referenced anywhere, by using [`WeakRef`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakRef).
22
+ Support was also added using [`weak-value-map`](https://github.com/amapili/weak-value-map) as a peer dependency, which looks to be more memory-efficient but it is considered experimental. Probably only useful if you're running Node.js >= 10 < 14.6.0.
23
+
24
+ - **Implement the IRC QUIT command**
25
+ Bancho doesn't emit `PART` when users are disconnecting without leaving channels first. This fixes users that were never marked as having left channels they were part of when disconnecting.
26
+
27
+ - **Rate-limiting has been refactored**
28
+ We're now using a much simpler implementation based on a FIFO queue with rate-limiting.
29
+ Default rate limits for both user and bot accounts have been fine-tuned.
30
+
31
+ - **New `BanchoLobby` features:**
32
+ - New `banPlayer` method (using `!mp ban`)
33
+ - New `setName` method (using `!mp name`)
34
+ - New `gamemode` property (updated when referees use `!mp map` with gamemode id, or using `setMap` of course)
35
+ - When a player leaves the lobby (`playerLeft` event), the subsequent `updateSettings` call will emit `allPlayersReady` if all remaining players are ready.
36
+ This works around a lack of reporting from Bancho when every player is ready, except the one who has just left, though it is not automatic and you do have to call `updateSettings` yourself.
37
+
38
+ - **Add support for ACTION events (/me messages)**
39
+ See https://git.cartooncraft.fr/ThePooN/bancho.js/-/commit/e3636e427d4d00ce79b89b31b751d3e733622b75
40
+
41
+ - **Misc. bug fixes and minor improvements (eg. typings)**
42
+ See the changelog for dev versions below.
43
+
44
+ ### Version 0.10.0-rc.11
45
+
46
+ - Fix stats with players who have non-decimal global accuracy
47
+
48
+ ### Version 0.10.0-rc.10
49
+
50
+ - Switch to an actually FIFO rate-limiting library
51
+ The new implementation is actually correct now...
52
+ - Fine-tune rate limits again for user and bot accounts
53
+
5
54
  ### Version 0.10.0-rc.9
6
55
 
7
56
  - Updated all dependencies, fixing security issues (in dev dependencies)
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![NPM](https://nodei.co/npm/bancho.js.png?compact=true)](https://nodei.co/npm/bancho.js/)
4
4
  [![pipeline status](https://git.cartooncraft.fr/ThePooN/bancho.js/badges/master/pipeline.svg)](https://git.cartooncraft.fr/ThePooN/bancho.js/commits/master)
5
5
 
6
- ## Current release: 0.10.0-rc.9
6
+ ## Current release: 0.10.1
7
7
 
8
8
  # Introduction
9
9
 
@@ -7,7 +7,8 @@ const BanchoMultiplayerChannel = require("./BanchoMultiplayerChannel");
7
7
  const ConnectStates = require("./Enums/ConnectStates");
8
8
  const IrcCommands = require("./Enums/IrcCommands");
9
9
  const Nodesu = require("nodesu");
10
- const RateLimiter = require("limiter").RateLimiter;
10
+ const RateLimiterMemory = require("rate-limiter-flexible").RateLimiterMemory;
11
+ const RateLimiterQueue = require("rate-limiter-flexible").RateLimiterQueue;
11
12
  const PrivateMessage = require("./PrivateMessage");
12
13
  const ChannelMessage = require("./ChannelMessage");
13
14
 
@@ -44,7 +45,7 @@ class BanchoClient extends EventEmitter {
44
45
  this.osuApi = new Nodesu.Client(apiKey, {
45
46
  parseData: true
46
47
  });
47
- this.rateLimiter = new RateLimiter({ tokensPerInterval: limiterPrivate, interval: limiterTimespan });
48
+ this.rateLimiter = new RateLimiterQueue(new RateLimiterMemory({ points: limiterPrivate, duration: limiterTimespan / 1000 }));
48
49
  }
49
50
  else if(typeof optionsOrUsername == "object") {
50
51
  /**
@@ -61,8 +62,8 @@ class BanchoClient extends EventEmitter {
61
62
  const options = {
62
63
  host: "irc.ppy.sh",
63
64
  port: 6667,
64
- limiterTimespan: 10000,
65
- limiterPrivate: 5,
65
+ limiterTimespan: 12500,
66
+ limiterPrivate: 9,
66
67
  limiterPublic: undefined,
67
68
  botAccount: false,
68
69
  };
@@ -80,9 +81,9 @@ class BanchoClient extends EventEmitter {
80
81
  process.emitWarning("You have set both deprecated custom rate limits and `botAccount`. The default bot accounts limits will take precedence. This warning will be removed in v1.0.0.");
81
82
  }
82
83
 
83
- const limiterPrivate = options.botAccount ? 300 : options.limiterPrivate;
84
- const limiterTimespan = options.botAccount ? 60000 : options.limiterTimespan;
85
- options.rateLimiter = new RateLimiter({ tokensPerInterval: limiterPrivate, interval: limiterTimespan });
84
+ const limiterPrivate = options.botAccount ? 298 : options.limiterPrivate;
85
+ const limiterTimespan = options.botAccount ? 62500 : options.limiterTimespan;
86
+ options.rateLimiter = new RateLimiterQueue(new RateLimiterMemory({ points: limiterPrivate, duration: limiterTimespan / 1000 }));
86
87
  }
87
88
 
88
89
  this.username = options.username;
@@ -27,7 +27,7 @@ class BanchoMessage {
27
27
 
28
28
  /**
29
29
  * The content of this message
30
- * @type {string}
30
+ * @returns {string}
31
31
  */
32
32
  get content() {
33
33
  return this.message;
@@ -35,7 +35,7 @@ class BanchoMessage {
35
35
 
36
36
  /**
37
37
  * Tries to parse this message as an ACTION (/me message).
38
- * @returns {[string]}
38
+ * @returns {string}
39
39
  */
40
40
  getAction() {
41
41
  const action = actionRegex.exec(this.message);
@@ -138,8 +138,8 @@ class BanchoLobby extends EventEmitter {
138
138
  case "playerChangedBeatmap":
139
139
  case "refereeChangedBeatmap":
140
140
  case "beatmapFromSettings":
141
- this.beatmapId = ret.id;
142
141
  if(ret.id != this.beatmapId) {
142
+ this.beatmapId = ret.id;
143
143
  this.beatmap = null;
144
144
  for(const player of this.slots)
145
145
  if(player != null)
@@ -45,10 +45,10 @@ class BanchoBotStatsCommand {
45
45
  }
46
46
  };
47
47
  const accuracyListener = (msg) => {
48
- const m = /Accuracy: (\d+)\.(\d+)%/.exec(msg.message);
48
+ const m = /Accuracy: (\d+(\.\d+)?)%/.exec(msg.message);
49
49
  if(m) {
50
50
  // Accuracy returned by !stats are inaccurate so we're simply setting it in the return object instead.
51
- this.return.accuracy = Number(m[1] + "." + m[2]);
51
+ this.return.accuracy = Number(m[1]);
52
52
  this.resolve(this.return);
53
53
  this._removeListeners();
54
54
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bancho.js",
3
- "version": "0.10.0-rc.9",
3
+ "version": "0.10.1",
4
4
  "description": "Interface with Bancho over IRC, made easy and reliable",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -35,8 +35,8 @@
35
35
  "weak-value-map": "^1.0.1"
36
36
  },
37
37
  "dependencies": {
38
- "limiter": "^2.1.0",
39
- "nodesu": "^0.7.2"
38
+ "nodesu": "^0.7.2",
39
+ "rate-limiter-flexible": "^2.3.12"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "weak-value-map": "^1.0.1"