Add function to process commands to MultiServer.py

This commit is contained in:
2023-03-02 18:35:34 -06:00
parent e53a9a3e2a
commit c191a224c0

View File

@@ -46,6 +46,9 @@ class Context:
self.lookup_name_to_id = {}
self.lookup_id_to_name = {}
async def process_command(self, input):
await process_command(ctx, input)
async def send_msgs(websocket, msgs):
if not websocket or not websocket.open or websocket.closed:
return
@@ -296,14 +299,16 @@ def set_password(ctx : Context, password):
async def console(ctx : Context):
while True:
input = await aioconsole.ainput()
await process_command(ctx, input)
async def process_command(ctx : Context, input):
command = shlex.split(input)
if not command:
continue
return
if command[0] == '/exit':
ctx.server.ws_server.close()
break
return
if command[0] == '/players':
logging.info(get_connected_players_string(ctx))