user: str = '?'
host: str = '?'
+ def __str__(self) -> str:
+ return f'{self.nick}!{self.user}@{self.host}'
+
@dataclass
class ServerCapability:
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
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
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:'