fix NICK change

This commit is contained in:
zefie
2025-06-20 05:30:24 -04:00
parent 8285fcea58
commit e52826482a

View File

@@ -1703,6 +1703,7 @@ class WTVIRC {
break; break;
} }
case 'NICK': case 'NICK':
var old_nickname = socket.nickname;
var new_nickname = params[0]; var new_nickname = params[0];
if (new_nickname.startsWith(':')) { if (new_nickname.startsWith(':')) {
new_nickname = new_nickname.slice(1); new_nickname = new_nickname.slice(1);
@@ -1757,13 +1758,12 @@ class WTVIRC {
if (!socket.nickname) { if (!socket.nickname) {
// If no nickname is set, set it now // If no nickname is set, set it now
socket.nickname = new_nickname; socket.nickname = new_nickname;
} this.nicknames.set(socket, socket.nickname);
this.nicknames.set(socket, socket.nickname); } else if (socket.nickname != new_nickname) {
if (socket.nickname && socket.newickname != new_nickname) {
this.processNickChange(socket, new_nickname); this.processNickChange(socket, new_nickname);
if (socket.registered) { if (socket.registered) {
socket.write(`:${socket.nickname}!${socket.username}@${socket.host} NICK :${new_nickname}\r\n`); socket.write(`:${old_nickname}!${socket.username}@${socket.host} NICK :${new_nickname}\r\n`);
this.broadcastUser(socket.nickname, `:${socket.nickname}!${socket.username}@${socket.host} NICK :${new_nickname}\r\n`, socket); this.broadcastUser(socket.nickname, `:${old_nickname}!${socket.username}@${socket.host} NICK :${new_nickname}\r\n`, socket);
this.broadcastToAllServers(`:${socket.uniqueId} NICK ${new_nickname} :${this.getDate()}\r\n`); this.broadcastToAllServers(`:${socket.uniqueId} NICK ${new_nickname} :${this.getDate()}\r\n`);
} }
} }