mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Print IRC error messages in red
This commit is contained in:
parent
20be67503b
commit
99004165f2
3 changed files with 24 additions and 0 deletions
|
@ -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(" ")}`;
|
||||
}
|
||||
|
||||
|
|
17
lib/irc.js
17
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,6 +176,9 @@ details summary {
|
|||
#buffer .talk {
|
||||
color: black;
|
||||
}
|
||||
#buffer .error {
|
||||
color: red;
|
||||
}
|
||||
#buffer .me-tell {
|
||||
color: #b37400;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue