|
@ -12,12 +12,20 @@ class NickHandler(CommandHandler): |
|
|
async def handle(self, server: Server, client: Client, msg: Message) -> None: |
|
|
async def handle(self, server: Server, client: Client, msg: Message) -> None: |
|
|
nickname = msg.args[0] |
|
|
nickname = msg.args[0] |
|
|
|
|
|
|
|
|
|
|
|
# Remove stale references if they exist |
|
|
if client.nickname: |
|
|
if client.nickname: |
|
|
del server.clients_by_nick[client.nickname] |
|
|
|
|
|
# TODO: Update all channel references |
|
|
|
|
|
|
|
|
server.remove_client_by_name(client.nickname) |
|
|
|
|
|
for channel_name in client.channels: |
|
|
|
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
|
|
|
channel.remove_client_by_nick(client.nickname) |
|
|
|
|
|
|
|
|
client.nickname = nickname |
|
|
client.nickname = nickname |
|
|
|
|
|
|
|
|
|
|
|
# Add references for client |
|
|
server.add_client(client) |
|
|
server.add_client(client) |
|
|
|
|
|
for channel_name in client.channels: |
|
|
|
|
|
channel = server.get_channel_by_name(channel_name) |
|
|
|
|
|
channel.remove_client_by_nick(client.nickname) |
|
|
|
|
|
|
|
|
if client.username and client.realname: |
|
|
if client.username and client.realname: |
|
|
client.registered = True |
|
|
client.registered = True |
|
|