These changes were supposed to be in de524c1a26 but got lost in my
Git stash...
Once again, this is very experimental code; please don't base any
serious changes on it.
Room#chat has now been folded into CommandParser.parse.
User#chat now directly calls CommandParser.parse, saving a line of
stack, and eliminating a function that never did much, really.
Before, PS often relied on bots to handle moderating users who send messages that contained too many capitals or stretching.
This should be something that's preventative, not reactive, which is what this does.
Now, bots are no longer needed for these purposes as this allows stretching/caps punishments to be prevented, server-side.
This is basically a system that allows for room moderators or higher to set a minimum time between a user's messages sent to the room.
This is especially helpful for times the server might be lagging or the chat is just moving much too fast.
Alternatively, this could also help to stop spammers in their tracks and give staff more time to handle them as well.
The naming are now consistent: /rangeban and /banip both work, as
do /rangelock and /lockip.
In addition, they no longer crash the server and mostly do what
they say they do.
Locking/banning hosts is no longer supported, because it's too much
code for something no one needs to do.
Modules compiled using node.js' addons API do not get added to
require.cache and will make /hotpatch crash if any of them happen to
have been required when it is called.
Commands like /promote and /[rank] no longer work; instead we require
/globalpromote and /global[rank]. This should cut down on people who
accidentally globally promote someone they meant to room-promote.
- 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.
Context in command-parser.js has been renamed CommandContext and
refactored to use ES6 classes. Its also subsumed the canTalk
function. Future iterations will probably put the parse function
inside it as well.
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.
Crashlogger now supports passing in a dictionary of additional
information to report, so we no longer need to resort to making fake
errors.
The hadException parameter has now been removed entirely. I don't know
of a use case for it to be false.