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.
Most images are hosted in places that already support HTTPS, so all
we need to do is transparently rewrite them to be protocol-local.
For the rest, I don't care enough to enforce HTTPS on them. At
least wait for browsers to complain more about it...
If a room is under modjoin, /invite will try to roomvoice a user who
doesn't already have permission to join the room.
This feature is pretty rudimentary and only works if the modjoin
setting is `+`, but I'm 80% sure it's better than nothing.
Fixes the long-standing issue of bad interaction between `this.parse('!command')` and `this.canBroadcast()`: each time the latter was called, it would announce the command usage.
The old `.message` is dropped, and the new `.message` is the old
`.originalMessage`.
Having a fake `.message` pretending a namespace command is a
top-level command seems entirely unnecessary, so I still don't
really understand what it's for in the first place.
this.errorReply sends a red error message inline. The main special
thing is that it takes advantage of our new /error support in PMs to
send inline errors in PMs as well.
This was done by applying chat plugins to the cloned commands
object rather than the original, which should probably have been
done in the first place.
The modlog API is now accessible from outside of CommandParser
through CommandParser.writeModlog.
We now also have a concept of a global modlog, and some new
command APIs for writing to it.
These are commands from commands.js, before they're possibly
overwritten by other chat commands. It's a shallow copy so memory
impact will probably be minimal.
- Return proper error message for forbidden commands.
- Fix a recursive crash in lobby-less servers.
- Fix a stack overflow in some (very stupidly) modded servers.
Apparently modlog is in CommandParser, which doesn't make it very
straightforward to access outside of the this. functions in
commands. This change at least makes it possible to write to
other rooms' modlogs in commands, but in the long term we might
want to move modlog from CommandParser to Rooms, or at least
expose an API accessible outside of commands.
This gives commands like !htmlbox and /roomintro a basic validator,
to warn about typoes related to mismatched HTML tags. This is NOT
intended to be secure (we have a separate sanitizer client-side for
that), but is intended to guard against user error only.
this.parse in chat commands was changed to default to parsing
in-namespace, when namespaces were introduced. This commit changes
it back to parsing globally, with in-namespace parsing being
optional and defaulting to off.
Seperated /privateroom command into /privateroom and /hiddenroom. In
hidden rooms, mostly set by battle players, global staff maintain their
ranks within the room, but the rank is not kept in secret/private rooms
(only set by users who can create chat rooms).
Created command /whoare to allow global staff to see the hidden rooms a
user is in.
If a crash happens during a command (which is around 99% of all
crashes), a bug in either Node or SockJS causes the user who issued
the command to be unable to do say or do anything (although they'll
still receive messages).
We used to have a crashguard to prevent this from happening, but
it was removed due to suspicions of being a significant lag source.
Later lag investigation has shown that it's not the biggest source
of lag, so we're reintroducing that crashguard for now.
Adds support for adding the word 'global' in front of global
promotion/demotion commands, for instance /globalmod username
to promote a user to global mod.
Also adds /roomdeauth.
JSHint is now a fair bit stricter, and is now correctly checking
files in `mods/`.
The code has been fixed to match the new stricter standards.
JSHint has now caught its second actual bug: Gen 5 Pinap Berry
was Ice instead of Grass.
I used a hack to make the multiple declaration errors go away,
so all that remained in jsHint were actual errors, which I've
now mostly fixed.
All this linting ended up uncovering one actual bug: Uproar's
message not showing. It's a very minor bug in a move no one uses,
so I'm going to fold it into this commit.
It now always fills out targetUsername, and passes the exactName
flag through to splitTarget. /whois will no longer follow through
name changes unless the /whois user has auth (voice counts).
This is not a secure way to hide from unvoiced users; other
commands such as PMing will still follow through.