From: Christian Heller Date: Wed, 13 Aug 2025 08:46:44 +0000 (+0200) Subject: Add more numerics handlers, alarm on missing ones. X-Git-Url: https://plomlompom.com/repos/booking/%7B%7B%20web_path%20%7D%7D/decks/static/foo.html?a=commitdiff_plain;h=HEAD;p=ircplom Add more numerics handlers, alarm on missing ones. --- diff --git a/ircplom/client.py b/ircplom/client.py index c62608b..49006ed 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -306,6 +306,20 @@ class Client(ABC, ClientQueueMixin): 'Log msg.raw, then process incoming msg into appropriate client steps.' self._log(msg.raw, scope=LogScope.RAW, out=False) match msg.verb: + case '001' | '002' | '003' | '004': + pass # explicitly ignored verbs/numerics + case '375': + self._db.set('motd', [], False) + case '372': + motd = self._db.get_force('motd')[0] + assert isinstance(motd, list) + motd += [msg.params[-1]] + case '376': + motd = self._db.get_force('motd')[0] + assert isinstance(motd, list) + self._db.set('motd', motd, True) + for line in self._db.motd: + self._log(line, as_notice=True) case 'PING': self.send(IrcMessage(verb='PONG', params=(msg.params[0],))) case 'ERROR': @@ -315,7 +329,7 @@ class Client(ABC, ClientQueueMixin): case 'NOTICE' | 'PRIVMSG': scope = LogScope.CHAT if '!' in msg.source else LogScope.SERVER self._log(msg.params[-1], scope=scope, channel=msg.params[0], - out=False, is_notice=msg.verb == 'NOTICE', + out=False, as_notice=msg.verb == 'NOTICE', sender=msg.nick_from_source) case 'PRIVMSG': self._log(msg.params[-1], scope=LogScope.CHAT, out=False, @@ -345,6 +359,8 @@ class Client(ABC, ClientQueueMixin): user, channel = msg.nick_from_source, msg.params[-1] self._log(f'{user} {msg.verb.lower()}s {channel}', scope=LogScope.CHAT, channel=channel) + case _: + self._log(f'PLEASE IMPLEMENT HANDLER FOR: {msg.raw}') @dataclass diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index 60fd1aa..40d012f 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -160,10 +160,9 @@ class _ClientWindowsManager: if 'out' in kwargs and scope != LogScope.SERVER: first_char = _LOG_PREFIX_OUT if kwargs['out'] else _LOG_PREFIX_IN if scope == LogScope.CHAT: - nickname = (self._db.nickname if kwargs['out'] - else kwargs['sender']) - sender_label = f' [{nickname}]' - if kwargs.get('is_notice', False): + sender_label = ' [' + (self._db.nickname if kwargs['out'] + else kwargs['sender']) + ']' + if kwargs.get('as_notice', False): first_char *= 3 prefix = f'{first_char}{sender_label}' self._tui_log(msg, scope=scope, prefix=prefix, **kwargs)