lib/irc: make isHighlight operate on messages

Makes it easier to re-use elsewhere.
This commit is contained in:
Simon Ser 2020-08-13 11:44:41 +02:00
parent 11660e4409
commit 917b348992
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 10 additions and 2 deletions

View file

@ -291,7 +291,7 @@ export default class App extends Component {
var text = msg.params[1]; var text = msg.params[1];
var kind; 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; msgUnread = Unread.HIGHLIGHT;
kind = "highlight"; kind = "highlight";
} else if (target == this.client.nick) { } else if (target == this.client.nick) {

View file

@ -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) { while (true) {
var i = text.indexOf(nick); var i = text.indexOf(nick);
if (i < 0) { if (i < 0) {