From 99004165f2a8b53661823c0f8ad841989afc19e3 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 29 Jun 2020 14:29:31 +0200 Subject: [PATCH] Print IRC error messages in red --- components/buffer.js | 4 ++++ lib/irc.js | 17 +++++++++++++++++ style.css | 3 +++ 3 files changed, 24 insertions(+) diff --git a/components/buffer.js b/components/buffer.js index d2695a8..4c640ca 100644 --- a/components/buffer.js +++ b/components/buffer.js @@ -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(" ")}`; } diff --git a/lib/irc.js b/lib/irc.js index e7bac49..dffc2d7 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -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; + } +} diff --git a/style.css b/style.css index c68b710..c0224f5 100644 --- a/style.css +++ b/style.css @@ -176,6 +176,9 @@ details summary { #buffer .talk { color: black; } +#buffer .error { + color: red; +} #buffer .me-tell { color: #b37400; }