This both allows staff to lock users that are offline, given they have a previous punishment (globally or in any room)
This also will utilize existing punishment information for handling nameblacklists, making a nameblacklist of a user with a current punishment equivalent to having used /blacklist at the moment of that punishment
This is used in several parts of the sim where commands carryout potentially dangerous actions. For this reason, it should be apart of a user's constructor.
The new FS module is an abstraction layer over the built-in fs module.
The main reason it exists is because I need an abstraction layer I can
disable writing from. But that'll be in another commit.
Currently, mine is better because:
- paths are always relative to PS's base directory
- Promises (seriously wtf Node Core what are you thinking)
- PS-style API: FS("foo.txt").write("bar") for easier argument order
- mkdirp
This also increases the minimum supported Node version from v6.0 to
v7.7, because we now use async/await. Sorry for the inconvenience!
This also drops the mock-fs-require-fix dependency
mock-fs-require-fix was always kind of a huge hack. It's no longer
necessary, with an FS API that does everything it used to.
This removes a lot of other hacks from test/main.js, which is nice.
This is a surprisingly minor refactor considering how many files it
touches, but most of this is only renames.
In terms of file renames:
- `tools.js` is now `sim/dex.js`
- `battle-engine.js` is now `sim/index.js` and its three classes are
in `sim/battle.js`, `sim/side.js`, and `sim/pokemon.js`
- `prng.js` is now `sim/prng.js`
In terms of variable renames:
- `Tools` is now `Dex`
- `BattleEngine` is now `Sim`
- `BattleEngine.Battle` is now `Sim.Battle`
- `BattleEngine.BattleSide` is now `Sim.Side`
- `BattleEngine.BattlePokemon` is now `Sim.Pokemon`
* Users#mergeConnection - run room.game.onUpdateConneciton for battles
(1) oops, forgot that battles were roomgames as well, so they needed to update for dc's (guest => player) and send the requests accordingly
(2) I'm so bad
* Use PS style conventions
- prevents onConnect from being called twice in onUpdateConnection AND in joinRoom for autojoin.
```
CRASH: Error: onConnect
at ScavengerHunt.onConnect (/home/ubuntu/workspace/suppress/chat-plugins/scavengers.js:137:9)
at ChatRoom.onConnect (/home/ubuntu/workspace/suppress/rooms.js:1369:51)
at User.joinRoom (/home/ubuntu/workspace/suppress/users.js:1181:9)
at User.tryJoinRoom (/home/ubuntu/workspace/suppress/users.js:1143:25)
at CommandContext.autojoin (/home/ubuntu/workspace/suppress/chat-commands.js:1334:13)
at CommandContext.run (/home/ubuntu/workspace/suppress/chat.js:292:28)
at CommandContext.parse (/home/ubuntu/workspace/suppress/chat.js:138:19)
at Object.Chat.parse (/home/ubuntu/workspace/suppress/chat.js:807:17)
at User.processChatQueue (/home/ubuntu/workspace/suppress/users.js:1433:9)
at Timeout.chatQueueTimeout.setTimeout [as _onTimeout] (/home/ubuntu/workspace/suppress/users.js:1413:15)
Additional information:
user = Guest 2
room = global
pmTarget = undefined
message = /autojoin gamecorner,scavengers
CRASH: Error: onConnect
at ScavengerHunt.onConnect (/home/ubuntu/workspace/suppress/chat-plugins/scavengers.js:137:9)
at ScavengerHunt.onUpdateConnection (/home/ubuntu/workspace/suppress/room-game.js:174:28)
at connection.inRooms.forEach.roomid (/home/ubuntu/workspace/suppress/users.js:891:15)
at Set.forEach (native)
at User.mergeConnection (/home/ubuntu/workspace/suppress/users.js:878:22)
at User.merge (/home/ubuntu/workspace/suppress/users.js:833:9)
at User.handleRename (/home/ubuntu/workspace/suppress/users.js:738:9)
at User.validateRename (/home/ubuntu/workspace/suppress/users.js:698:8)
at Verifier.verify.then.success (/home/ubuntu/workspace/suppress/users.js:652:10)
at process._tickCallback (internal/process/next_tick.js:103:7)
```
This abstracts matchmaking logic from the global room away to its own
module, allowing the two to be decoupled from each other entirely with
some refactoring.
Related to #3361
- Always return a boolean. *Sometimes* returning the name under which a user qualifies is not useful enough.
- The default for an invalid group or pseudo-group is now false. Though maybe it should throw instead?
- Users with auth in the relevant room are now treated as trusted.
We had a lot of discussion in Dev and a somewhat-close poll, but in
the end "Chat" was a better name than "Messages", and also has the
advantage of being shorter (which is nice for Chat.html and
Chat.plural which should be short).
CommandParser.parse has been refactored so most of its logic now
resides in CommandContext#parse.
CommandParser recursion is now a lot lighter. Instead of make a new
copy of the CommandContext, the existing one is reused.
messages.js no longer needs to exist; its functionality is now in
CommandContext#parse and CommandContext#canTalk. Its duplicate code
is gone now! :D
The inNamespace option of CommandContext#parse appears unused and has
been removed.
Users#matchesRank has been renamed Users#authAtLeast.
This unifies modjoin checks (both Room#modjoin and Room#staffRoom join
restrictions) under one function, Room#checkModjoin.
This makes it easier for commands to check whether a user should know
about a room's existence, which, previously, had been duplicated
unreliably in each command's implementation.
Fixes#2426
Roombans/blacklists have been mostly rewritten from scratch.
The new code mostly uses the same patterns as global punishments.
In addition:
- /ban has been renamed /globalban
- globalbans and blacklists now require a reason
- bans and blacklists in public rooms now show up in global modlog
- blacklist syntax is different: /blacklist and /unblacklist
- ban/blacklist display in /whoare is now more detailed
This isn't all the work that needs to be done on blacklists, but it's
the highest-priority changes.
- blacklists.tsv has been renamed room-punishments.tsv
- The format everywhere has changed to roomid:userid, rather than
roomid|userid
- roompunishments.tsv's format is now `Room ID:User ID, IPs and alts`
rather than `User ID, Room ID|IPs and alts`, which is more sane and
also cuts down on repetition of room IDs
Those are the changes that affect storage format, which are highest
priority because I don't want to support the previous format.
Other changes include:
- Punishments.roombannedIps renamed to Punishments.roomIps
- Punishments.roombannedUserids renamed to Punishments.roomUserids
- Some refactoring for ES6 destructuring
- Various bugfixes
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.
The 'root' permission used to be applied globally, but a refactor made
it apply per-room, so admins wouldn't have the permission while in
private rooms and rooms they have other roomauth in.
This once again makes 'root' a global permission.
This commit introduces Tools.html and Tools.plural, helper functions
for string construction.
Tools.html is a template tag function that escapes HTML inside the
template string.
Tools.plural is a helper function that takes a passed Number, Array,
Set, or Map and returns a string representing whether or not it's
plural.
It also starts doing some refactors of some files to make it clear how
I expect code style for template strings to look.
Previously, we used ' for IDs, " for English text, and ' for code.
We should now be using ' for IDs, ` for English text, and ` for code.
User#games no longer retains games; it instead gets them from
Rooms(roomid).game.
The Trivia tests needed to be fixed for fidelity to continue passing.
This should make it easier to hunt down that bug that's causing SockJS
not to disconnect.
(I have suspicions that it's related to websocket-raw but it's always
nice to get more data...)