home · contact · privacy
Move TOPIC message parsing into EXPECTATIONS (with small task parsing hack to make...
authorChristian Heller <c.heller@plomlompom.de>
Wed, 3 Sep 2025 12:53:51 +0000 (14:53 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 3 Sep 2025 12:53:51 +0000 (14:53 +0200)
ircplom/client.py
ircplom/msg_parse_expectations.py

index 6bd924dd01b19ab455f53ff209eb27a279b28bf0..1219a64ff3caf1051d2aa3cb7ba1f3316991b74a 100644 (file)
@@ -763,7 +763,10 @@ class Client(ABC, ClientQueueMixin):
                     target = target.users[target_name]
                 elif target_name == 'topic':
                     target = target.channels[ret['CHAN']].topic
-                for tok_name in tok_names:
+                for tok_name in sorted(tok_names):
+                    # NB: alphabetical sorting of tok_names purely as a hack
+                    # to ensure any setattr_topic:what be processed before any
+                    # setattr_topic:who, i.e. for parsing TOPIC message, FIXME
                     setattr(target, tok_name, ret[tok_name])
         if ret['verb'] == '005':   # RPL_ISUPPORT
             for item in ret['isupport']:
@@ -842,9 +845,6 @@ class Client(ABC, ClientQueueMixin):
                 ch.remove_nick(ret['quitter'])
                 self._log(f'{ret["quitter"]} quits: {ret["message"]}',
                           LogScope.CHAT, target=ch_name)
-        elif ret['verb'] == 'TOPIC':
-            self._db.channels[ret['channel']].topic.what = ret['topic']
-            self._db.channels[ret['channel']].topic.who = ret['author']
 
 
 ClientsDb = dict[str, Client]
index 86c7715a430648016208eb37501228b393273016..918ee47532ecfc038b5b40fced3680e1d1a291c5 100644 (file)
@@ -291,10 +291,10 @@ MSG_EXPECTATIONS += [
                          'PART',
                          ((MsgTok.CHANNEL, ':channel'),
                           (MsgTok.ANY, ':message'))),
-    _MsgParseExpectation((MsgTok.NICK_USER_HOST, ':author'),
+    _MsgParseExpectation((MsgTok.NICK_USER_HOST, 'setattr_topic:who'),
                          'TOPIC',
-                         ((MsgTok.CHANNEL, ':channel'),
-                          (MsgTok.ANY, ':topic'))),
+                         ((MsgTok.CHANNEL, ':CHAN'),
+                          (MsgTok.ANY, 'setattr_topic:what'))),
 ]
 
 # messaging