|
@ -1,6 +1,7 @@ |
|
|
from paircd.client import Client |
|
|
from paircd.client import Client |
|
|
from paircd.command_handler import CommandHandler |
|
|
from paircd.command_handler import CommandHandler |
|
|
from paircd.message import Message |
|
|
from paircd.message import Message |
|
|
|
|
|
from paircd.reply import ERR_NICKNAMEINUSE |
|
|
from paircd.server import Server |
|
|
from paircd.server import Server |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -11,6 +12,13 @@ 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] |
|
|
|
|
|
|
|
|
|
|
|
existing_client = server.get_client_by_name(nickname) |
|
|
|
|
|
if existing_client is not None: |
|
|
|
|
|
if client != existing_client: |
|
|
|
|
|
target = client.nickname if client.nickname else nickname |
|
|
|
|
|
client.write_message(ERR_NICKNAMEINUSE(target, nickname)) |
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
# Remove stale references if they exist |
|
|
# Remove stale references if they exist |
|
|
if client.nickname: |
|
|
if client.nickname: |
|
|
server.remove_client_by_name(client.nickname) |
|
|
server.remove_client_by_name(client.nickname) |
|
|