From: Christian Heller Date: Tue, 2 Sep 2025 08:47:42 +0000 (+0200) Subject: For channel residents show nicknames or entire masks rather than IDs. X-Git-Url: https://plomlompom.com/repos/day?a=commitdiff_plain;h=59a150d7e6a882e8abd364bd0faa0f4da3b48dc4;p=ircplom For channel residents show nicknames or entire masks rather than IDs. --- diff --git a/ircplom/client.py b/ircplom/client.py index b04c4c9..7e6b14f 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -250,6 +250,9 @@ class NickUserHost: user: str = '?' host: str = '?' + def __str__(self) -> str: + return f'{self.nick}!{self.user}@{self.host}' + @dataclass class ServerCapability: @@ -335,9 +338,6 @@ class _Channel: class _NickUserHost(NickUserHost): - def __str__(self) -> str: - return f'{self.nick}!{self.user}@{self.host}' - def __eq__(self, other) -> bool: if not isinstance(other, NickUserHost): return False diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index 6f42c45..2961f6e 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -192,18 +192,16 @@ class _UpdatingChannel(_UpdatingNode): def set_and_check_for_change(self, update: _Update ) -> Optional[tuple[LogScope, Any]]: - def fmt_ids(user_ids: tuple[str, ...]) -> str: - return ', '.join(user_ids) if update.path == ('user_ids',): assert isinstance(update.value, tuple) - d: dict[str, str] = {} + d: dict[str, tuple[str, ...]] = {} if not self.user_ids: - d['residents'] = fmt_ids(update.value) + d['nicks:residents'] = tuple(update.value) else: - d['joining'] = fmt_ids(tuple(id_ for id_ in update.value - if id_ not in self.user_ids)) - d['parting'] = fmt_ids(tuple(id_ for id_ in self.user_ids - if id_ not in update.value)) + d['nuhs:joining'] = tuple(id_ for id_ in update.value + if id_ not in self.user_ids) + d['nuhs:parting'] = tuple(id_ for id_ in self.user_ids + if id_ not in update.value) if super().set_and_check_for_change(update): return (self._scope(update.path), d) return None @@ -296,6 +294,14 @@ class _ClientWindowsManager: self.log(f'{log_path} cleared', **log_kwargs) elif isinstance(value, dict): for verb, item in [(k, v) for k, v in value.items() if v]: + toks = verb.split(':', maxsplit=1) + verb = toks[-1] + transform = toks[0] if len(toks) > 1 else '' + if transform in {'nicks', 'nuhs'}: + nuhs = (self.db.users[id_] for id_ in item) + item = ', '.join([ + (str(nuh) if transform == 'nuhs' else nuh.nick) + for nuh in nuhs]) self.log(f'{verb}: {item}', **log_kwargs) else: announcement = f'{log_path} set to:'