Change AutoWho regex to match partial hashes

This commit is contained in:
zenith 2026-05-14 12:43:48 -04:00
parent 6e0d8b9f4c
commit 1c117507c4
2 changed files with 3 additions and 3 deletions

View file

@ -104,7 +104,7 @@ def _msg_id():
# greedy .+ intentionally captures nicks containing parens like "user (alt) (deadbeefcafe)"
_WHO_ENTRY_RE = re.compile(
r"(?:^|,\s)"
r"(?:(?P<nick>.+?)\s\((?P<np>[0-9a-fA-F]+)\)|(?P<bh>[0-9a-fA-F]+))"
r"(?:(?P<bh>[0-9a-fA-F]{32})|(?P<nick>.+?)\s\((?P<np>[0-9a-fA-F]{12})\))"
r"(?=,\s|$)"
)
@ -279,7 +279,7 @@ class RRCHub:
nick = self.nicks.get(ph)
if nick:
return nick
return ph.hex()[:10]
return ph.hex()[:12]
def mark_read(self, room):
r = self._normalize_room(room)

View file

@ -137,7 +137,7 @@ def _body_markup(body, body_attr="body_text", own_nick=None):
return out, has_links
def _short_hash(b, n=10):
def _short_hash(b, n=12):
if isinstance(b, (bytes, bytearray)):
return bytes(b).hex()[:n]
return "?"