Commit Graph

45 Commits

Author SHA1 Message Date
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
Dieter Reinert
d0152f53b4
Roomlogs: Retry on transient DB connection Errors (#10776)
Some checks failed
Node.js CI / build (16.x) (push) Has been cancelled
2024-12-30 20:55:48 -06:00
urkerab
9f29c90db2
Handle 25 hour days correctly (#10635)
Some checks are pending
Node.js CI / build (16.x) (push) Waiting to run
2024-11-02 22:45:34 -05:00
Guangcong Luo
369e25120f Fix Roomlogs logging game rooms
This is a minor refactor to make Roomlogs more reliable about when
it does or doesn't log, by using the same approach for `roomlogTable`
as for `roomlogStream`.

This also simplifies `setupRoomlogStream` to be sync. It's already got
sync FS access, so this shouldn't make it any worse. And Main is using
the database instead, so perf here isn't particularly critical anyway.
2024-07-03 04:42:44 -07:00
Karthik
8819e60f9a
Fix Roomlogs crash (#10352)
* Fix Roomlogs crash

* suggestions

* Fix roomlogStream stuff
2024-06-17 16:05:16 -05:00
Mia
1e89fc563d Roomlogs: Fix bugs in database handling
Cropped up while hunting the memory bug. Maybe related. Dunno yet.
2024-06-12 19:29:06 -05:00
Mia
ee113e24d5 Roomlogs: Fix typo 2024-06-05 09:19:14 -05:00
Mia
1ec6d1476c Roomlogs: Be properly agnostic to config settings 2024-06-02 23:56:38 -05: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
bdc1ed2401 Chatlog: Add support for linecounts on the database 2024-05-18 03:14:57 -05:00
Mia
3855c708e5 Fix crash in roomlogs 2024-05-15 18:00:17 -05:00
Mia
13a5c1ca52
Roomlogs: Support logging to Cockroach instead of flat files (#10298)
* Roomlogs: Support logging to Cockroach instead of flat files

* Correct roomlog timestamp use

* Remove nonnull cast

* Update server/roomlogs.ts

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* remove y/m/d cols

* Fix indices

* consistency

* replace refs

* Fix syntax error

* Separate out dates into an extra table

* Fix other stuff

* Refactor chatlog

* use type param

* prevent crash in child process

* test

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* Update server/roomlogs.ts

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>

* RU: Ban Thundurus-T

* Inheritance: Unban Enamorus

* Add ADV RU challenge format

* SSB: Fix Haste Inky's move

* UU: Ban Pelipper

* use miscrosecond precision for timestamps

* cleanup

---------

Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
2024-05-15 16:12:07 -05: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
Mia
b4798c6eae Roomlogs: Ensure uhtmlchange messages are stored in the roomlog
Without oan original /uhtmlchange in the log to work off of, the changes never get placed in the log (so they don't get seen on join), and they never get placed in the log anywhere, so that log iteration is essentially pointless otherwise. This commit places it if it doesn't exist, then future changes will be able to adjust the message as they get made.
2023-12-20 02:15:01 -06:00
Karthik
2dc0f5aefa
Fix private logs not getting sent when connecting to GameRoom (#9269) 2022-12-31 19:49:23 -06:00
Mia
ab62e1af43
Add a plugin to use Perspective for monitoring battles (#8541) 2021-12-03 07:52:26 -06:00
Mia
866722f70d Roomlogs: Don't count certain protocol messages for Room#nthMessageHandlers
Previously, join/leave/userstats/etc would all count against the nthMessageHandlers (which is relevant for repeats), and this is most definitely incorrect behavior.
2021-09-15 12:56:39 -05:00
Mia
7811795344
Handle new TypeScript version (#8449)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2021-08-30 20:11:44 -07:00
Annika
633e061067 Modlog: Remove text logging code 2021-08-09 14:06:14 -07:00
Annika
bcbe100c41
Modlog: Use SQLite for searches (#8004) 2021-07-23 13:47:49 -07:00
Mia
76c10841ea
Lib: Add an index file for all exports (#7972) 2021-01-31 18:00:19 -08:00
Annika
88da40d046
Roomlog: Support getting total linecount (#7885) 2021-01-07 13:10:23 -08:00
Annika
7f2dec0797
Modlog: Avoid optional properties in ModlogEntry (#7613)
* Modlog: Avoid optional properties in ModlogEntry

* Use a type

* Make IP nullable

* Add NOT NULL constrains

* Fix typo
2020-11-01 14:07:01 -08:00
Guangcong Luo
9d87616176
Add more style linting rules (#7537)
* Lint arrow-body-style

* Lint prefer-object-spread

Object spread is faster _and_ more readable.

This also fixes a few unnecessary object clones.

* Enable no-parameter-properties

This isn't currently used, but this makes clear that it shouldn't be.

* Refactor more Promises to async/await

* Remove unnecessary code from getDataMoveHTML etc

* Lint prefer-string-starts-ends-with

* Stop using no-undef

According to the typescript-eslint FAQ, this is redundant with
TypeScript, and they're not wrong. This will save us from needing to
specify globals in two different places which will be nice.
2020-10-19 02:42:28 -07:00
Annika
f1b4e3d43a
Modlog: Refactor to use ModlogEntry objects (#7403) 2020-09-28 11:06:30 -07:00
Annika
f34ffa9e74
Refactor Modlog into one file (#7127) 2020-08-06 00:39:37 -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
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
TheMezStrikes
815d5c5a0a
/changeuhtml should send /uhtmlchange not /uhtml (#6912) 2020-06-24 05:32:25 -07:00
Guangcong Luo
1e5b5ab465 Update Streams API with pushEnd/writeEnd
Previously, ending a read stream was `stream.push(null)`, and ending a
write stream was `stream.end()`. This was often confusing, and so now,
these are consistently `stream.pushEnd()` and `stream.writeEnd()`.

This refactor already found a bug in which `stream.end()` was used
where `stream.push(null)` should have been.

Also in this refactor: By default, `pushError` ends the stream. You can
pass `true` as the second parameter if the error is recoverable (the
stream shouldn't end).
2020-06-10 16:07:24 -07:00
Mia
6839a1f4db
Add a library for utility functions (#6817) 2020-06-09 22:06:43 -07: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
Volco
0dee619326
Fix the rename command to log the new room & require a target (#6710) 2020-05-18 09:21:14 -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
fart
80cfacc2b0
Support /hidetext [line count] (#6471) 2020-03-22 15:53:40 -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
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
Waleed Hassan
34e215c7a6
Support renaming rooms (#6295) 2020-02-21 00:47:07 -08:00
Waleed Hassan
28e870c4fb Server: Use readonly where appropriate (#5902) 2019-10-21 16:12:32 +10:30
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
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