Add case-mapping support to irc.isHighlight

Closes: https://todo.sr.ht/~emersion/gamja/77
This commit is contained in:
Simon Ser 2021-06-06 15:52:58 +02:00
parent b9dc17db97
commit 403d7ec7f7
2 changed files with 7 additions and 5 deletions

View File

@ -322,7 +322,7 @@ export default class App extends Component {
msg.key = messagesCount;
messagesCount++;
msg.isHighlight = irc.isHighlight(msg, client.nick);
msg.isHighlight = irc.isHighlight(msg, client.nick, client.cm);
if (!msg.tags) {
msg.tags = {};

View File

@ -245,16 +245,18 @@ function isWordBoundary(ch) {
}
}
export function isHighlight(msg, nick) {
export function isHighlight(msg, nick, cm) {
if (msg.command != "PRIVMSG" && msg.command != "NOTICE") {
return false;
}
// TODO: case-mapping handling
if (msg.prefix && msg.prefix.name == nick) {
nick = cm(nick);
if (msg.prefix && cm(msg.prefix.name) == nick) {
return false; // Our own messages aren't highlights
}
var text = msg.params[1];
var text = cm(msg.params[1]);
while (true) {
var i = text.indexOf(nick);
if (i < 0) {