diff --git a/bink.py b/bink.py index 70bf3ad..d63b0ff 100755 --- a/bink.py +++ b/bink.py @@ -142,18 +142,20 @@ class App(): post_user = post["user"] time_seconds = post["time"] / 1_000_000_000 stamp = datetime.datetime.fromtimestamp(time_seconds) - if current_user != post_user and name_re.search(body): - widget_body = [] - index = 0 - for match in name_re.finditer(body): - start, end = match.span() - before = body[index:start] - highlight = body[start:end] - widget_body.append(before) - widget_body.append(("highlight", highlight)) - index = end - widget_body.append(body[index:]) - body = widget_body + if current_user != post_user: + search = name_re.finditer(body) + if search: + widget_body = [] + index = 0 + for match in search: + start, end = match.span() + before = body[index:start] + highlight = body[start:end] + widget_body.append(before) + widget_body.append(("highlight", highlight)) + index = end + widget_body.append(body[index:]) + body = widget_body pile = urwid.Pile([ urwid.Text([("bold", f"~{post_user}"), " @ ", stamp.strftime("%H:%M (%A, %B %d, %Y)")]), urwid.Text(body),