From 917b348992822eebe7abd965b10ff939df18bd72 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 13 Aug 2020 11:44:41 +0200 Subject: [PATCH] lib/irc: make isHighlight operate on messages Makes it easier to re-use elsewhere. --- components/app.js | 2 +- lib/irc.js | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/components/app.js b/components/app.js index 74b73cb..0032d3e 100644 --- a/components/app.js +++ b/components/app.js @@ -291,7 +291,7 @@ export default class App extends Component { var text = msg.params[1]; var kind; - if (msg.prefix.name != this.client.nick && irc.isHighlight(text, this.client.nick)) { + if (irc.isHighlight(msg, this.client.nick)) { msgUnread = Unread.HIGHLIGHT; kind = "highlight"; } else if (target == this.client.nick) { diff --git a/lib/irc.js b/lib/irc.js index c8a3304..88edbdb 100644 --- a/lib/irc.js +++ b/lib/irc.js @@ -219,7 +219,15 @@ function isWordBoundary(ch) { } } -export function isHighlight(text, nick) { +export function isHighlight(msg, nick) { + if (msg.command != "PRIVMSG" && msg.command != "NOTICE") { + return false; + } + if (msg.prefix.name == nick) { + return false; // Our own messages aren't highlights + } + + var text = msg.params[1]; while (true) { var i = text.indexOf(nick); if (i < 0) {