Commit Graph

153 Commits

Author SHA1 Message Date
Guangcong Luo
73a04cdcba TypeScript: Enable noImplicitOverride
Some checks are pending
Publish to npm / test (push) Waiting to run
Publish to npm / get-version (push) Waiting to run
Publish to npm / npm-publish (push) Blocked by required conditions
Node.js CI / build (18.x) (push) Waiting to run
2025-02-26 14:38:32 -08:00
Guangcong Luo
e25bec3620 Remove some implicit conversions
boolean -> number and number -> string should be explicit. Probably
string -> number should be, too, but I'm not ready to turn on the lint
option yet.

This was supposed to be part of the big ESLint refactor but I forgot
to push it. <_<
2025-02-25 22:55:01 -08:00
Guangcong Luo
78439b4a02
Update to ESLint 9 (#10926)
ESLint has a whole new config format, so I figure it's a good time to
make the config system saner.

- First, we no longer have separate eslint-no-types configs. Lint
  performance shouldn't be enough of a problem to justify the
  relevant maintenance complexity.

- Second, our base config should work out-of-the-box now. `npx eslint`
  will work as expected, without any CLI flags. You should still use
  `npm run lint` which adds the `--cached` flag for performance.

- Third, whatever updates I did fixed style linting, which apparently
  has been bugged for quite some time, considering all the obvious
  mixed-tabs-and-spaces issues I found in the upgrade.

Also here are some changes to our style rules. In particular:

- Curly brackets (for objects etc) now have spaces inside them. Sorry
  for the huge change. ESLint doesn't support our old style, and most
  projects use Prettier style, so we might as well match them in this way.
  See https://github.com/eslint-stylistic/eslint-stylistic/issues/415

- String + number concatenation is no longer allowed. We now
  consistently use template strings for this.
2025-02-25 20:03:46 -08:00
Kris Johnson
df5c46bb53 Remove the Section Leader rank 2024-10-01 21:27:49 -06:00
Mia
cb09767c6f Roomlogs: Support logging to flat files while database config exists
Smogtours....
2024-06-02 23:53:58 -05:00
Mia
b048de52e2 Make the logs/ directory prefix configurable 2024-05-19 12:30:22 -05:00
Mia
3f68a259d0 Helptickets: Account for changes to replay schema 2024-01-29 18:34:22 -06:00
Guangcong Luo
cec317671e Cleanup RoomGame implementations again
This reinstates the recently-reverted RoomGame refactor/cleanup, but
with the bugs (forfeiting BestOfGame, and autojoin) fixed.

This reinstates:

- 6bccd4f622 Fix crash in bestof when expiring battles
- 2a48cbd064 Cleanup more RoomGame implementations

The latter fixes these, in addition to refactoring:
- Fix a race condition when destroying bestof games
- Fix `/tour settings scouting off` error message
2024-01-16 15:54:38 +09:00
Leonard Craft III
5252aa7d7e Revert "Cleanup more battle implementations"
This reverts commit 2a48cbd064.
2024-01-15 13:38:01 -06:00
Guangcong Luo
2a48cbd064 Cleanup more battle implementations
This is mostly just refactoring, but the refactor caught a few bugs:

- Fix a race condition when destroying bestof games
- Fix `/tour settings scouting off` error message
2024-01-15 23:58:46 +09:00
Guangcong Luo
9ca7bcd4f0 Fix Smogtours crash
`users.joinRoom` was not written to handle `Chat.Interruption`.

This is a stopgap fix. A proper fix would probably involve relocating
`onBeforeRoomJoin`.
2024-01-08 21:00:50 -08:00
Guangcong Luo
eb0ef53e0e
Remove unlinkUser (#10101)
This refactor removes `player.unlinkUser()` which was used for several
unrelated use cases.

These have been split apart into:

- at the end of a game, `game.setEnded()` now clears `user.games`,
  while leaving `player.id` untouched
- when trying to change the user associated with the player, we now
  consistently use the higher-level `game.updatePlayer()`

There's a good chance this fixes the lagspikes currently affecting PS.
2024-01-08 20:49:34 -08:00
Guangcong Luo
f0e9bf19a5 Refactor connection iteration 2024-01-08 16:06:06 -08:00
Guangcong Luo
3c51f8aa1f
Refactor BestOfGame (#10026)
This replaces some pretty jank code with much cleaner code.
Anything that would be more cleanly implemented by iterating the
players array is now done by iterating the players array.

Some instances of p1/p2 are lying around but we should slowly deprecate
them.
2024-01-07 01:45:23 -08:00
Annika
cf483fd8a1
Room permissions: Allow control over broadcasting
This does 2 things:
* allows command permissions to be set to the default user group, granting the permission to all users
* lets rooms set permissions for broadcasting on a per-command basis by using `!` as the prefix for a command with no other permissions requirements

This is intended to let Tech & Code room let regular users broadcast `!code`, but potentially has other applications.

Closes #9534
2023-06-05 16:41:34 -07:00
Mia
6c715468f0 Users: Add a handler for user renaming
Loginfilter doesn't fit the usecase for this since it doesn't track renames - oldUser doesn't work since that's only if the name was already used, and consulting previousIDs doesn't work since we only add userids to that once. This is the simplest way to add support for this functionality.
2022-11-22 12:31:30 -06:00
Mia
a98e5f70be Users: Allow admins to send 25 messages at once
Requested by Kennedy.
2022-11-14 10:20:09 -06:00
Quinton Lee
10f09c1339
Users: Lower chat throttle for public bots (#8944) 2022-10-23 20:55:14 -07:00
Andrew Werner
9230b5af8c GlobalAuth: Remove extraneous save call
GlobalAuth#delete already calls GlobalAuth#save, so this save call is unnessecary.
Testing did not reveal and problems with removing this extra call.
This is an attempt to fix a rare issue where GlobalAuth changes do not save.
2022-10-18 20:00:13 -04:00
Mia
ec4cb6a6fa
Support persisting battles in a Postgres database (#8442) 2022-07-22 18:07:10 -07:00
Mia
cfeb1303bb
Chat: Properly typecheck Chat.runHandlers arguments (#8612) 2022-01-23 17:55:19 -08:00
Guangcong Luo
8642abcd12
Avatar manager (#8563) 2021-12-14 10:21:02 -08:00
Guangcong Luo
be0cee5a33
Refactor getIdentity not to take roomids (#8528) 2021-11-12 22:05:59 -08:00
Annika
9c08822cff Revert Multi Battle changes 2021-10-24 17:13:10 -04:00
Mia
88ef7fdf1f
Support marksharing ranges (#8498) 2021-10-24 12:44:46 -07:00
Mia
0f5c9c133b
Support searching multi formats (#8172) 2021-10-24 12:04:57 -07:00
Mia
83e77f9c93 Friends: Write last seen data on disconnect 2021-07-28 14:08:40 -05:00
Mia
f3856757a1
Users: default the display of friend login notifs to off 2021-07-23 22:29:06 -05:00
Mia
bdeb9c538a Support /blockchallenges friends 2021-07-22 21:18:52 -05:00
Mia
ed34cc49b1 Friends: Add a page to spectate the battles of friends 2021-07-19 02:57:08 -05:00
Mia
20c795f8f4
Friends: Move caching to User#friends (#8404) 2021-07-16 20:33:07 -07:00
Mia
e5fbd64427
Support adding friends (#7333) 2021-07-16 12:56:34 -07:00
Annika
6ed55b6d1f
IPTools: Add sanity checks (#8331) 2021-07-09 19:59:45 -07:00
Distrib
e9a5bc9332
/blockchallenges: Support allowing challenges from certain groups (#8362) 2021-06-26 17:28:03 -07:00
Mia
94b5e5e898 Fix trusting users 2021-06-01 10:17:10 -05:00
Mia
8fa02b73a4 Users: Automatically trust users in Staff room 2021-06-01 08:33:51 -05:00
Mia
09e298f15b
Punishments: Support giving multiple punishments to one user (#8265) 2021-05-31 11:06:01 -07:00
Guangcong Luo
74211859c9 Update to TypeScript 4.3
Changes relevant to our codebase:

- TypeScript now knows that `typeof id === 'string'`! A bunch of casts
  on `User | ID` or `Room | RoomID` are no longer necessary!!!

- `override` will protect against certain typoes, and we'll adopt it
  (and `--noImplicitOverride`) as soon as sucrase comes in

- `declare` is now required for properties we want to narrow the type
  of without directly overwriting - a good thing to use going forward,
	but very annoying to fix all our old code for
2021-05-26 14:16:54 -07:00
Mia
77023b02b6
Stop defaulting messages to Lobby in protocol (#8304) 2021-05-17 07:17:48 -07:00
Guangcong Luo
c695620e58
Refactor to new challenge system (#8303)
See PR for full details:

https://github.com/smogon/pokemon-showdown/pull/8303
2021-05-17 07:15:01 -07:00
Mia
d99a21ad41 Users: Close open pages on connection disconnect 2021-05-14 09:33:01 -05:00
Mia
7154920b2c
Support forcing modchat on ladder tour battles (#8214) 2021-04-23 22:40:09 -07:00
Kris Johnson
a1bdafbfe8
Add room sections (#8205) 2021-04-23 22:39:56 -07:00
Guangcong Luo
44ef998ecc Implement free-for-all
This involves a huge refactor for how battles are constructed, but
it's totally worth it.

Currently, tournaments, challenges, and laddering are unsupported; only
unrated searches work. But it does work, and it's beautiful.
2021-04-01 04:44:16 -07:00
Annika
c2e97aaaed
Use optional chaining in more places (#8063) 2021-02-22 11:42:05 -08:00
Mia
76c10841ea
Lib: Add an index file for all exports (#7972) 2021-01-31 18:00:19 -08:00
Guangcong Luo
da30a71706 Revert "Remove User#inRooms and User#games (#7815)"
This reverts commit 5c9c84c415.

This also reverts commit 1fc92ef977.
2021-01-30 15:55:55 -05:00
Mia
6b4507aba9
Chat: Track slow async commands (#7961) 2021-01-29 08:59:20 -08:00
Guangcong Luo
1fc92ef977 Fix bugs in inRooms/games refactor 2021-01-28 20:35:30 -05:00
Mia
c1cd4630b1
Users: Automatically expire inactive connections (#7957) 2021-01-28 11:43:02 -08:00