Display /me actions in IRC.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3365 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
Cory McWilliams 2016-12-23 20:04:38 +00:00
parent fe765ed834
commit 7e85e9fd11
2 changed files with 27 additions and 11 deletions

View File

@ -169,7 +169,6 @@ function connect(id) {
break; break;
} }
} }
print(id, account);
if (account) { if (account) {
let self = {account: account}; let self = {account: account};
@ -431,6 +430,14 @@ function printMessage(message) {
var now = message.timestamp || new Date().toString(); var now = message.timestamp || new Date().toString();
var from = message.from || "unknown"; var from = message.from || "unknown";
if (message.action) {
terminal.print(
{class: "base0", value: niceTime(lastTimestamp, now)},
" * ",
{class: "base3", value: from},
" ",
formatMessage(message.message));
} else {
terminal.print( terminal.print(
{class: "base0", value: niceTime(lastTimestamp, now)}, {class: "base0", value: niceTime(lastTimestamp, now)},
" ", " ",
@ -439,6 +446,7 @@ function printMessage(message) {
{class: "base00", value: ">"}, {class: "base00", value: ">"},
" ", " ",
formatMessage(message.message)); formatMessage(message.message));
}
lastTimestamp = now; lastTimestamp = now;
} }

View File

@ -73,11 +73,19 @@ class IrcService {
} else if (prefix.indexOf('!') != -1) { } else if (prefix.indexOf('!') != -1) {
conversation = prefix.split('!')[0]; conversation = prefix.split('!')[0];
} }
this._service.notifyMessageReceived(conversation, { let message = {
from: prefix.split('!')[0], from: prefix.split('!')[0],
message: parts[parts.length - 1], message: parts[parts.length - 1],
type: parts[0], 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") { } else if (parts[0] == "PING") {
parts[0] = "PONG"; parts[0] = "PONG";
this._send(parts.join(" ")); this._send(parts.join(" "));