From 403d7ec7f71909d3b38bac54d4c55df49172b4f8 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Sun, 6 Jun 2021 15:52:58 +0200 Subject: [PATCH] Add case-mapping support to irc.isHighlight Closes: https://todo.sr.ht/~emersion/gamja/77 --- components/app.js | 2 +- lib/irc.js | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/components/app.js b/components/app.js index f0e63c1..55b2e0c 100644 --- a/components/app.js +++ b/components/app.js @@ -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 = {}; diff --git a/lib/irc.js b/lib/irc.js index a7e5365..fdb4cb3 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -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) {