Add support for /me

This commit is contained in:
Simon Ser 2020-04-25 20:20:39 +02:00
parent b612c48fb2
commit 14ac3617ce
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48

View file

@ -42,14 +42,13 @@ function createMessageElement(msg) {
};
line.appendChild(timestamp);
line.appendChild(document.createTextNode(" "));
switch (msg.command) {
case "NOTICE":
case "PRIVMSG":
var text = msg.params[1];
line.className += " talk";
var nick = document.createElement("a");
nick.href = "#";
nick.className = "nick nick-" + (djb2(msg.prefix.name) % 16 + 1);
@ -59,10 +58,23 @@ function createMessageElement(msg) {
switchBuffer(createBuffer(msg.prefix.name));
};
line.appendChild(document.createTextNode(" <"));
line.appendChild(nick);
line.appendChild(document.createTextNode("> "));
line.appendChild(document.createTextNode(text));
var actionPrefix = "\001ACTION ";
if (text.startsWith(actionPrefix) && text.endsWith("\001")) {
var action = text.slice(actionPrefix.length, -1);
line.className += " me-tell";
line.appendChild(document.createTextNode("* "));
line.appendChild(nick);
line.appendChild(document.createTextNode(" " + action));
} else {
line.className += " talk";
line.appendChild(document.createTextNode("<"));
line.appendChild(nick);
line.appendChild(document.createTextNode("> "));
line.appendChild(document.createTextNode(text));
}
break;
default:
line.appendChild(document.createTextNode(" " + msg.command + " " + msg.params.join(" ")));