mirror of
https://github.com/Xevion/tcp-chat.git
synced 2025-12-06 03:16:44 -06:00
command name argument lower, ensure client is properly removed from main.py all_clients
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -33,5 +33,6 @@ def receive():
|
||||
thread = threading.Thread(target=client.handle, name=client.id[:8])
|
||||
thread.start()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
receive()
|
||||
|
||||
Reference in New Issue
Block a user