From db528715729f3e67bd84e9f2fe2462fbeb9cca55 Mon Sep 17 00:00:00 2001 From: Stack Fault Date: Tue, 27 Aug 2024 07:44:41 -0400 Subject: [PATCH 1/4] Fixed issue on URL resolver message Moved user_to uppercase to a different function --- core/servers/chat/mrc_multiplexer.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/servers/chat/mrc_multiplexer.js b/core/servers/chat/mrc_multiplexer.js index d39a9b5b6..d11488d15 100644 --- a/core/servers/chat/mrc_multiplexer.js +++ b/core/servers/chat/mrc_multiplexer.js @@ -245,8 +245,7 @@ exports.getModule = class MrcModule extends ServerModule { connectedSockets.forEach(client => { if ( message.to_user == '' || - // Fix PrivMSG delivery on case mismatch - message.to_user.toUpperCase() == client.username.toUpperCase() || + message.to_user == client.username.toUpperCase() || message.to_user == 'CLIENT' || message.from_user == client.username || message.to_user == 'NOTME' @@ -336,6 +335,13 @@ exports.getModule = class MrcModule extends ServerModule { // return; // } + // Make sure to_user is always uppercase + try { + let to_user_uc = to_user.toUpperCase(); + to_user = to_user_uc; + } + catch (e) {} + return { from_user, from_site, from_room, to_user, to_site, to_room, body }; } From 5b6fc321e2049012199e11bf9e4e811e8a717e0c Mon Sep 17 00:00:00 2001 From: Stack Fault Date: Tue, 27 Aug 2024 13:55:40 -0400 Subject: [PATCH 2/4] Removed temp var --- core/servers/chat/mrc_multiplexer.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/servers/chat/mrc_multiplexer.js b/core/servers/chat/mrc_multiplexer.js index d11488d15..bcbc52ef5 100644 --- a/core/servers/chat/mrc_multiplexer.js +++ b/core/servers/chat/mrc_multiplexer.js @@ -337,8 +337,7 @@ exports.getModule = class MrcModule extends ServerModule { // Make sure to_user is always uppercase try { - let to_user_uc = to_user.toUpperCase(); - to_user = to_user_uc; + to_user = to_user.toUpperCase(); } catch (e) {} From 27937ed14b7ff1d1ec7c4283a45853240edef2dd Mon Sep 17 00:00:00 2001 From: Stack Fault Date: Tue, 27 Aug 2024 15:36:17 -0400 Subject: [PATCH 3/4] Several fixes - Added msg delay on connect to space out commands - Fixed linewrap issue - Added MRC Trust verbs - Added PM local echo - Fixed to_user and from_user uppercase --- core/mrc.js | 68 ++++++++++++++++++++-------- core/servers/chat/mrc_multiplexer.js | 12 ++--- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/core/mrc.js b/core/mrc.js index 11533dbd2..327029535 100644 --- a/core/mrc.js +++ b/core/mrc.js @@ -275,21 +275,7 @@ exports.getModule = class mrcModule extends MenuModule { const chatLogView = this.viewControllers.mrcChat.getView( MciViewIds.mrcChat.chatLog ); - const messageLength = stripMciColorCodes(msg).length; - const chatWidth = chatLogView.dimens.width; - let padAmount = 0; - let spaces = 2; - - if (messageLength > chatWidth) { - padAmount = chatWidth - (messageLength % chatWidth) - spaces; - } else { - padAmount = chatWidth - messageLength - spaces; - } - - if (padAmount < 0) padAmount = 0; - - const padding = ' |00' + ' '.repeat(padAmount); - chatLogView.addText(pipeToAnsi(msg + padding)); + chatLogView.addText(pipeToAnsi(msg)); if (chatLogView.getLineCount() > this.config.maxScrollbackLines) { chatLogView.deleteLine(0); @@ -380,7 +366,7 @@ exports.getModule = class mrcModule extends MenuModule { // Deliver PrivMsg else if ( - message.to_user.toLowerCase() == this.state.alias.toLowerCase() + message.to_user.toUpperCase() == this.state.alias.toUpperCase() ) { const currentTime = moment().format( this.client.currentTheme.helpers.getTimeFormat() @@ -450,6 +436,14 @@ exports.getModule = class mrcModule extends MenuModule { } else { // pm formattedMessage = stringFormat(privateMessageFormat, textFormatObj); + + // Echo PrivMSG to chat log (the server does not echo it back) + const currentTime =moment().format( + this.client.currentTheme.helpers.getTimeFormat() + ); + this.addMessageToChatLog( + '|08' + currentTime + '|00 ' + formattedMessage + '|00' + ); } try { @@ -562,6 +556,7 @@ exports.getModule = class mrcModule extends MenuModule { /** * Process known additional server commands directly */ + case 'afk': this.sendServerMessage(`AFK ${message.substr(5)}`); break; @@ -594,6 +589,30 @@ exports.getModule = class mrcModule extends MenuModule { this.sendServerMessage(cmd[0].toUpperCase()); break; + /** + * MRC Trust commands + */ + + case 'trust': + this.sendServerMessage(`REGISTER ${message.substr(7)}`); + break; + + case 'register': + this.sendServerMessage(`REGISTER ${message.substr(10)}`); + break; + + case 'identify': + this.sendServerMessage(`IDENTIFY ${message.substr(10)}`); + break; + + case 'update': + this.sendServerMessage(`UPDATE ${message.substr(8)}`); + break; + + /** + * Local client commands + */ + case 'quit': return this.prevMenu(); @@ -665,13 +684,26 @@ exports.getModule = class mrcModule extends MenuModule { this.sendServerMessage('USERLIST'); } + /** + * MRC Server flood protection requires messages to be spaced in time + */ + msgDelay(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + /** * Things that happen when a local user connects to the MRC multiplexer */ - clientConnect() { + async clientConnect() { + this.sendHeartbeat(); + await this.msgDelay(100); + this.sendServerMessage('MOTD'); + await this.msgDelay(100); + this.joinRoom('lobby'); + await this.msgDelay(100); + this.sendServerMessage('STATS'); - this.sendHeartbeat(); } }; diff --git a/core/servers/chat/mrc_multiplexer.js b/core/servers/chat/mrc_multiplexer.js index bcbc52ef5..c0d7827a8 100644 --- a/core/servers/chat/mrc_multiplexer.js +++ b/core/servers/chat/mrc_multiplexer.js @@ -16,7 +16,7 @@ const os = require('os'); // MRC const clientVersion = '1.3.1'; -const lineDelimiter = new RegExp('\r\n|\r|\n'); // eslint-disable-line no-control-regex +const lineDelimiter = new RegExp('\r\n|\r|\n|\n\r'); // eslint-disable-line no-control-regex const ModuleInfo = (exports.moduleInfo = { name: 'MRC', @@ -327,7 +327,7 @@ exports.getModule = class MrcModule extends ServerModule { * Takes an MRC message and parses it into something usable */ parseMessage(line) { - const [from_user, from_site, from_room, to_user, to_site, to_room, body] = + let [from_user, from_site, from_room, to_user, to_site, to_room, body] = line.split('~'); // const msg = line.split('~'); @@ -335,11 +335,9 @@ exports.getModule = class MrcModule extends ServerModule { // return; // } - // Make sure to_user is always uppercase - try { - to_user = to_user.toUpperCase(); - } - catch (e) {} + // Make sure to_user and from_user are always uppercase + to_user = (to_user || '').toUpperCase(); + from_user = (from_user || '').toUpperCase(); return { from_user, from_site, from_room, to_user, to_site, to_room, body }; } From cf712d3c62831748425d6d3049f8c843a7c7b5b9 Mon Sep 17 00:00:00 2001 From: Stack Fault Date: Sat, 31 Aug 2024 12:35:01 -0400 Subject: [PATCH 4/4] Command aliasing + additional passthru cmds Fixed previously added passthru (TRUST) Fixed trailing PIPE code sent to server unnecessarily --- core/mrc.js | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/core/mrc.js b/core/mrc.js index 327029535..835e48bfe 100644 --- a/core/mrc.js +++ b/core/mrc.js @@ -47,7 +47,7 @@ const MciViewIds = { const helpText = ` |15General Chat|08: |03/|11rooms |08& |03/|11join |03 |08- |07List all or join a room -|03/|11pm |03 |08- |07Send a private message +|03/|11pm |03 |08- |07Send a private message |08(/t /tell /msg) ---- |03/|11whoon |08- |07Who's on what BBS |03/|11chatters |08- |07Who's in what room @@ -57,6 +57,7 @@ const helpText = ` |03/|11meetups |08- |07Info about MRC MeetUps |03/|11quote |08- |07Send raw command to server |03/|11help |08- |07Server-side commands help +|03/|11quit |08- |07Quit MRC |08(/q) --- |03/|11l33t |03 |08- |07l337 5p34k |03/|11kewl |03 |08- |07BBS KeWL SPeaK @@ -423,11 +424,11 @@ exports.getModule = class mrcModule extends MenuModule { const messageFormat = this.config.messageFormat || - '|00|10<|02{fromUserName}|10>|00 |03{message}|00'; + '|00|10<|02{fromUserName}|10>|00 |03{message}'; const privateMessageFormat = this.config.outgoingPrivateMessageFormat || - '|00|10<|02{fromUserName}|10|14->|02{toUserName}>|00 |03{message}|00'; + '|00|10<|02{fromUserName}|10|14->|02{toUserName}>|00 |03{message}'; let formattedMessage = ''; if (to_user == undefined) { @@ -471,6 +472,9 @@ exports.getModule = class mrcModule extends MenuModule { cmd[0] = cmd[0].substr(1).toLowerCase(); switch (cmd[0]) { + case 't': + case 'tell': + case 'msg': case 'pm': const newmsg = cmd.slice(2).join(' '); this.processOutgoingMessage(newmsg, cmd[1]); @@ -573,6 +577,10 @@ exports.getModule = class mrcModule extends MenuModule { this.sendServerMessage(`STATUS ${message.substr(8)}`); break; + case 'topics': + this.sendServerMessage(`TOPICS ${message.substr(8)}`); + break; + case 'lastseen': this.sendServerMessage(`LASTSEEN ${message.substr(10)}`); break; @@ -594,7 +602,7 @@ exports.getModule = class mrcModule extends MenuModule { */ case 'trust': - this.sendServerMessage(`REGISTER ${message.substr(7)}`); + this.sendServerMessage(`TRUST ${message.substr(7)}`); break; case 'register': @@ -613,6 +621,7 @@ exports.getModule = class mrcModule extends MenuModule { * Local client commands */ + case 'q': case 'quit': return this.prevMenu(); @@ -640,6 +649,13 @@ exports.getModule = class mrcModule extends MenuModule { chatLogView.setText(''); } + /** + * MRC Server flood protection requires messages to be spaced in time + */ + msgDelay(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + /** * Creates a json object, stringifies it and sends it to the MRC multiplexer */ @@ -676,19 +692,14 @@ exports.getModule = class mrcModule extends MenuModule { /** * Joins a room, unsurprisingly */ - joinRoom(room) { + async joinRoom(room) { // room names are displayed with a # but referred to without. confusing. room = room.replace(/^#/, ''); this.state.room = room; this.sendServerMessage(`NEWROOM:${this.state.room}:${room}`); - this.sendServerMessage('USERLIST'); - } - /** - * MRC Server flood protection requires messages to be spaced in time - */ - msgDelay(ms) { - return new Promise((resolve) => setTimeout(resolve, ms)); + await this.msgDelay(100); + this.sendServerMessage('USERLIST'); } /** @@ -698,9 +709,6 @@ exports.getModule = class mrcModule extends MenuModule { this.sendHeartbeat(); await this.msgDelay(100); - this.sendServerMessage('MOTD'); - await this.msgDelay(100); - this.joinRoom('lobby'); await this.msgDelay(100);