From 358242ba4fb32fb9f7517dba3b41d358195e7126 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 14 Aug 2025 11:52:47 +0200 Subject: [PATCH] Simplify MOTD handling, complefixy ignorance of numerics. --- ircplom/client.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ircplom/client.py b/ircplom/client.py index 358b884..65232c6 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -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': -- 2.30.2