a little flair for webtv, and a new hack system

This commit is contained in:
zefie
2025-06-20 20:13:15 -04:00
parent 54f7b47086
commit d4396a8e1e

View File

@@ -40,8 +40,8 @@ class WTVIRC {
this.debug = debug; this.debug = debug;
this.server = null; this.server = null;
this.clients = []; this.clients = [];
this.usernames = new Map(); // nickname -> username
this.channelData = new Map(); this.channelData = new Map();
this.usernames = new Map(); // nickname -> username
this.usertimestamps = new Map(); // nickname -> timestamp since last message this.usertimestamps = new Map(); // nickname -> timestamp since last message
this.usermodes = new Map(); // nickname -> Array of modes (e.g. ['w', 'i']) this.usermodes = new Map(); // nickname -> Array of modes (e.g. ['w', 'i'])
this.usersignontimestamps = new Map(); // nickname -> timestamp since user signed on this.usersignontimestamps = new Map(); // nickname -> timestamp since user signed on
@@ -103,6 +103,7 @@ class WTVIRC {
this.supported_prefixes = ["ohv", "@%+"]; this.supported_prefixes = ["ohv", "@%+"];
this.supported_client_caps = ['chghost', 'away-notify', 'echo-message', 'invite-notify', 'multi-prefix', 'userhost-in-names', 'account-notify', 'extended-join']; this.supported_client_caps = ['chghost', 'away-notify', 'echo-message', 'invite-notify', 'multi-prefix', 'userhost-in-names', 'account-notify', 'extended-join'];
this.supported_server_caps = ['TBURST', 'EOB', 'IE', 'EX']; this.supported_server_caps = ['TBURST', 'EOB', 'IE', 'EX'];
this.supported_webtv_command_hacks = ["MODE"];
this.session_store_path = this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + path.sep + 'minisrv_internal_irc'); this.session_store_path = this.wtvshared.getAbsolutePath(this.minisrv_config.config.SessionStore + path.sep + 'minisrv_internal_irc');
this.klines_path = this.session_store_path + path.sep + 'klines.json'; this.klines_path = this.session_store_path + path.sep + 'klines.json';
this.caps = [ this.caps = [
@@ -877,6 +878,9 @@ class WTVIRC {
break; break;
} }
targetSocket.write(`:${targetSocket.nickname} MODE ${targetSocket.nickname} ${parts.slice(2).join(' ')}\r\n`); targetSocket.write(`:${targetSocket.nickname} MODE ${targetSocket.nickname} ${parts.slice(2).join(' ')}\r\n`);
if (this.clientIsWebTV(targetSocket)) {
this.sendWebTVNoticeTo(targetSocket, `The network has set your user mode: ${parts.slice(3).join(' ')}`);
}
this.broadcastToAllServers(`:${sourceUniqueId} MODE ${targetUniqueId} ${parts.slice(3).join(' ')}\r\n`, socket); this.broadcastToAllServers(`:${sourceUniqueId} MODE ${targetUniqueId} ${parts.slice(3).join(' ')}\r\n`, socket);
break; break;
case 'NICK': case 'NICK':
@@ -2016,7 +2020,7 @@ class WTVIRC {
if (this.clientIsWebTV(socket)) { if (this.clientIsWebTV(socket)) {
var output_lines = []; var output_lines = [];
var channelObj = this.channelData.get(ch); var channelObj = this.channelData.get(ch);
output_lines.push("Welcome to the channel " + ch + "! You have joined successfully."); output_lines.push("You have joined " + ch + ".");
output_lines.push("Current channel modes: +" + channelObj.modes.join('')); output_lines.push("Current channel modes: +" + channelObj.modes.join(''));
let isOp = channelObj.ops.has(socket.nickname); let isOp = channelObj.ops.has(socket.nickname);
let isHalfOp = channelObj.halfops.has(socket.nickname); let isHalfOp = channelObj.halfops.has(socket.nickname);
@@ -2361,6 +2365,16 @@ class WTVIRC {
socket.write(`:${this.servername} 403 ${socket.nickname} ${t} :No such channel\r\n`); socket.write(`:${this.servername} 403 ${socket.nickname} ${t} :No such channel\r\n`);
continue; continue;
} }
if (this.clientIsWebTV(socket) && msg.startsWith('/')) {
var wtvcmd = msg.slice(1).split(' ');
if (wtvcmd[0].length > 0) {
if (this.supported_webtv_command_hacks.includes(wtvcmd[0].toUpperCase())) {
var wtvstr = `${wtvcmd[0].toUpperCase()} ${wtvcmd.splice(1).join(' ')}\r\n`;
this.processSocketData(socket, wtvstr);
}
}
continue;
}
this.broadcastChannel(t, `:${socket.nickname}!${socket.username}@${socket.host} PRIVMSG ${t} :${msg}\r\n`, socket); this.broadcastChannel(t, `:${socket.nickname}!${socket.username}@${socket.host} PRIVMSG ${t} :${msg}\r\n`, socket);
this.broadcastToAllServers(`:${socket.uniqueId} PRIVMSG ${t} :${msg}\r\n`); this.broadcastToAllServers(`:${socket.uniqueId} PRIVMSG ${t} :${msg}\r\n`);
} else { } else {
@@ -3033,6 +3047,20 @@ class WTVIRC {
} }
} }
broadcastChannelWebTV(channel, message, exceptSocket = null) {
// Broadcast a message to all users in a specific channel, except the one specified
if (this.channelData.has(channel)) {
const channelObj = this.channelData.get(channel);
for (const user of channelObj.users) {
const socket = Array.from(this.nicknames.keys()).find(s => this.nicknames.get(s) === user);
// Only send to WebTV clients
if (socket && socket !== exceptSocket && this.clientIsWebTV(socket)) {
this.sendWebTVNoticeTo(socket, message)
}
}
}
}
broadcastChannelJoin(channel, sourceSocket, exceptSocket = null) { broadcastChannelJoin(channel, sourceSocket, exceptSocket = null) {
// 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);
@@ -3931,6 +3959,7 @@ class WTVIRC {
var hostname = this.hostnames.get(nickname); var hostname = this.hostnames.get(nickname);
let modeMsg = `:${nickname}!${username}@${hostname} MODE ${channel} `; let modeMsg = `:${nickname}!${username}@${hostname} MODE ${channel} `;
let WTVMsg = `${nickname} has set channel mode `;
let addingFlag = false; let addingFlag = false;
let paramIndex = 0; let paramIndex = 0;
if (!socket.isserver) { if (!socket.isserver) {
@@ -3997,11 +4026,13 @@ class WTVIRC {
if (mc === '+') { if (mc === '+') {
addingFlag = true; addingFlag = true;
modeMsg += '+'; modeMsg += '+';
WTVMsg += '+';
serverModeMsg += '+'; serverModeMsg += '+';
continue; continue;
} else if (mc === '-') { } else if (mc === '-') {
addingFlag = false; addingFlag = false;
modeMsg += '-'; modeMsg += '-';
WTVMsg += '-';
serverModeMsg += '-'; serverModeMsg += '-';
continue; continue;
} }
@@ -4051,6 +4082,7 @@ class WTVIRC {
} }
} }
if (result) { if (result) {
WTVMsg += mc;
validModes.push(mc); validModes.push(mc);
if (modeStr.length > 0) { if (modeStr.length > 0) {
modeMsg += modeStr; modeMsg += modeStr;
@@ -4064,6 +4096,7 @@ class WTVIRC {
modeMsg += ' ' + this.findUserByUniqueId(params[i]); modeMsg += ' ' + this.findUserByUniqueId(params[i]);
} else { } else {
modeMsg += ' ' + params[i]; modeMsg += ' ' + params[i];
WTVMsg += ' ' + params[i];
} }
serverModeMsg += ' ' + params[i]; serverModeMsg += ' ' + params[i];
} }
@@ -4074,6 +4107,7 @@ class WTVIRC {
modeMsg += '\r\n'; modeMsg += '\r\n';
if (validModes.length > 0) { if (validModes.length > 0) {
this.broadcastChannel(channel, modeMsg); this.broadcastChannel(channel, modeMsg);
this.broadcastChannelWebTV(channel, WTVMsg);
this.broadcastToAllServers(serverModeMsg, socket); this.broadcastToAllServers(serverModeMsg, socket);
} }
} }