From 0e90ac40e734ab4b3efd368df49f9488220ea5e9 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 30 Sep 2025 19:38:11 +0200 Subject: [PATCH] For MsgParseExpectation do/doafter tasks, use title as argument rather than callable path node. --- src/ircplom/client.py | 10 ++++------ src/ircplom/msg_parse_expectations.py | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/ircplom/client.py b/src/ircplom/client.py index 6569f8f..8c65d1e 100644 --- a/src/ircplom/client.py +++ b/src/ircplom/client.py @@ -922,7 +922,7 @@ class Client(ABC, ClientQueueMixin): for verb in ('setattr', 'do', 'doafter'): for task, tok_names in [t for t in ret['_tasks'].items() if t[0].verb == verb]: - node = self + node: Any = self for step in task.path: key = ret[step] if step.isupper() else step node = (node[key] if isinstance(node, Dict) @@ -931,8 +931,10 @@ class Client(ABC, ClientQueueMixin): for tok_name in tok_names: if task.verb == 'setattr': setattr(node, tok_name, ret[tok_name]) + elif tok_name: + node(ret[tok_name]) else: - getattr(node, tok_name)() + node() if ret['_verb'] == '001': # RPL_WELCOME for name in self._autojoins: self.send('JOIN', name) @@ -944,10 +946,6 @@ class Client(ABC, ClientQueueMixin): else: key, data = _Dict.key_val_from_eq_str(item) self.db.isupport[key] = data - elif ret['_verb'] == '353': # RPL_NAMREPLY - self.db.channels[ret['channel']].add_from_namreply(ret['names']) - elif ret['_verb'] == '372': # RPL_MOTD - self.db.motd.append(ret['line']) elif ret['_verb'] == '401': # ERR_NOSUCHNICK raise TargetUserOffline(ret['missing']) elif ret['_verb'] == '432': # ERR_ERRONEOUSNICKNAME diff --git a/src/ircplom/msg_parse_expectations.py b/src/ircplom/msg_parse_expectations.py index 461b85e..4027fd3 100644 --- a/src/ircplom/msg_parse_expectations.py +++ b/src/ircplom/msg_parse_expectations.py @@ -253,14 +253,14 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ '372', # RPL_MOTD _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), - (_MsgTok.ANY, ':line'))), + (_MsgTok.ANY, 'do_db.motd.append:line'))), _MsgParseExpectation( '376', # RPL_ENDOFMOTD _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), _MsgTok.ANY), # comment - bonus_tasks=('do_db.motd:complete',)), + bonus_tasks=('do_db.motd.complete:',)), _MsgParseExpectation( '396', # RPL_VISIBLEHOST @@ -284,14 +284,14 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), (_MsgTok.ANY, 'setattr_db:sasl_auth_state')), - bonus_tasks=('do_caps:end_negotiation',)), + bonus_tasks=('do_caps.end_negotiation:',)), _MsgParseExpectation( '904', # ERR_SASLFAIL _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), (_MsgTok.ANY, 'setattr_db:sasl_auth_state')), - bonus_tasks=('do_caps:end_negotiation',)), + bonus_tasks=('do_caps.end_negotiation:',)), _MsgParseExpectation( 'AUTHENTICATE', @@ -444,22 +444,22 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ (_MsgTok.NICK_USER_HOST, 'skipnuh_,setattr_db.channels.CHAN.topic:who'), (_MsgTok.ANY, ':timestamp')), - bonus_tasks=('doafter_db.channels.CHAN.topic:complete',)), + bonus_tasks=('doafter_db.channels.CHAN.topic.complete:',)), _MsgParseExpectation( '353', # RPL_NAMREPLY _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), '@', - (_MsgTok.CHANNEL, ':channel'), - (_MsgTok.LIST, ':names'))), + (_MsgTok.CHANNEL, ':CHANNEL'), + (_MsgTok.LIST, 'do_db.channels.CHANNEL.add_from_namreply:names'))), _MsgParseExpectation( '353', # RPL_NAMREPLY _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), '=', - (_MsgTok.CHANNEL, ':channel'), - (_MsgTok.LIST, ':names'))), + (_MsgTok.CHANNEL, ':CHANNEL'), + (_MsgTok.LIST, 'do_db.channels.CHANNEL.add_from_namreply:names'))), _MsgParseExpectation( '366', # RPL_ENDOFNAMES @@ -467,7 +467,7 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), (_MsgTok.CHANNEL, ':CHAN'), _MsgTok.ANY), # comment - bonus_tasks=('doafter_db.channels.CHAN.user_ids:complete',)), + bonus_tasks=('doafter_db.channels.CHAN.user_ids.complete:',)), _MsgParseExpectation( 'JOIN', @@ -533,7 +533,7 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ 'ERROR', _MsgTok.NONE, ((_MsgTok.ANY, 'setattr_db:connection_state'),), - bonus_tasks=('doafter_:close',)), + bonus_tasks=('doafter_close:',)), _MsgParseExpectation( 'PING', @@ -564,7 +564,7 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ (_MsgTok.NICK_USER_HOST, 'setattr_db.channels.CHAN.topic:who'), ((_MsgTok.CHANNEL, ':CHAN'), (_MsgTok.ANY, 'setattr_db.channels.CHAN.topic:what')), - bonus_tasks=('doafter_db.channels.CHAN.topic:complete',)), + bonus_tasks=('doafter_db.channels.CHAN.topic.complete:',)), _MsgParseExpectation( 'QUIT', -- 2.30.2