Commit Graph

142 Commits

Author SHA1 Message Date
Mia
010ffe1a41
Admin: Fix /disablecommand message (#8019) 2021-02-13 23:19:59 -05:00
Guangcong Luo
148439dc27 Refactor /editbattle
This moves the `player()` and `pokemon()` functions to be defined
inside `eval`, allowing them to be used by `>>>` and `/evalbattle`.

This should hopefully make the commands more readable as well.
2021-02-02 13:52:16 -08:00
Guangcong Luo
796be8da60 Implement /ebat reseed
Fixes #7963
2021-02-02 13:45:34 -08:00
Mia
76c10841ea
Lib: Add an index file for all exports (#7972) 2021-01-31 18:00:19 -08:00
Mia
3479c1f5e0 Admin: Allow dev staff to use /processes 2021-01-28 15:00:05 -06:00
TheMezStrikes
593e589bb4
Default sendhtmlpage to all connections (#7939) 2021-01-23 04:36:05 -08:00
urkerab
5cb927d439
Remove variables made redundant by PR #7663 (#7873)
The `hotpatchVersions` variable was only used by `requiresForce`.

The `patch` variable no longer provides any benefit over `target`,
so I removed it too.
2021-01-03 21:17:30 +04:00
Annika
ca9ce2f225
Refactor /updateserver (#7836)
Now, `/updateserver` updates both public and private code.

To update only one, use `/updateserver private` or `/updateserver public`.
2020-12-26 07:17:43 -08:00
Mia
9712f6ecf1
Modlog: Remove Rooms global in PM (#7799) 2020-12-13 12:52:52 -08:00
Mia
b7001afdba
Chat: Add a method for iterating commands (#7722) 2020-12-03 19:37:59 -08:00
Annika
70016c9e49 Admin: Fix /updateserver private 2020-11-25 13:48:31 -08:00
Guangcong Luo
847681d9e9 Improve /updateserver, /rebuild, /hotpatch UX
My carefully-designed `/updateserver` UX has been ruined by the
addition of the rebuild step.

The new `/updateserver`, `/rebuild`, and `/hotpatch` commands are now
once again as carefully-designed as before, and should represent a
much improved server administration experience.
2020-11-17 10:45:40 +00:00
Mia
7307364451
Remove /forcehotpatch (#7663)
Hotpatches now always rebuild before patching.
2020-11-14 21:01:35 -08:00
Mia
60bda2795f
CommandContext: Move parseCommand into Chat (#7661) 2020-11-11 19:59:38 -08:00
Guangcong Luo
b9a0d3f494 Fix return signature of context.parse 2020-11-11 03:25:06 +00:00
Guangcong Luo
6d5dcfe948 Fix !pline broadcast limit 2020-11-10 14:55:05 -05:00
Mia
9c2c4efe07
Admin: Warn the user of disabled commands on hotpatch/lockdown (#7660) 2020-11-08 17:25:41 -08:00
Mia
850d4a4b9b
Add a command to disable commands (#7655) 2020-11-08 14:39:20 -08:00
Guangcong Luo
1e39e19f00 Refactor chat to use Utils.splitFirst 2020-11-08 18:31:38 +00:00
Konrad Borowski
32f299584f
Remove hotpatch notifications from Upper Staff (#7646) 2020-11-05 22:56:39 +04:00
Mia
c0baf2135d
Make /addline broadcastable and rename to /pline (#7621) 2020-11-02 08:47:55 -08:00
Annika
3b709ac34f
Fix permission check for /addline 2020-11-01 18:43:02 -08:00
Annika
2f130e8762
Modlog: Support logging to a SQLite database (#7513)
* Modlog: Support logging to a SQLite database

Co-authored-by: Christopher Monsanto <chris@monsan.to>
2020-10-30 19:27:25 -04:00
Konrad Borowski
6fe378b246
Indicate pending promises in /eval (#7592) 2020-10-27 14:33:04 -07: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
Guangcong Luo
1c0c77ff6b
Update to TypeScript 4.0 (#7504) 2020-10-10 14:43:32 -07:00
Guangcong Luo
65db20711c Fix bug in /updateserver 2020-10-01 11:58:14 -07:00
Guangcong Luo
523c1a335d
Introduce Chat.oldPlugins (#7434)
This provides a new way to persist chat plugin data across hotpatches:
`Chat.oldPlugins`.

In a plugin, you can now do:

```
export const cache = Chat.oldPlugins.pluginname?.cache || {};
```

to create a cache that will persist across hotpatches.
2020-09-30 19:45:54 -07:00
Mia
6255927779
Add a command to highlight users in bot html pages (#7304) 2020-09-18 07:38:44 -07:00
Annika
2c6bd4aa5d
Chat plugins: Export plugin state (#7351) 2020-09-10 19:17:00 -07:00
Mia
44fc0123ad
Chat: Refactor CommandContext and PageContext to use ErrorMessage more (#7234) 2020-09-06 00:15:16 -07:00
Guangcong Luo
1217457b06 Fix /updateserver
This adds a bunch of minor fixes to /updateserver. The big one is that
we no longer stash untracked files, which should fix the problem where
it sometimes takes forever to update.

However, it seems like conflicting untracked files sometimes corrupts
the Git system?

    zarel@cytosine ~/W/psserver (master)> git rebase FETCH_HEAD
    Created autostash: abc06bdca
    First, rewinding head to replay your work on top of it...
    error: The following untracked working tree files would be overwritten by checkout:
        server/chat-plugins/help.ts
    Please move or remove them before you switch branches.
    Aborting
    fatal: Could not detach HEAD

    zarel@cytosine ~/W/psserver (master|AM/REBASE)> git rebase --abort
    error: could not read '.git/rebase-apply/head-name': No such file or directory

I couldn't reliably reproduce this, unfortunately, but I've switched to
`git rebase --no-autostash FETCH_HEAD` to be safe. File conflicts
are really rare in general, so I don't think that needs to be a
blocker.
2020-09-02 20:14:07 -07:00
Guangcong Luo
e14485656f Implement a basic /hiderank
This doesn't really have any nice-to-have automatic restoration
features but it should be all the important parts.

`user.group` no longer exists, and has been replaced with
`user.tempGroup`, which now applies both to temporary promotions of
unregistered users, as well as temporary hidden ranks of auth.
2020-08-22 07:20:26 -07:00
Annika
2b8268aabe
Make /updateserver private exit if no updates (#7242) 2020-08-21 15:38:50 -07:00
Annika
a3c579c3c4
Fix crash in /updateserver private (#7236) 2020-08-20 21:29:57 -07:00
Annika
4cbf905ec8
Modlog: Fix exact searches and improve hotpatching (#7211) 2020-08-15 14:10:46 -07:00
Annika
2b809f99e4
Support updating private code in /updateserver (#7183) 2020-08-09 20:24:32 -07:00
Annika
f563252418
Modlog: Fix bugs and support hotpatching (#7163) 2020-08-06 22:05:13 -04:00
Annika
cd85cd7a9d
Hosts & IPTools: Refactor to remove hardcoded ranges (#7078) 2020-07-29 23:04:50 -07:00
Annika
c16750741a
Fix hotpatching IPTools and multiline patterns for Hosts (#7069) 2020-07-27 01:51:28 -07:00
Annika
e0c18e8e0b
Refactor IPTools and add a host management chat plugin (#7061) 2020-07-26 12:41:27 -07:00
Peach
f2bfe2538c
Make sendhtmlpage perms more strict, refactor perm checks (#7044) 2020-07-25 23:31:28 -07:00
Guangcong Luo
b5591fdccf Fix crash in /sendhtmlpage 2020-07-25 19:09:41 -04:00
HoeenHero
86043a504a
Add a command to enable hotpatching (#7056) 2020-07-24 17:42:06 -07:00
Guangcong Luo
2f805c93a2
Remove "Battle" prefix from data exports (#7039)
`BattlePokedex` is now `Pokedex`, `BattleItems` is now `Items`, etc.

I also renamed `Movedex` to `Moves` and `Statuses` to `Conditions`.

`TypeChart` isn't `Types` yet, because unlike the others, it's not
indexed by ID. That should probably be fixed one day.
2020-07-24 12:42:26 -07:00
Mia
63819e8d1c
Make /sendhtmlpage send to the last active connection (#7051) 2020-07-24 10:59:53 -07:00
Mia
126a740b2a
Fix chat-commands.js mention in /hotpatch's help (#7047) 2020-07-24 10:46:54 -07:00
Guangcong Luo
b53faf1768 Fix /sendhtmlpage 2020-07-23 12:54:01 -07:00
Mia
964f4f8d06
Add a command for bots to send HTML pages (#6934) 2020-07-23 12:05:45 -07:00
Peach
e9611b7ce2
Remove unnecessary references to the global room (#7033) 2020-07-22 08:52:46 -07:00
Guangcong Luo
faab60a618 Unify command logging code
Global punishments like /lock will notify Staff, and admin commands
like /updateserver will log to Staff, but this has been done ad-hoc
in the past.

To handle these cases, this commit introduces new chat-context
functions:

- `this.addGlobalModAction`,
- `this.privateGlobalModAction`
- `this.stafflog`

Other updates:

- the issue where Staff notifications didn't show up until someone talks
  has been fixed
- `privateModAction`s in Staff will now be visible in the scrollback
  log
- a bunch of commands that should notify Staff but didn't now do
- some typos in modlogs have been fixed
2020-07-07 18:51:29 -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
Mia
4997a47314
Commands: Allow the room parameter to be null (#6948)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2020-07-05 14:25:09 -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
Guangcong Luo
6af875af8b Improve RoomPermission/GlobalPermission checks
Global permissions can no longer be used as room permissions. Instead,
the two are entirely separate lists, with only a few permissions in
both lists.
2020-06-21 03:53:06 -07:00
Mia
d2b255b934
/eval: Log in dev room and broadcast (#6871)
Co-authored-by: Guangcong Luo <guangcongluo@gmail.com>
2020-06-18 23:28:15 -07:00
Guangcong Luo
cc22bae74f Fix crash in /editbattle 2020-06-17 18:12:34 -07:00
Guangcong Luo
8748427dce Fix TS error in PM
It's surprising to me that this happened after e0f97dcf6b, which
doesn't touch this line.
2020-06-13 10:54:22 -07:00
Guangcong Luo
e0f97dcf6b Replace Chat.uncache* with Utils.clearRequireCache
This replaces the old approach with a new "clear everything except a
whitelist" approach, which should overall involve much less code and
lead to fewer bugs of the "the path changed for a module and I forgot
to update the uncache paths" variety.

I considered a lot of other approaches, but they seem to have more
flaws without any advantages in exchange for them. (We moved away
from `uncacheTree` because it only tracks the first require: there's
no way to get a full list of dependents for a module, only its first
dependent.)
2020-06-12 22:02:32 -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
DeltaCoderr
70ab234f1d
Add Room Owner rank in Help Commands (#6821) 2020-06-09 07:48:46 -07:00
Annika
f4863a9444
Update references to Global Administrators post-flattening (#6815)
Co-authored-by: Charlie Kobayashi <sparkychildcharlie@gmail.com>
2020-06-08 09:41:03 -07:00
Guangcong Luo
08420c7feb Reassign hotpatch permissions
Currently, 'hotpatch' and 'lockdown' are admin permissions, and
'console' is a console admin permission. In preparation for the
admin/leader unification, I'm removing the hotpatch permission:

- /memoryusage, /loadbanlist, /adddatacenters, /refreshpage,
  /loadbanlist have been moved from 'hotpatch' to 'lockdown'. This
	doesn't change anything, I'm just unifying the permission name.

- /updateserver has been moved from 'hotpatch' to 'console'.
  /updateserver in combination with either hotpatch or lockdown can be
	used for arbitrary code execution, and is approximately as dangerous
	as any other console command.

- /hotpatch, /savelearnsets have been moved from 'hotpatch' to
  'console'. They're reasonably harmless, but they don't do anything
	without console access, so a non-console admin using them is nearly
	definitely some sort of mistake.

`user.hasConsoleAccess` now also has a CommandContext function
`this.canUseConsole` to handle its error message.
2020-06-06 07:44:31 -07:00
Kris Johnson
a7948c7c9c
Typescript config/ (#6760) 2020-05-29 19:34:43 -07:00
Alexander B
b546337b18
Fix and enhance /editbattle (#6758) 2020-05-29 05:59:13 -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
Waleed Hassan
a29c62e71c
Fix hotpatching chat (#6643) 2020-05-02 12:32:16 -07:00
Guangcong Luo
1dada44a2a Support server/chat-plugins/private as symlink 2020-04-25 15:51:11 -04:00
Guangcong Luo
6a685df8c7 Fix crashes when hotpatching chat
(Also fix a mistaken thing-of-the-day refactor: I blame giving two
different variables the same name.)
2020-04-25 11:11:24 -04:00
Guangcong Luo
776ccf9796
Refactor Sockets to ProcessManager+TypeScript (#6584) 2020-04-17 04:05:45 -07:00
Guangcong Luo
806ce433da Fix zombie processes after hotpatching chat 2020-04-08 12:02:42 -07:00
Kris Johnson
994fc60aed
Rename Template to Species (#6478) 2020-03-25 23:29:27 -07:00
whales
9ad7b53bdb Don't fail silently in uhtml commands 2020-03-23 20:33:42 +10:30
Peach
2bf71cd42d
Attribute addhtml and code commands (#6444) 2020-03-20 20:58:56 -07:00
Kris Johnson
3e26318758
Refactor learnsets.js (#6466) 2020-03-18 00:59:29 -07:00
Guangcong Luo
60cbd7d0d7 Implement /chatlog command 2020-03-14 00:04:16 -04:00
Peach
d9f2f8e745
Block hotpatches while updating/rebuilding (#6445) 2020-03-12 00:45:14 -04:00
Guangcong Luo
efa98a08b9 Improve linkRegex
We're now using regexfree for linkRegex as well as the indentation
rule.

https://zarel.github.io/regexfree/
2020-03-08 20:16:53 -07:00
Guangcong Luo
4616bf1090 Fix bug in /addhtmlbox 2020-03-07 16:31:52 -08: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
Guangcong Luo
1051b9e4ba Sent a useful tip if someone sends /nick 2020-02-11 14:43:05 -08:00
Waleed Hassan
02c862da31 Add a GroupSymbol type (#6285) 2020-01-14 14:07:11 -08:00
whales
8a2969eb18 Fix rebuilding on windows (#6191) 2019-12-17 05:29:24 +09:00
whales
f7d5cefc7d Refactor tournament plugin loading (#6118) 2019-11-30 17:53:01 +13:00
whales
544d331a65 Report normalized target for hotpatches (#6057) 2019-11-24 10:22:48 +13:00
Guangcong Luo
a01daed212 Fix /rebuild crash 2019-11-16 10:10:33 +13:00
peach
52a10f8291 Fix paths when hotpatching properly 2019-11-15 23:35:56 +10:30
peach
42aec533a6 Fix paths when hotpatching 2019-11-15 23:34:19 +10:30
Guangcong Luo
23f9bfa1b7
Split up server/chat-commands/ (#5943)
`server/chat-commands.js` is now a directory. It's been split into
`core`, `moderation`, and `admin`. `info` and `roomsettings` from
`chat-plugins` have also moved to `chat-commands`.

Some cleanup:

- Bot commands for inserting HTML into rooms like `/adduhtml` have been
  moved from `info` into `admin`.

- `/a` has been renamed `/addline`, for clarity (and also moved from
  `info` into `admin`).

- Room management commands like `/createroom` and `/roomintro` were
  moved to `room-settings`

- `chat-commands/admin` has been TypeScripted
2019-11-15 11:12:54 +13:00