From 1e37f83f8f776ed1c358d3adb6f2e686df67227d Mon Sep 17 00:00:00 2001 From: Tobias Girstmair Date: Sat, 25 May 2024 22:48:20 +0200 Subject: [PATCH] highlight: make sure own nick is delimetered properly --- contrib/highlight | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contrib/highlight b/contrib/highlight index 2f3089a..e23130f 100755 --- a/contrib/highlight +++ b/contrib/highlight @@ -1,6 +1,6 @@ #!/usr/bin/python3 -import sys +import re, sys def parse(line): #-> [nick, user, host], command, arguments prefix, params = b"", [] @@ -58,9 +58,9 @@ for line in sys.stdin.buffer: msg_end +=1 hi_start, hi_end = msg_start, msg_start - if myself and myself in msg: # highlight own nick - hi_start = msg.index(myself) + msg_start - hi_end = len(myself) + hi_start + if m := re.search(rb"\b%s\b" % re.escape(myself), msg): + hi_start = msg_start + m.start(0) + hi_end = msg_start + m.end(0) say( DIM, line[:nick_start], -- 2.39.3