home · contact · privacy
Add more numerics handlers, alarm on missing ones. master
authorChristian Heller <c.heller@plomlompom.de>
Wed, 13 Aug 2025 08:46:44 +0000 (10:46 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 13 Aug 2025 08:46:44 +0000 (10:46 +0200)
ircplom/client.py
ircplom/client_tui.py

index c62608b84c628113e7348fd7d16a1ebeb75d7193..49006edd22d846bdda4ed1be6efa0d5075488616 100644 (file)
@@ -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
index 60fd1aa0940cd7da7c5dbe023abf0a9966fea709..40d012f4ca90c1cfcb1e1fb0e35a28a6aebed6bd 100644 (file)
@@ -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)