This commit is contained in:
zefie
2025-06-17 20:54:03 -04:00
parent 851531125e
commit d31f83f03f

View File

@@ -557,6 +557,7 @@ class WTVIRC {
if (targetSocket.client_caps && targetSocket.client_caps.includes('account-notify')) { if (targetSocket.client_caps && targetSocket.client_caps.includes('account-notify')) {
targetSocket.write(`:${targetSocket.nickname}!${targetSocket.username}@${targetSocket.host} ACCOUNT ${accountName}\r\n`); targetSocket.write(`:${targetSocket.nickname}!${targetSocket.username}@${targetSocket.host} ACCOUNT ${accountName}\r\n`);
} }
break;
case 'SVSNICK': case 'SVSNICK':
if (!socket.is_srv_authorized) { if (!socket.is_srv_authorized) {
socket.write(`:${this.servername} :ERROR :Permission denied\r\n`); socket.write(`:${this.servername} :ERROR :Permission denied\r\n`);
@@ -769,8 +770,9 @@ class WTVIRC {
this.broadcastToAllServers(`:${nickname}!${user_name}@${this.servername} QUIT :${message}\r\n`, socket); this.broadcastToAllServers(`:${nickname}!${user_name}@${this.servername} QUIT :${message}\r\n`, socket);
break; break;
case 'JOIN': case 'JOIN':
var channel = parts[3]; var channel = this.findChannel(parts[3]);
if (!this.channels.has(channel)) { if (!channel || !this.channels.has(channel)) {
channel = parts[3];
this.createChannel(channel); this.createChannel(channel);
} }
var userSocket = this.findSocketByUniqueId(sourceUniqueId); var userSocket = this.findSocketByUniqueId(sourceUniqueId);
@@ -1101,14 +1103,15 @@ class WTVIRC {
} }
break; break;
} }
var channel = parts[2]; var channel = this.findChannel(parts[2]);
if (!channel || !this.channels.has(channel)) {
socket.write(`:${this.servername} 403 ${nickname} ${channel} :No such channel\r\n`);
break;
}
var topic = parts.slice(3).join(' '); var topic = parts.slice(3).join(' ');
if (topic.startsWith(':')) { if (topic.startsWith(':')) {
topic = topic.slice(1); // Remove leading ':' topic = topic.slice(1); // Remove leading ':'
} }
if (!this.channels.has(channel)) {
this.createChannel(channel);
}
this.channeltopics.set(channel, topic); this.channeltopics.set(channel, topic);
var username = this.usernames.get(nickname) || nickname; var username = this.usernames.get(nickname) || nickname;
var hostname = this.hostnames.get(nickname) || ''; var hostname = this.hostnames.get(nickname) || '';
@@ -1237,17 +1240,19 @@ class WTVIRC {
break; break;
} }
var targetUniqueId = parts[2]; var targetUniqueId = parts[2];
var channelName = parts[3]; var channelName = this.findChannel(parts[3]);
var username = this.usernames.get(nickname) || nickname;
var hostname = this.hostnames.get(nickname) || '';
var targetSocket = this.findSocketByUniqueId(targetUniqueId); var targetSocket = this.findSocketByUniqueId(targetUniqueId);
if (!this.channels.has(channelName)) { var username = this.usernames.get(targetSocket.nickname) || socket.nickname;
var hostname = this.hostnames.get(targetSocket.nickname) || '';
if (!channelName ||!this.channels.has(channelName)) {
channelName = parts[3];
this.createChannel(channelName); this.createChannel(channelName);
} }
this.channels.get(channelName).add(nickname); if (!this.channels.get(channelName).has(targetSocket.nickname)) {
targetSocket.write(`:${nickname}!${username}@${hostname} JOIN ${channelName}\r\n`); this.channels.get(channelName).add(targetSocket.nickname);
this.broadcastChannel(channelName, `:${nickname}!${username}@${hostname} JOIN ${channelName}\r\n`, targetSocket); }
this.broadcastToAllServers(`:${sourceUniqueId} SVSJOIN ${channelName} ${targetUniqueId}\r\n`, socket); this.broadcastChannelJoin(channelName, targetSocket);
//this.broadcastToAllServers(`:${sourceUniqueId} SVSJOIN ${channelName} ${targetUniqueId}\r\n`, socket);
var chan_modes = this.channelmodes.get(channelName) || []; var chan_modes = this.channelmodes.get(channelName) || [];
if (chan_modes === true) { if (chan_modes === true) {
chan_modes = []; chan_modes = [];
@@ -3127,6 +3132,9 @@ class WTVIRC {
// Broadcast a channel join message to all users in the channel, except the one specified // Broadcast a channel join message to all users in the channel, except the one specified
channel = this.findChannel(channel); channel = this.findChannel(channel);
if (!channel) { if (!channel) {
if (this.debug) {
console.warn(`Attempted to broadcast join to non-existent channel: ${channel}`);
}
return; return;
} }
if (this.channels.has(channel)) { if (this.channels.has(channel)) {
@@ -3143,6 +3151,10 @@ class WTVIRC {
} }
} }
} }
} else {
if (this.debug) {
console.warn(`Attempted to broadcast join to non-existent channel: ${channel}`);
}
} }
} }