From 7e85e9fd11b1185d96626ffaf37460d737184619 Mon Sep 17 00:00:00 2001 From: Cory McWilliams Date: Fri, 23 Dec 2016 20:04:38 +0000 Subject: [PATCH] Display /me actions in IRC. git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3365 ed5197a5-7fde-0310-b194-c3ffbd925b24 --- packages/cory/chat/chat.js | 26 +++++++++++++++++--------- packages/cory/libirc/libirc.js | 12 ++++++++++-- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/cory/chat/chat.js b/packages/cory/chat/chat.js index 6e62fb78..7d77a3d5 100644 --- a/packages/cory/chat/chat.js +++ b/packages/cory/chat/chat.js @@ -169,7 +169,6 @@ function connect(id) { break; } } - print(id, account); if (account) { let self = {account: account}; @@ -431,14 +430,23 @@ function printMessage(message) { var now = message.timestamp || new Date().toString(); var from = message.from || "unknown"; - terminal.print( - {class: "base0", value: niceTime(lastTimestamp, now)}, - " ", - {class: "base00", value: "<"}, - {class: "base3", value: from}, - {class: "base00", value: ">"}, - " ", - formatMessage(message.message)); + if (message.action) { + terminal.print( + {class: "base0", value: niceTime(lastTimestamp, now)}, + " * ", + {class: "base3", value: from}, + " ", + formatMessage(message.message)); + } else { + terminal.print( + {class: "base0", value: niceTime(lastTimestamp, now)}, + " ", + {class: "base00", value: "<"}, + {class: "base3", value: from}, + {class: "base00", value: ">"}, + " ", + formatMessage(message.message)); + } lastTimestamp = now; } diff --git a/packages/cory/libirc/libirc.js b/packages/cory/libirc/libirc.js index f478ef3d..8a765a03 100644 --- a/packages/cory/libirc/libirc.js +++ b/packages/cory/libirc/libirc.js @@ -73,11 +73,19 @@ class IrcService { } else if (prefix.indexOf('!') != -1) { conversation = prefix.split('!')[0]; } - this._service.notifyMessageReceived(conversation, { + let message = { from: prefix.split('!')[0], message: parts[parts.length - 1], type: parts[0], - }); + }; + if (message.message.length > 2 && message.message.charCodeAt(0) == 1 && message.message.charCodeAt(message.message.length - 1) == 1) { + message.ctcp = true; + if (message.message.substring(1, 1 + "ACTION ".length) == "ACTION ") { + message.action = true; + message.message = message.message.substring(1 + "ACTION ".length, message.message.length - 1); + } + } + this._service.notifyMessageReceived(conversation, message); } else if (parts[0] == "PING") { parts[0] = "PONG"; this._send(parts.join(" "));