fix uniqueid issue
This commit is contained in:
@@ -3381,6 +3381,13 @@ class WTVIRC {
|
|||||||
return nickname;
|
return nickname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (const [socket, users] of this.serverusers.entries()) {
|
||||||
|
for (const user of users) {
|
||||||
|
if (this.getUniqueId(user) === uniqueId) {
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3484,6 +3491,8 @@ class WTVIRC {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
getUsernameFromUniqueId(uniqueId) {
|
getUsernameFromUniqueId(uniqueId) {
|
||||||
// Find the username associated with a unique ID
|
// Find the username associated with a unique ID
|
||||||
for (const [socket, nickname] of this.nicknames.entries()) {
|
for (const [socket, nickname] of this.nicknames.entries()) {
|
||||||
@@ -3594,8 +3603,11 @@ class WTVIRC {
|
|||||||
findUser(username) {
|
findUser(username) {
|
||||||
// Normalize the username to lowercase for case-insensitive comparison
|
// Normalize the username to lowercase for case-insensitive comparison
|
||||||
let foundUser = null;
|
let foundUser = null;
|
||||||
|
if (typeof username !== 'string') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (const [socket, nick] of this.nicknames.entries()) {
|
for (const [socket, nick] of this.nicknames.entries()) {
|
||||||
if (nick.toLowerCase() === username.toLowerCase()) {
|
if (nick.toLowerCase() === username.toLowerCase()) {
|
||||||
foundUser = nick;
|
foundUser = nick;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -3895,22 +3907,10 @@ class WTVIRC {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
processChannelModeParams(channel, mode, params, socket) {
|
processChannelModeParams(channel, mode, target) {
|
||||||
if (!params) {
|
|
||||||
return false; // No parameters provided
|
|
||||||
}
|
|
||||||
var target = null;
|
|
||||||
if (socket.isserver) {
|
|
||||||
target = this.findSocketByUniqueId(params);
|
|
||||||
} else {
|
|
||||||
target = this.findUser(params);
|
|
||||||
}
|
|
||||||
if (!target) {
|
|
||||||
target = params;
|
|
||||||
}
|
|
||||||
if (!target) {
|
if (!target) {
|
||||||
if (this.debug) {
|
if (this.debug) {
|
||||||
console.warn(`No target found for unique ID ${params}`);
|
console.warn(`No target found for ${target}`);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -4049,6 +4049,7 @@ class WTVIRC {
|
|||||||
// Split modes into array and process each character
|
// Split modes into array and process each character
|
||||||
let modeChars = modes.split('');
|
let modeChars = modes.split('');
|
||||||
var serverModeMsg = '';
|
var serverModeMsg = '';
|
||||||
|
var target = null;
|
||||||
if (socket.isserver) {
|
if (socket.isserver) {
|
||||||
let sourceUniqueId = this.uniqueids.get(nickname);
|
let sourceUniqueId = this.uniqueids.get(nickname);
|
||||||
serverModeMsg = `:${sourceUniqueId} MODE ${channel} `;
|
serverModeMsg = `:${sourceUniqueId} MODE ${channel} `;
|
||||||
@@ -4064,7 +4065,6 @@ class WTVIRC {
|
|||||||
|
|
||||||
let modeMsg = `:${nickname}!${username}@${hostname} MODE ${channel} `;
|
let modeMsg = `:${nickname}!${username}@${hostname} MODE ${channel} `;
|
||||||
let addingFlag = false;
|
let addingFlag = false;
|
||||||
let flags = [];
|
|
||||||
let paramIndex = 0;
|
let paramIndex = 0;
|
||||||
if (!socket.isserver) {
|
if (!socket.isserver) {
|
||||||
if (modeChars.includes('o')) {
|
if (modeChars.includes('o')) {
|
||||||
@@ -4079,14 +4079,7 @@ class WTVIRC {
|
|||||||
socket.write(`:${this.servername} 482 ${nickname} ${channel} :You're not an IRC operator\r\n`);
|
socket.write(`:${this.servername} 482 ${nickname} ${channel} :You're not an IRC operator\r\n`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (modes === 'b') {
|
||||||
if (!this.isIRCOp(nickname) && !this.isChannelOp(nickname, channel) && !this.isChannelHalfOp(nickname, channel)) {
|
|
||||||
socket.write(`:${this.servername} 482 ${nickname} ${channel} :You're not a channel operator\r\n`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modes === 'b') {
|
|
||||||
// Get the list of channel bans
|
// Get the list of channel bans
|
||||||
var output_lines = [];
|
var output_lines = [];
|
||||||
if (this.channelbans.has(channel)) {
|
if (this.channelbans.has(channel)) {
|
||||||
@@ -4122,7 +4115,13 @@ class WTVIRC {
|
|||||||
output_lines.push(`:${this.servername} 337 ${nickname} ${channel} :End of channel invite list\r\n`);
|
output_lines.push(`:${this.servername} 337 ${nickname} ${channel} :End of channel invite list\r\n`);
|
||||||
this.sendThrottled(socket, output_lines);
|
this.sendThrottled(socket, output_lines);
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
if (!this.isIRCOp(nickname) && !this.isChannelOp(nickname, channel) && !this.isChannelHalfOp(nickname, channel)) {
|
||||||
|
socket.write(`:${this.servername} 482 ${nickname} ${channel} :You're not a channel operator\r\n`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
for (let j = 0; j < modeChars.length; j++) {
|
for (let j = 0; j < modeChars.length; j++) {
|
||||||
let param = null;
|
let param = null;
|
||||||
@@ -4144,7 +4143,13 @@ class WTVIRC {
|
|||||||
if (['o', 'I', 'b', 'e', 'v', 'h', 'l', 'k'].includes(mc)) {
|
if (['o', 'I', 'b', 'e', 'v', 'h', 'l', 'k'].includes(mc)) {
|
||||||
var plusminus = (addingFlag) ? "+" : "-";
|
var plusminus = (addingFlag) ? "+" : "-";
|
||||||
param = params[paramIndex];
|
param = params[paramIndex];
|
||||||
var result = this.processChannelModeParams(channel, plusminus + mc, param, socket);
|
if (socket.isserver) {
|
||||||
|
target = this.findUserByUniqueId(param);
|
||||||
|
} else {
|
||||||
|
target = this.findUser(param);
|
||||||
|
}
|
||||||
|
console.log(target, param);
|
||||||
|
var result = this.processChannelModeParams(channel, plusminus + mc, target, socket);
|
||||||
paramIndex++;
|
paramIndex++;
|
||||||
} else {
|
} else {
|
||||||
var result = this.setChannelMode(channel, mc, addingFlag);
|
var result = this.setChannelMode(channel, mc, addingFlag);
|
||||||
@@ -4173,7 +4178,11 @@ class WTVIRC {
|
|||||||
}
|
}
|
||||||
if (params.length > 0) {
|
if (params.length > 0) {
|
||||||
for (let i = 0; i < params.length; i++) {
|
for (let i = 0; i < params.length; i++) {
|
||||||
modeMsg += ' ' + params[i];
|
if (socket.isserver) {
|
||||||
|
modeMsg += ' ' + this.findUserByUniqueId(params[i]);
|
||||||
|
} else {
|
||||||
|
modeMsg += ' ' + params[i];
|
||||||
|
}
|
||||||
serverModeMsg += ' ' + params[i];
|
serverModeMsg += ' ' + params[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user