home · contact · privacy
Simplify MOTD handling, complefixy ignorance of numerics.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 14 Aug 2025 09:52:47 +0000 (11:52 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 14 Aug 2025 09:52:47 +0000 (11:52 +0200)
ircplom/client.py

index 358b884cd507eebcdc88ac035197e5466d0e1acd..65232c6f870754f4295a0fcbd1a7561a2fcaa6fc 100644 (file)
@@ -14,9 +14,12 @@ from ircplom.irc_conn import (BaseIrcConnection, IrcConnAbortException,
 
 ClientsDb = dict[str, 'Client']
 _NAMES_DESIRED_SERVER_CAPS = ('server-time', 'account-tag', 'sasl')
-_NUMERIC_RANGES_TO_IGNORE = ((2, 4),  # irrelevant login info
-                             (251, 255),  # more of the same, LUSERS-specific
-                             (265, 266))  # more LUSERS stuff
+_NUMERICS_TO_IGNORE = (  # tuples define (inclusive) ranges
+    (2, 4),      # nothing in this login info we're interested in
+    (251, 255),  # same
+    (265, 266),  # same
+    375,  # RPL_MOTDSTART already implied to us by first appearance of 372
+)
 
 
 class LogScope(Enum):
@@ -328,8 +331,11 @@ class Client(ABC, ClientQueueMixin):
             self._update_db('isupports', None, True)
         self._prev_verb = msg.verb
         numerics_to_ignore = []
-        for min_, max_ in _NUMERIC_RANGES_TO_IGNORE:
-            numerics_to_ignore += list(range(min_, max_ + 1))
+        for item in _NUMERICS_TO_IGNORE:
+            if isinstance(item, tuple):
+                numerics_to_ignore += list(range(item[0], item[1] + 1))
+            else:
+                numerics_to_ignore += [item]
         if msg.verb.isdigit() and int(msg.verb) in numerics_to_ignore:
             return
         match msg.verb:
@@ -338,14 +344,10 @@ class Client(ABC, ClientQueueMixin):
             case '005':
                 for param in msg.params[1:-1]:
                     self._db.append('isupports', param)
-            case '375':
-                self._db.set('motd', [], False)
-            case '372':
+            case '372':  # RPL_MOTD
                 self._db.append('motd', msg.params[-1])
-            case '376':
-                self._db.set('motd', None, confirm=True)
-                for line in self._db.motd:
-                    self._log(line, as_notice=True)
+            case '376':  # RPL_ENDOFMOTD
+                self._update_db('motd', None, True)
             case 'PING':
                 self.send(IrcMessage(verb='PONG', params=(msg.params[0],)))
             case 'ERROR':