implement option changing

This commit is contained in:
Fabian Dill 2020-06-27 14:16:51 +02:00
parent e3c18be288
commit 12120ac995
2 changed files with 22 additions and 11 deletions

View File

@ -959,11 +959,6 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
client.messageprocessor(args)
def set_password(ctx: Context, password):
ctx.password = password
logging.warning('Password set to ' + password if password else 'Password disabled')
class ServerCommandProcessor(CommandProcessor):
ctx: Context
@ -1034,12 +1029,6 @@ class ServerCommandProcessor(CommandProcessor):
self.output(response)
return False
@mark_raw
def _cmd_password(self, new_password: str = "") -> bool:
"""Set the server password. Leave the password text empty to remove the password"""
set_password(self.ctx, new_password if new_password else None)
return True
@mark_raw
def _cmd_forfeit(self, player_name: str) -> bool:
"""Send out the remaining items from a player's game to their intended recipients"""
@ -1100,6 +1089,25 @@ class ServerCommandProcessor(CommandProcessor):
self.output(response)
return False
def _cmd_option(self, option_name: str, option: str):
"""Set options for the server. Warning: expires on restart"""
simple_options = {"hint_cost": int,
"location_check_points": int,
"password": str,
"forfeit_mode": str,
"item_cheat": bool,
"auto_save_interval": int}
attrtype = simple_options.get(option_name, None)
if attrtype:
setattr(self, option_name, attrtype(option))
self.output(f"Set option {option_name} to {getattr(self, option_name)}")
return True
else:
known = (f"{option}:{otype}" for option, otype in simple_options.items())
self.output(f"Unrecognized Option {option_name}, known: "
f"{', '.join(known)}")
return False
async def console(ctx: Context):
session = prompt_toolkit.PromptSession()

View File

@ -17,10 +17,13 @@ from Utils import get_public_ipv4, get_public_ipv6
class CustomClientMessageProcessor(ClientMessageProcessor):
def _cmd_video(self, platform, user):
"""Set a link for your name in the WebHost tracker pointing to a video stream"""
if platform.lower().startswith("t"): # twitch
self.ctx.video[self.client.team, self.client.slot] = "Twitch", user
self.ctx.save()
self.output(f"Registered Twitch Stream https://www.twitch.tv/{user}")
return True
return False
# inject