Add function to process commands to MultiServer.py
This commit is contained in:
@@ -46,6 +46,9 @@ class Context:
|
|||||||
self.lookup_name_to_id = {}
|
self.lookup_name_to_id = {}
|
||||||
self.lookup_id_to_name = {}
|
self.lookup_id_to_name = {}
|
||||||
|
|
||||||
|
async def process_command(self, input):
|
||||||
|
await process_command(ctx, input)
|
||||||
|
|
||||||
async def send_msgs(websocket, msgs):
|
async def send_msgs(websocket, msgs):
|
||||||
if not websocket or not websocket.open or websocket.closed:
|
if not websocket or not websocket.open or websocket.closed:
|
||||||
return
|
return
|
||||||
@@ -296,14 +299,16 @@ def set_password(ctx : Context, password):
|
|||||||
async def console(ctx : Context):
|
async def console(ctx : Context):
|
||||||
while True:
|
while True:
|
||||||
input = await aioconsole.ainput()
|
input = await aioconsole.ainput()
|
||||||
|
await process_command(ctx, input)
|
||||||
|
|
||||||
|
async def process_command(ctx : Context, input):
|
||||||
command = shlex.split(input)
|
command = shlex.split(input)
|
||||||
if not command:
|
if not command:
|
||||||
continue
|
return
|
||||||
|
|
||||||
if command[0] == '/exit':
|
if command[0] == '/exit':
|
||||||
ctx.server.ws_server.close()
|
ctx.server.ws_server.close()
|
||||||
break
|
return
|
||||||
|
|
||||||
if command[0] == '/players':
|
if command[0] == '/players':
|
||||||
logging.info(get_connected_players_string(ctx))
|
logging.info(get_connected_players_string(ctx))
|
||||||
|
|||||||
Reference in New Issue
Block a user