From 83ec1cea52a9060fbb4c5068f614a320deb13a08 Mon Sep 17 00:00:00 2001 From: zefie Date: Wed, 18 Jun 2025 20:59:47 -0400 Subject: [PATCH] fix motd --- zefie_wtvp_minisrv/includes/classes/WTVIRC.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/zefie_wtvp_minisrv/includes/classes/WTVIRC.js b/zefie_wtvp_minisrv/includes/classes/WTVIRC.js index 50d6f239..06c537f0 100644 --- a/zefie_wtvp_minisrv/includes/classes/WTVIRC.js +++ b/zefie_wtvp_minisrv/includes/classes/WTVIRC.js @@ -4196,7 +4196,7 @@ class WTVIRC { } } - async doMOTD(nickname, socket) { + async doMOTD(nickname, socket = null) { // Sends the Message of the Day (MOTD) to the user var output_lines = []; output_lines.push(`:${this.servername} 375 ${nickname} :${this.servername} message of the day\r\n`); @@ -4216,7 +4216,11 @@ class WTVIRC { output_lines.push(`:${this.servername} 372 ${nickname} :No message of the day is set\r\n`); } output_lines.push(`:${this.servername} 376 ${nickname} :End of /MOTD command\r\n`); - await this.sendThrottled(socket, output_lines); + if (socket) { + await this.sendThrottled(socket, output_lines); + } else { + return output_lines; + } } isReservedChannel(channel) { @@ -4350,10 +4354,10 @@ class WTVIRC { return id; } - async sendThrottled(socket, lines, delayMs = 10) { + async sendThrottled(socket, lines, delayMs = 1) { for (const line of lines) { - socket.write(line); await new Promise(res => setTimeout(res, delayMs)); + socket.write(line); } } @@ -4649,7 +4653,7 @@ class WTVIRC { } output_lines.push(`:${this.servername} 042 ${nickname} ${socket.uniqueId} :your unique ID\r\n`); - await this.doMOTD(nickname, socket); + output_lines.push(...(await this.doMOTD(nickname))); const visibleClients = Array.from(this.nicknames.values()).filter(nick => { const modes = this.usermodes.get(nick) || [];