Print IRC error messages in red

This commit is contained in:
Simon Ser 2020-06-29 14:29:31 +02:00
parent 20be67503b
commit 99004165f2
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
3 changed files with 24 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import { html, Component } from "/lib/index.js";
import linkify from "/lib/linkify.js";
import * as irc from "/lib/irc.js";
function djb2(s) {
var hash = 5381;
@ -82,6 +83,9 @@ function LogLine(props) {
`;
break;
default:
if (irc.isError(msg.command) && msg.command != irc.ERR_NOMOTD) {
lineClass = "error";
}
content = html`${msg.command} ${msg.params.join(" ")}`;
}

View file

@ -7,6 +7,7 @@ export const RPL_TOPIC = "332";
export const RPL_WHOREPLY = "352";
export const RPL_NAMREPLY = "353";
export const RPL_ENDOFNAMES = "366";
export const ERR_NOMOTD = "422";
export const ERR_PASSWDMISMATCH = "464";
// https://ircv3.net/specs/extensions/sasl-3.1
export const RPL_LOGGEDIN = "900";
@ -240,3 +241,19 @@ export function isHighlight(text, nick) {
text = text.slice(i + nick.length);
}
}
export function isError(cmd) {
if (cmd >= "400" && cmd <= "568") {
return true;
}
switch (cmd) {
case ERR_NICKLOCKED:
case ERR_SASLFAIL:
case ERR_SASLTOOLONG:
case ERR_SASLABORTED:
case ERR_SASLALREADY:
return true;
default:
return false;
}
}

View file

@ -176,6 +176,9 @@ details summary {
#buffer .talk {
color: black;
}
#buffer .error {
color: red;
}
#buffer .me-tell {
color: #b37400;
}