From: Christian Heller Date: Wed, 3 Sep 2025 12:53:51 +0000 (+0200) Subject: Move TOPIC message parsing into EXPECTATIONS (with small task parsing hack to make... X-Git-Url: https://plomlompom.com/repos/day?a=commitdiff_plain;h=7f753ddd6d35a9e730511e475817570b08ff8039;p=ircplom Move TOPIC message parsing into EXPECTATIONS (with small task parsing hack to make it work). --- diff --git a/ircplom/client.py b/ircplom/client.py index 6bd924d..1219a64 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -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] diff --git a/ircplom/msg_parse_expectations.py b/ircplom/msg_parse_expectations.py index 86c7715..918ee47 100644 --- a/ircplom/msg_parse_expectations.py +++ b/ircplom/msg_parse_expectations.py @@ -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