only show mentions from other users

This commit is contained in:
nebula 2025-05-04 05:12:02 +00:00
parent 4072e2b7e5
commit 26eec98680

View File

@ -107,7 +107,8 @@ if len(sys.argv) > 1:
import urwid
name_re = compile(f"(?<!\w)[@~]?{getpwuid(os.getuid()).pw_name}")
current_user = getpwuid(os.getuid()).pw_name
name_re = compile(f"(?<!\w)[@~]?{current_user}")
footer = "[c]reate [r]efresh [q]uit | scrolling: arrows, j/k, space, page up/down, ctrl-d/ctrl-u"
attrmap = [
("bold", "default,bold", "default"),
@ -137,9 +138,10 @@ class App():
def post_to_widget(self, post):
body = post["body"]
post_user = post["user"]
time_seconds = post["time"] / 1_000_000_000
stamp = datetime.datetime.fromtimestamp(time_seconds)
if name_re.search(body):
if current_user != post_user and name_re.search(body):
widget_body = []
index = 0
for match in name_re.finditer(body):
@ -152,11 +154,10 @@ class App():
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([("bold", f"~{post_user}"), " @ ", stamp.strftime("%H:%M (%A, %B %d, %Y)")]),
urwid.Text(body),
urwid.Divider()
])
# pile.post_time = post["time"]
return pile
def write_with_editor(self):