From: Christian Heller Date: Fri, 5 Sep 2025 12:45:22 +0000 (+0200) Subject: Simplify _NickUserHost comparisons. X-Git-Url: https://plomlompom.com/repos/day?a=commitdiff_plain;h=a34b2d43cfa31f01038b00e8df18b4abe881a38a;p=ircplom Simplify _NickUserHost comparisons. --- diff --git a/ircplom/client.py b/ircplom/client.py index e11b1e7..e36f461 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -392,14 +392,6 @@ class _Channel: class _NickUserHost(NickUserHost): - def __eq__(self, other) -> bool: - if not isinstance(other, NickUserHost): - return False - for key in NickUserHost.__annotations__: - if getattr(self, key) != getattr(other, key): - return False - return True - def __setattr__(self, key: str, value: NickUserHost | str) -> None: if key == 'nickuserhost' and isinstance(value, _NickUserHost): for annotated_key in NickUserHost.__annotations__: @@ -714,8 +706,10 @@ class Client(ABC, ClientQueueMixin): if '_verb' not in ret: self._log(f'PLEASE IMPLEMENT HANDLER FOR: {msg.raw}') return - for nickuserhost in ret['_nickuserhosts']: - self.db.userid_for_nickuserhost(nickuserhost, allow_none=True) + for nuh in ret['_nickuserhosts']: # update, ensure identities + if (id_ := self.db.userid_for_nickuserhost(nuh, allow_none=True)): + for ret_name in [k for k in ret if ret[k] is nuh]: + ret[ret_name] = self.db.users[id_] for verb in ('setattr', 'do', 'doafter'): for task, tok_names in [t for t in ret['_tasks'].items() if t[0].verb == verb]: @@ -769,8 +763,7 @@ class Client(ABC, ClientQueueMixin): self.send(IrcMessage('AUTHENTICATE', ('PLAIN',))) else: self.caps.end_negotiation() - elif ret['_verb'] == 'JOIN'\ - and ret['joiner'].nick != self.db.users['me'].nick: + elif ret['_verb'] == 'JOIN' and ret['joiner'] != self.db.users['me']: self.db.channels[ret['channel']].append_nick(ret['joiner']) elif ret['_verb'] == 'NICK': user_id = self.db.userid_for_nickuserhost(ret['named'])