mud/src/mudlib/commands/quit.py

24 lines
680 B
Python

"""Quit command for disconnecting from the server."""
from mudlib.commands import CommandDefinition, register
from mudlib.player import Player, players
async def cmd_quit(player: Player, args: str) -> None:
"""Disconnect the player from the server.
Args:
player: The player executing the command
args: Command arguments (unused)
"""
player.writer.write("Goodbye!\r\n")
await player.writer.drain()
player.writer.close()
# Remove from player registry
if player.name in players:
del players[player.name]
# Register the quit command with its aliases
register(CommandDefinition("quit", cmd_quit, aliases=["q"], mode="*"))