Commit Graph

185 Commits

Author SHA1 Message Date
Annika
ae11a699a6
Add a BasicRoom#tr method (#7143) 2020-08-05 19:14:41 -07:00
Mia
fbfd31e1cf
Support configuring when crashes are private (#7122) 2020-08-04 02:18:57 -07:00
Volco
26e2a1c4d4
Fix renaming groupchats and groupchat creation (#7123) 2020-08-02 16:21:49 -07:00
Charlie Kobayashi
69cf80ed2a
Make broadcastBuffer an array (#7103)
This removes any extra unnecessary newlines at the end of each message sent to each client, and will always handle all messages assigned to the buffer properly.
2020-07-31 17:57:19 -07:00
Guangcong Luo
7d95f68d26 Fix message corruption
Fixes #7099
2020-07-31 16:39:35 -07:00
Guangcong Luo
c39be07d23 Fix crash messages not appearing in Upper Staff 2020-07-30 17:17:04 -07:00
Mia
29afa9f454
Fix RO rank displaying (#7090) 2020-07-30 13:17:46 -07:00
Annika
74a22d0402
Correctly display reveal button for /cleartext (#7082) 2020-07-29 14:21:42 -07:00
Guangcong Luo
add3a5d9f0 Fix bug when hidetexting own text 2020-07-29 00:37:18 -07:00
Mia
94fff9d496
Support customizing permissions per-room (#6883) 2020-07-29 00:22:03 -07:00
Mia
7216c493bb
Support renaming groupchats (#6965) 2020-07-29 00:21:24 -07:00
Annika
2da0317a71
Implement a /cleartext command (#7065) 2020-07-29 00:16:30 -07:00
Annika
3a3af89054
Display join/leave messages for locked players (#7066) 2020-07-26 16:03:28 -07:00
Guangcong Luo
c08a1a3199 Fix drivers not having mod powers in battles
Battles are now considered personal rooms, and so
`globalGroupInPersonalRoom` now applies to them properly.
2020-07-24 18:51:38 -07:00
Annika
7375ab4d90
Add cooldown for unregistered namechanges (#7032) 2020-07-23 00:00:29 -07:00
Peach
e9611b7ce2
Remove unnecessary references to the global room (#7033) 2020-07-22 08:52:46 -07:00
Annika
960d7a927f
Fix bug in destroyPersonalRooms() (#7031)
This will actually destroy groupchats when a user is locked/globally banned, which to my understanding is the intended behavior.
`continue`ing when a room isn't persistent makes no sense, since groupchats are by definition not persistent.
2020-07-21 21:24:50 -07:00
Annika
570df13186
Support renaming battles (#7015) 2020-07-18 21:27:24 -07:00
Kirk Scheibelhut
eea2196280
Server side changes to support persistent user settings and privacy changes (#6947)
NOTE: This is changes the semantics of `hidenext`/`ionext` from
applying to the next created *battle* to applying to the next
created *search*/*challenge*.
2020-07-06 21:18:38 -07:00
Annika
26150aab1b
Fix bug in /renameroom (#6952) 2020-07-03 11:48:25 -07:00
Guangcong Luo
26615490f7 Merge BasicChatRoom and BasicRoom
They were only ever kept separate because of GlobalRoom. It might be
useful to support rooms that aren't ChatRooms, but we've been chucking
properties into either BasicChatRoom or BasicRoom essentially at
random, so I think it makes sense to wait until we actually have a
use-case for a non-Chat room before carefully deciding which properties
belong where.
2020-07-02 18:54:02 -07:00
Guangcong Luo
46c9afa2f3
"Remove" the global room (#6885)
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")
2020-07-02 11:31:34 -07:00
Mia
75f9937aad
Info: Support viewing current media requests and hiding media (#6907) 2020-06-30 15:59:52 -07:00
Annika
bc2aec5c82
Roomevents: Support event categories (#6820) 2020-06-21 21:46:11 -07:00
Mia
f9e79220dd
Polls: Support queuing (#6595) 2020-06-20 23:56:04 -07:00
Guangcong Luo
214aef6df6 Strongly type Rooms.global.settingsList 2020-06-20 21:45:02 -07:00
Guangcong Luo
20336fdfa0 Refactor /requestshow 2020-06-18 23:47:39 -07:00
Mia
501f773204
Improve /requestshow (#6868) 2020-06-18 23:43:41 -07:00
Mia
f8b95ce9a0
Rooms: Save creation time for all rooms (#6845) 2020-06-18 19:45:30 -07:00
Guangcong Luo
839d86a2ab Refactor /makegroupchat a little
None of these are likely to fix the lag spike, but I couldn't find
anything that stuck out.
2020-06-17 21:11:52 -04:00
Mia
6c97866f83
Add commands to show media in chat (#6745) 2020-06-16 14:40:10 -07:00
Guangcong Luo
97b856596e Fix lobby autojoin on side servers 2020-06-11 17:06:16 -07:00
Austin Couturier
c9b2b9dbf2
Change |pm|~ to |pm|& (#6827) 2020-06-10 21:53:36 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07:00
Guangcong Luo
8c4d55b184 Fix bugs in Settings refactor 2020-06-09 15:40:54 -04:00
Mia
15fed24b40
Refactor auth and room.settings (#6777)
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>
2020-06-09 08:22:25 -07:00
Guangcong Luo
7b33aef0e3 Fix room events crashing with no alias
PR #6781 only fixed one of the crashes; the real problem was that the
code expects aliases to be an empty array if rooms have no aliases,
which have multiple flaws including unnecessarily taking up JSON
space.
2020-06-04 14:49:38 -04:00
Annika
b454343aee
Room events: Support aliases and renaming (#6748) 2020-05-30 17:54:13 -07:00
Guangcong Luo
ddb9a5d11e Improve code documentation 2020-05-26 21:29:34 -04:00
Guangcong Luo
69f866ea94 Rephrase "has crashed" to "crashed"
This is a really minor thing, but fewer words tend to make
sentences more readable, and crash messages should focus more
on why something crashed than the crash itself.
2020-05-26 19:35:46 -04:00
Charlie Kobayashi
b30d09a3eb
Scavengers: Initialize all settings as null (#6734) 2020-05-23 14:46:59 -07:00
Charlie Kobayashi
9cb8fc4257
Scavengers: Convert to TypeScript (#6726) 2020-05-22 17:06:03 -07:00
Konrad Borowski
c687b3b0ed
Replace attributed uhtml on change (#6693)
Not doing so wastes a lot of bandwidth.

This fixes https://www.smogon.com/forums/threads/dont-send-all-uhtml-messages.3664370/

`|uhtmlchange|` is no longer automatically parsed; please use
`room.uhtmlchange(` instead.
2020-05-16 07:16:42 -07:00
Kris Johnson
2a642afac9
Support changing /data's tier in /roomsettings (#6675) 2020-05-15 18:55:09 -07:00
HoeenHero
8c9225fc5c Don't override the rules link with null when initializing 2020-05-15 09:13:14 -04:00
Ben Davies
1f595fd6a6
Prevent user identity updates from sending leave messages for guests (#6641)
Guests usually don't appear in join/leave/rename messages, but it's
possible for a bot to /trn to a guest nick with an assertion from the
login server and trigger a leave message for a guest nick to get sent.
This shouldn't have any consequences for the official client, but can
crash bots that keep state for users.
2020-05-02 12:33:00 -07:00
Guangcong Luo
8498842697 Make custom room ranks always override
Custom room rank symbols will now override all other ranks in the
userlist.

Their permissions now also fall back to global permissions.

(Also fix an obscure crash with custom rank symbols.)
2020-04-18 07:22:29 -07:00
Guangcong Luo
776ccf9796
Refactor Sockets to ProcessManager+TypeScript (#6584) 2020-04-17 04:05:45 -07:00
Guangcong Luo
c49343b7e2 Setting a room rank can no longer demote globals
Previously, if you gave e.g. roomvoice to a global moderator, that
would demote their room rank to voice. Now, they will remain a
moderator, with "voice" only appearing in `/roomauth` and `/auth`.

(Includes a refactor of Config.groups)
2020-04-17 03:32:11 -07:00
Guangcong Luo
ae129ed8d7 Report full stack trace for crashes
We previously only reported the first line of the stack trace, but now that .readmore exists, showing
the full stack trace isn't too spammy anymore.

Also, private logs are now put into Upper Staff.
2020-04-11 04:20:19 -04:00
Mia
3fc757e958
Typescript chat-commands/moderation, refactor Punishments (#6490) 2020-04-08 11:56:19 -07:00
fart
80cfacc2b0
Support /hidetext [line count] (#6471) 2020-03-22 15:53:40 -07:00
Guangcong Luo
7de51956c5 Change BasicChatRoom to Room in some types
`user.can` and `user.authAtLeast` now take `Room | BasicChatRoom`
instead of `BasicChatRoom`. It's now significantly less necessary to
cast things to `BasicChatRoom`.
2020-03-15 19:52:59 -07:00
Guangcong Luo
125fe31d06 Improve eslintrc
Fixed some more code style, allowing these rules to be enabled:

- `comma-dangle`
- `function-paren-newline`
- `member-delimiter-style`
- `no-eval`
- `no-fallthrough`
- `no-misused-promises`
- `no-unused-vars`
- `operator-linebreak`
2020-03-06 22:35:55 -08:00
Waleed Hassan
8aa4f053bb
Use optional chaining and linter improvements (#6422)
This is mostly just a follow up to #6342.

`prefer-optional-chaining` was turned on and fixed in every location it
complained in. The transformed function [0] looks expensive from a
glance but from skimming through the replaced sites it doesn't appear
to be ran in any important place, so it should be OK.

The linter improvements are:
- Increase linter performance
	- Make `full-lint` and `lint` write to different caches so we
	  avoid overwriting their caches since they're different configs
	- Change husky's hook to `npm run lint` so as to write to the
	  same cache
	- Remove `@typescript-eslint/eslint-plugin-tslint` which is
	  essentially a wrapper to TSLint because the rules aren't worth
	  running another linter
- Convert `.eslintrc.json` and `.eslintrc-syntax.json` to two spaces
  rather than four tabs to respect PS' `.editorconfig`
- Rename `fulllint` to `full-lint` to ease spelling it

[0] - https://pastie.io/mmtxpf.js (prettified)
2020-03-06 11:44:32 -08:00
Guangcong Luo
b21c9047e2
Migrate to typescript-eslint (#6342) 2020-03-05 08:33:06 -08:00
whales
26fa367f75
Fix bugs with renaming rooms (#6392) 2020-02-24 23:54:10 -08:00
whales
38daf467fc
Add some common rooms to the roomid type (#6393) 2020-02-24 19:52:41 -08:00
whales
926970f765
Automatically upload replays when reporting (#6380) 2020-02-21 00:47:19 -08:00
Waleed Hassan
34e215c7a6
Support renaming rooms (#6295) 2020-02-21 00:47:07 -08:00
Kris Johnson
2ea84725e2
Typescript Daily Spotlight, RoomFAQs, and Wi-Fi (#6373) 2020-02-18 13:26:44 -08:00
Kris Johnson
36d6dc8b0c
Typescript Jeopardy, Blackjack, and Room Events (#6331) 2020-02-07 03:16:49 -08:00
Waleed Hassan
f7e024e009
Allow safer and exact type retrieval of Room#game (#6315)
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
2020-02-03 05:09:37 -08:00
Waleed Hassan
02c862da31 Add a GroupSymbol type (#6285) 2020-01-14 14:07:11 -08:00
HoeenHero
86e3c81b8a Tickets: Ticket rooms expire and close after 40 minutes of inactivity 2020-01-01 20:45:17 -05:00
whales
65d904b6e5 Fix room desynch bug (#6239) 2019-12-31 00:27:40 +09:00
whales
dd1dee6fa9 Make subrooms inherit parent room mutes (#6161) 2019-12-11 16:58:39 +09:00
whales
20c708b20a Typescript roomsettings (#6117) 2019-11-30 17:34:14 +13:00
Konrad Borowski
5fcb840e3b Hide stack traces for private code (#5898) 2019-11-29 10:35:18 +13:00
MrEconomical
dea8411ad3 Fix file extensions in comments (#6062)
Update the extensions of a bunch of files that were migrated to TypeScript in comments
2019-11-24 12:57:12 +13:00
Guangcong Luo
f54410a44b Fix crash with /importinputlog 2019-11-17 13:10:43 +13:00
Kirk Scheibelhut
d62a2d9c69 Introduce /modchatnext command (#5934) 2019-11-12 11:37:37 +13:00
Guangcong Luo
411afba392 TypeScript Announcements/Poll chat plugins 2019-11-11 02:13:48 +13:00
Waleed Hassan
a518cf102a Take steps to statically type Config (#5920)
This commit changes the TypeScript global variable of `Config` from
`AnyObject` to `Config & AnyObject`.

It still falls back to `AnyObject` (hence the 'Take steps') because of
the main-specific `Config` properties that are used without being in the
`Config` object itself.

These can be added by someone with access to the PS main server.

Regardlesss, this is an improvement as IntelliSense can display and
autocomplete the known properies.

In addition, the TypeScript compiler will now report bugs
concerning the types of the properties, which I have fixed in this
commit.
2019-10-30 18:45:20 +10:30
Waleed Hassan
28e870c4fb Server: Use readonly where appropriate (#5902) 2019-10-21 16:12:32 +10:30
whales
ea2dea1283 Rooms: Rooms.get can return null (#5860) 2019-10-09 18:52:33 +11:00
Spandan Punwatkar
c8873aeec9 Add Announcements (#5404)
(Announcements can't coexist with polls)
2019-10-04 01:21:38 +10:00
Waleed Hassan
5607c158e4 Use void in promises to appease TSLint (#5827) 2019-10-03 19:08:30 +10:00
Waleed Hassan
da4b887054 Rename Room#id -> Room#roomid, User#userid -> User#id (#5826)
These should make it clearer that userids are IDs but roomids aren't.
2019-10-03 18:57:38 +10:00
whales
fc2c69eb99 Destroy groupchats on all global punishments (#5755) 2019-09-15 06:27:51 +02:00
TheJetOU
f2783c642d Add a RoomID type (#5759) 2019-09-07 14:15:27 -05:00
TheJetOU
2b28c9fd6b Refactor Rooms(), Users() to Rooms.get(), Users.get() (#5725) 2019-08-25 06:33:56 -07:00
TheJetOU
7fe2e5338c TypeScript Tournaments (#5723) 2019-08-24 03:48:13 -07:00
Guangcong Luo
e0a2cf07e1 Correctly define global types for .ts files
Global types are defined differently for `.ts` files than for `.js`
files, leading to some confusion for past refactors.

This commit defines them correctly.

I'm also considering making certain global types only available under
namespaces, but I don't want to do that to `User` or `Room`, so for
now, there are no changes there, besides putting streams in the
`Streams` namespace (so `WriteStream` is now `Streams.WriteStream`).
2019-08-23 09:33:49 -07:00
TheJetOU
5597916644 TypeScript Rooms and Roomlogs (#5699) 2019-08-14 20:44:57 +02:00