add /countdown and !options
This commit is contained in:
parent
252f9600fe
commit
12273c396b
|
@ -620,9 +620,33 @@ class CommandProcessor(metaclass=CommandMeta):
|
|||
self.output(str(exception))
|
||||
|
||||
|
||||
class CommonCommandProcessor(CommandProcessor):
|
||||
ctx: Context
|
||||
|
||||
simple_options = {"hint_cost": int,
|
||||
"location_check_points": int,
|
||||
"password": str,
|
||||
"forfeit_mode": str,
|
||||
"item_cheat": bool,
|
||||
"auto_save_interval": int}
|
||||
|
||||
def _cmd_countdown(self, seconds: str = "10") -> bool:
|
||||
"""Start a countdown in seconds"""
|
||||
try:
|
||||
timer = int(seconds, 10)
|
||||
except ValueError:
|
||||
timer = 10
|
||||
asyncio.create_task(countdown(self.ctx, timer))
|
||||
return True
|
||||
|
||||
def _cmd_options(self):
|
||||
"""List all current options. Warning: lists password."""
|
||||
self.output("Current options:")
|
||||
for option in self.simple_options:
|
||||
self.output(f"Option {option} is set to {getattr(self.ctx, option)}")
|
||||
|
||||
class ClientMessageProcessor(CommandProcessor):
|
||||
marker = "!"
|
||||
ctx: Context
|
||||
|
||||
def __init__(self, ctx: Context, client: Client):
|
||||
self.ctx = ctx
|
||||
|
@ -695,14 +719,6 @@ class ClientMessageProcessor(CommandProcessor):
|
|||
"Your client is too old to send game beaten information. Please update, load you savegame and reconnect.")
|
||||
return False
|
||||
|
||||
def _cmd_countdown(self, seconds: str = "10") -> bool:
|
||||
"""Start a countdown in seconds"""
|
||||
try:
|
||||
timer = int(seconds, 10)
|
||||
except ValueError:
|
||||
timer = 10
|
||||
asyncio.create_task(countdown(self.ctx, timer))
|
||||
return True
|
||||
|
||||
def _cmd_missing(self) -> bool:
|
||||
"""List all missing location checks from the server's perspective"""
|
||||
|
@ -959,15 +975,7 @@ async def process_client_cmd(ctx: Context, client: Client, cmd, args):
|
|||
client.messageprocessor(args)
|
||||
|
||||
|
||||
class ServerCommandProcessor(CommandProcessor):
|
||||
ctx: Context
|
||||
simple_options = {"hint_cost": int,
|
||||
"location_check_points": int,
|
||||
"password": str,
|
||||
"forfeit_mode": str,
|
||||
"item_cheat": bool,
|
||||
"auto_save_interval": int}
|
||||
|
||||
class ServerCommandProcessor(CommonCommandProcessor):
|
||||
def __init__(self, ctx: Context):
|
||||
self.ctx = ctx
|
||||
super(ServerCommandProcessor, self).__init__()
|
||||
|
@ -1115,12 +1123,6 @@ class ServerCommandProcessor(CommandProcessor):
|
|||
f"{', '.join(known)}")
|
||||
return False
|
||||
|
||||
def _cmd_options(self):
|
||||
"""List all current options. Warning: lists password."""
|
||||
self.output("Current options:")
|
||||
for option in self.simple_options:
|
||||
self.output(f"Option {option} is set to {getattr(self.ctx, option)}")
|
||||
|
||||
async def console(ctx: Context):
|
||||
session = prompt_toolkit.PromptSession()
|
||||
while ctx.running:
|
||||
|
|
Loading…
Reference in New Issue