andruzzzhka / BeatSaberMultiplayer

MIT License
152 stars 39 forks source link

[Feature Request] Command line interface #16

Closed Assistant closed 6 years ago

Assistant commented 6 years ago

A way to interact with the server and hub through the command line; send commands and receive the output from them.

$ ServerHub --version
4.4.0
$ ServerHub --help
Help
Quit
Clients
$ ServerHub --clients
[0] Foo's Server @ 123.123.123.123:3701
[1] Bar's Server @ 111.111.111.111:3701
$ ServerHub --quit
$ echo ${?}
0
$ MultiplayerServer --version
4.4.0
$ MultiplayerServer --help
help
quit
clients
blacklist [add/remove] [playerID/IP]
whitelist [enable/disable/add/remove] [playerID/IP]
songs [add/remove/list] [songID on BeatSaver]
$ MultiplayerServer --songs add 967
Processing IMAGE -MATERIAL- (Version 0) Tatsh
Successfully added 967 to the song list
$ MultiplayerServer --songs list
65: Reol - LUVORATORRRRRY! feat.nqrse
967: XD_ - IMAGE -MATERIAL- (Version 0) Tatsh
$ MultiplayerServer --songs remove 65
Successfully removed 65 from the song list
$ MultiplayerServer --blacklist add 122.122.122.122
Successfully banned 122.122.122.122
$ MultiplayerServer --blacklist remove 122.122.122.122
Successfully unbanned 122.122.122.122
$ MultiplayerServer --whitelist enable 
Whitelist enabled
$ MultiplayerServer --whitelist add 76561198025299357
Successfully whitelisted 76561198025299357
$ MultiplayerServer --whitelist remove 76561198025299357
Successfully removed 76561198025299357 from whitelist
$ MultiplayerServer --whitelist disable
Whitelist disabled
$ MultiplayerServer --clients
Foo @ 123.123.123.123
Bar @ 111.111.111.111
$ MultiplayerServer --quit
$ echo ${?}
0
megalon commented 6 years ago

Would it be possible to use the --blacklist, --whitelist, and --songs commands while the server is running?

Currently it seems a reboot is needed to apply changes, and they can be overwritten by the running server. It would be great to be able to update these lists without shutting down the lobby.

Ideally, when the server runs it would create a named pipe, then for --blacklist, --whitelist, and --songs, check if the named pipe exists, and if it does, use it to communicate those commands to the running server and get their output back. If it doesn't, do what they're doing right now. For --clients and --quit, check if the named pipe exists, if it does, use it to communicate those commands to the running server and get their output back, but if it doesn't just exit with an error exit status.

--help and --version are fine as is.