From c53a06962b2b6db7e3cf6cb7709a94f5a7914698 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 28 Sep 2025 13:24:31 +0200 Subject: [PATCH] Ensure 332 doesn't affect users DB, since those identities are ancient. --- src/ircplom/msg_parse_expectations.py | 11 ++++++++--- src/tests/test.txt | 19 +++++++++++++------ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/ircplom/msg_parse_expectations.py b/src/ircplom/msg_parse_expectations.py index 84478b4..e5605b9 100644 --- a/src/ircplom/msg_parse_expectations.py +++ b/src/ircplom/msg_parse_expectations.py @@ -116,11 +116,15 @@ class _MsgParseExpectation: or ex_tok.type_ not in parsers) else parsers[ex_tok.type_](cmp_tok)) if ex_tok.type_ is _MsgTok.NICK_USER_HOST: - nickuserhosts += [value] + if not (ex_tok.code and + 'skipnuh' in [cmd.verb + for cmd in ex_tok.code.commands]): + nickuserhosts += [value] if ex_tok.code: parsed[ex_tok.code.title] = value singled_tasks += [(cmd, ex_tok.code.title) - for cmd in ex_tok.code.commands] + for cmd in ex_tok.code.commands + if cmd.verb != 'skipnuh'] for code in self.bonus_tasks: singled_tasks += [(cmd, code.title) for cmd in code.commands] tasks: dict[_Command, list[str]] = {} @@ -437,7 +441,8 @@ MSG_EXPECTATIONS: list[_MsgParseExpectation] = [ _MsgTok.SERVER, ((_MsgTok.NICKNAME, 'setattr_db.users.me:nick'), (_MsgTok.CHANNEL, ':CHAN'), - (_MsgTok.NICK_USER_HOST, 'setattr_db.channels.CHAN.topic:who'), + (_MsgTok.NICK_USER_HOST, + 'skipnuh_,setattr_db.channels.CHAN.topic:who'), (_MsgTok.ANY, ':timestamp')), bonus_tasks=('doafter_db.channels.CHAN.topic:complete',)), diff --git a/src/tests/test.txt b/src/tests/test.txt index acc8d08..0d7168e 100644 --- a/src/tests/test.txt +++ b/src/tests/test.txt @@ -170,16 +170,16 @@ 0:1 < :*.?.net 432 foo1 @foo :Erroneous nickname 1 !$ nickname refused for bad format -# join channel, collect topic, residents; update me:user from JOIN message +# join channel, collect topic, residents; update me:user from JOIN message; ensure topic.who not affecting users DB > /join #test 1 > JOIN :#test 0:1 < :foo1!~foobarbaz@baz.bar.foo JOIN #test 1 $ users:me:user set to: [~foobarbaz] 0:1 < :foo.bar.baz 332 foo1 #test :foo bar baz 1 $ channels:#test:exits cleared -0:1 < :foo.bar.baz 333 foo1 #test bar!~bar@bar.bar 1234567890 -1 $ channels:#test:topic set to: [Topic(what='foo bar baz', who=NickUserHost(nick='bar', user='~bar', host='bar.bar'))] -4 $ bar!~bar@bar.bar set topic: foo bar baz +0:1 < :foo.bar.baz 333 foo1 #test bar!~bar@OLD.bar.bar 1234567890 +1 $ channels:#test:topic set to: [Topic(what='foo bar baz', who=NickUserHost(nick='bar', user='~bar', host='OLD.bar.bar'))] +4 $ bar!~bar@OLD.bar.bar set topic: foo bar baz 0:1 < :foo.bar.baz 353 foo1 @ #test :foo1 @bar 1 $ users:1:nick set to: [?] 1 $ users:1:nick set to: [bar] @@ -195,7 +195,10 @@ 1 $ users:1:host set to: [bar.bar] 4 < [bar] hi there -# check _changing_ TOPIC message is communicated to channel window +# check _changing_ TOPIC message is communicated to channel window, as long as either content or who change +0:1 < :bar!~bar@bar.bar TOPIC #test :foo bar baz +1 $ channels:#test:topic set to: [Topic(what='foo bar baz', who=NickUserHost(nick='bar', user='~bar', host='bar.bar'))] +4 $ bar!~bar@bar.bar set topic: foo bar baz 0:1 < :bar!~bar@bar.bar TOPIC #test :foo bar baz 0:1 < :bar!~bar@bar.bar TOPIC #test :abc def ghi 1 $ channels:#test:topic set to: [Topic(what='abc def ghi', who=NickUserHost(nick='bar', user='~bar', host='bar.bar'))] @@ -217,8 +220,12 @@ > /join #testtest 1 > JOIN :#testtest 0:1 < :foo1!~foobarbaz@baz.bar.foo JOIN #testtest -0:1 < :foo.bar.baz 353 foo1 @ #testtest :foo1 baz +0:1 < :foo.bar.baz 332 foo1 #testtest :baz bar foo 1 $ channels:#testtest:exits cleared +0:1 < :foo.bar.baz 333 foo1 #testtest bar!~bar@OLD.bar.bar 1234567890 +1 $ channels:#testtest:topic set to: [Topic(what='baz bar foo', who=NickUserHost(nick='bar', user='~bar', host='OLD.bar.bar'))] +5 $ bar!~bar@OLD.bar.bar set topic: baz bar foo +0:1 < :foo.bar.baz 353 foo1 @ #testtest :foo1 baz 0:1 < :foo.bar.baz 366 foo1 #testtest :End of /NAMES list. 1 $ channels:#testtest:user_ids set to: 1 $ 2 -- 2.30.2