* Chat monitor: Improve the handling of usernames
This PR ignores word boundaries in evasion regexes when filtering usernames, preventing the use of usernames with evasions of slurs in them.
* properly fix merge conflicts
- Default precision is now 3.
(Instead of "3 months 25 days 17 hours 46 minutes 40 seconds", it'll
say "3 months 25 days 17 hours". You can still set the precision to
`Infinity` if you actually prefer that.)
- Now displays "forever" for Infinity or overflow durations
- No longer skips blank precision levels
(Shows "3 hours 0 minutes 10 seconds" instead of
"3 hours 10 seconds")
It turns out that when I switched us from `assert` to `assert.strict`,
I didn't actually update any existing tests or tell anyone:
0df0d234f2
So apparently everyone else just kept on using `strictEqual`.
This will be a PR and also throw an error if people continue trying to
use it, which should make it much clearer what PS policy is on this.
A lot of the problem may be that TypeScript marks assert.strict.equal
as deprecated when it's not. This was fixed 4 days ago:
https://github.com/DefinitelyTyped/DefinitelyTyped/pull/48452
But this probably hasn't made it to a thing yet. Until then, you'll
have to deal with TS marking your tests as deprecated, but it shouldn't
be too long.
Accidentally using `assert` instead of `assert.strict` should now show
an error. This protects against the probably much worse mistake of
accidentally using `assert.equal` rather than `assert.strict.equal`.
`assert.ok` is also deprecated now.
- `ip` and `ipself` are now separate permissions. This means that `ip`
is now a generalized permission for viewing IPs (no more need to use
`globalban`, since `ipself` now controls the ability to see your own
IP address)
- `alts` and `altsself` are now also separate (all users used to be
able to `altsself`).
- `modchat`, `modchatall`, and `manageroom` are now just one `modchat`
permission whose jurisdiction controls how high you can set modchat.
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
Permissions have gotten out-of-date, so this commit syncs them.
Default permissions are now matched with Main, in particular including
the new & rank as admin (removing the old Leader rank and ~ symbol).
Relevant changes:
- Admin (~) and Leader (&) have been merged into Admin (&)
- The 'ban' permission was split into 'globalban' and 'ban'
- The 'broadcast' permission was renamed 'show' (going forward,
"broadcast" should only refer to the big red/blue/green
announcement bars.)
- Bots no longer have global moderation abilities, making it
easier to give untrustworthy bots the "bot" rank.
I couldn't completely remove the global room in one commit, but this
solves basically every problem with it by making it no longer a `Room`.
In particular, this means:
- It's no longer of type `Room`
- It's no longer in the `Rooms.rooms` table
- Its class name is now `GlobalRoomState` rather than `GlobalRoom`
- It no longer tracks its own user list (online user count is now
provided by `Users.onlineCount`)
- It's no longer a socket channel (there's new syntax for "send this
message to every user")
This implements two big changes:
- All settings shared between `room.chatRoomData` and `room` have been
merged into `room.settings` (so, for instance, `room.slowchat` is now
only `room.settings.slowchat`).
This makes it so we never have to worry about them getting "out of
sync".
- Checking to see if a room is persistent is now `if (room.persist)`
instead of `if (room.chatRoomData)`
- `Rooms.global.writeChatRoomData()` is now rarely called directly;
there's a new `room.saveSettings()` which will handle it for you.
- All properties of `room.settings` are now optional (except
`title`).
- There's a new file `user-groups.ts` which handles authority.
- `room.auth` and `Users.globalAuth` are now
`Auth extends Map<ID, GroupSymbol>` objects.
- `room.auth` is now always defined, removing the need for
`room.auth?.[userid]` workarounds.
- A lot of code relating to usergroups and permission checks have
been refactored.
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
I don't want to remove them completely because they can still be used
for inspiration for writing new tests, but to me, "skipped test"
implies "bug that needs to be fixed", and these aren't bugs so much as
outright outdated code.
Closes#6665
Not having prefer-const on the JS side makes JS -> TS refactors really
unreadable. This commit just auto-fixes it so we're using
`prefer-const` everywhere.
By adding a `getGame` function of type:
```
// null is returned if the gameids don't match
// or the game doesn't exist
getGame<T extends RoomGame>(constructor: new (...args: any[]) => T) => T | null
```
(Credits @urkerab and @whalemer for the function signature.)
It allows refactoring previous code of:
```
if (room.game && room.game.gameid !== 'hangman') return;
const game = room.game as Hangman;
```
to:
```
const game = room.getGame(Hangman);
if (!game) return;
```
This has a couple of advantages:
- TypeScript will throw an error if the if condition is not present.
- In the new code, the template must extends `RoomGame` and be assignable to the same ID, so it's 100% typesafe