diff --git a/server/commands.py b/server/commands.py index 343b15a..b669b2d 100644 --- a/server/commands.py +++ b/server/commands.py @@ -32,7 +32,7 @@ class CommandHandler: aliases = [] name = name or func.__name__.capitalize() - command_name = command_name or func.__name__.lower() + command_name = (command_name or func.__name__).lower() for alias in aliases: self.aliases[alias] = command_name diff --git a/server/handler.py b/server/handler.py index ef586b9..8112063 100644 --- a/server/handler.py +++ b/server/handler.py @@ -104,7 +104,9 @@ class Client: command = data['content'].strip() if command.startswith('/'): - msg = self.command.process(data['content'][1:].strip().split()) + args = data['content'][1:].strip().split() + args[0] = args[0].lower() # Command name will always be perceived as lowercase + msg = self.command.process(args) if msg is not None: self.broadcast_message(msg) @@ -112,5 +114,6 @@ class Client: logger.critical(e, exc_info=True) logger.info(f'Client {self.id} closed. ({self.nickname})') self.conn.close() + self.all_clients.remove(self) self.broadcast_message(f'{self.nickname} left!') break diff --git a/server/main.py b/server/main.py index 2540bbc..5a3df74 100644 --- a/server/main.py +++ b/server/main.py @@ -33,5 +33,6 @@ def receive(): thread = threading.Thread(target=client.handle, name=client.id[:8]) thread.start() + if __name__ == '__main__': receive()