The chatQueue previously put a reference to the room directly in the
chatQueue array. This refactors it to use a room ID.
This mostly doesn't matter much, but it's nice not to have references
to rooms outside of the room, and makes for slightly cleaner code by
not needing the weird workaround to see if the room has expired.
Namelock used to get its own symbol, but it's been rolled in with
the regular lock symbol. It's easy enough for people who need to to
tell namelocked and regularly locked users apart, anyway, and this
should be less confusing to users who aren't familiar with the
distinction.
PS now properly restricts name lengths to 18 characters.
The new system is mainly notable for not applying namefilter (and
therefore monitors) to names that are over the limit.
Locks, bans, and namelocks are now stored in `config/punishments.tsv`
and last through restarts. They expire after a set amount of time.
By default, locks and namelocks last 37 hours, and bans last 7 days.
Namelocks now imply regular locks, so namelocked users can't talk.
Locks, bans, and namelocks can no longer be stacked. Now only one
can be active at a time. Since locks < namelocks < bans, this
shouldn't be a big deal in practice.
This all involves a huge refactor. Basically every function in
punishments.js has been changed, and most of them have been renamed,
too. In terms of public API, `lockName` has been renamed `namelock`.
Lock/namelock/ban reasons tracking is supported but currently
unused. It'll probably be fully supported in a later commit.
More punishment-related functionality has been moved from users.js
to punishments.js as well.
Closes#1471
Fix typos on sentences.
Make it write on modlog and global modlog.
Let namelocked names be reusable after unnamelock in case of an accident.
Set named to true on User object construction if it is found as namelocked.
Give proper reasoning on namelocked message.
Among the newly added rules, there are quite a few intended to enforce
compliance of CONTRIBUTING.md-blessed idioms, as well as ensure
safe usage of classes and constant bindings.
We are also now enforcing usage of early return in commands.js,
which has 100% compliance as of fd2c45c.
Requirements for promoting an offline user have now been unified for
room promotions, global promotions, and the special roomowner
appointment.
Now, in all these situations, an offline promotion is possible as
long as the user has a global rank or room rank in a registered
chat room (including private and hidden chat rooms, but excluding
unregistered rooms like battles and groupchats).
- Method `this.runBroadcast()` has been split from `this.canBroadcast()`.
It's now the only method handling command-usage and intended as the main API
for synchronous commands. Async commands will execute both separately.
Note that the `suppressMessage` parameter is now passed to `runBroadcast`.
- The semantics of `broadcasting` have been similarly split.
`this,broadcastMessage` will be set to a truthy value when `this.canBroadcast` is run.
`this,broadcasting` will only be set to `true` once `this.runBroadcast` is executed.
This is mostly targeted at the AG bot that's everywhere. Playing a
huge number of battles at once makes it way too common to be matched
with it over and over again, which is undesirable.
The callback code in TeamValidator and the functions that use it have
been refactored to use Promises.
Pretty much all signatures have been changed, for instance:
TeamValidator.validateTeamSync(format, team)
-> TeamValidator(format).validateTeam(team)
TeamValidator.validateTeam(format, team, callback)
-> TeamValidator(format).prepTeam(team) // returns a Promise
Validators are no longer cached since they're really lightweight. They
contain a format and a Tools instance, and Tools instances are already
cached in Tools anyway. This saves a tiny bit of RAM in exchange for a
tiny bit of CPU time, but more importantly makes the code more
readable.
I'm introducing a new pattern/API for managing the parts of code with
child processes - their process managers are now at .PM and are now
opt-in, so you can use them synchronously without needing to spawn
any processes.
Fixes#2448
`battle.tour` is now just a reference to the tour.
`battle.rated` is now just the minimum Elo rating of the two players
in the battle.
With the new RoomGame battles, neither of their old values are
necessary anymore.
This filters out characters commonly used for impersonation. It's
based on the one used in Main, but now the rest of you can enjoy it
too!
This also filters zalgo and other annoying characters out of pokemon
names as well as usernames.
Now that nodejs/node#3072 is mostly fixed, we can finally start using
Node 4+ features.
This refactor:
- uses arrow functions where appropriate
Note that arrow functions still aren't used in Mocha, where `this`
is sometimes meaningful.
This also removes the need for .bind() nearly everywhere, as well
as the `self = this` trick.
- refactors Validator and Connection into ES6 classes
- no longer uses Array#forEach for iterating arrays
We strongly prefer for (let i = 0; i < arr.length; i++) because of
performance reasons. Most forEaches have been replaced with for..of,
though, which is 5x slower than the long-form loop but 2x faster
than forEach, which is good enough outside of most inner loops.
The only exception is tournaments, which is due for a more invasive
refactor soon anyway.