From: Christian Heller Date: Fri, 19 Sep 2025 20:01:20 +0000 (+0200) Subject: Hide nothing from debugging windows, ensure sorted result if update.value is set. X-Git-Url: https://plomlompom.com/repos/booking/pick_tasks?a=commitdiff_plain;h=17426882907ac1950dfd99d14c3186d4753315d8;p=ircplom Hide nothing from debugging windows, ensure sorted result if update.value is set. --- diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index 5c0d942..3a0d7ed 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -8,7 +8,7 @@ from ircplom.tui_base import (BaseTui, PromptWidget, TuiEvent, Window, from ircplom.client import ( AutoAttrMixin, Channel, Client, ClientQueueMixin, Dict, DictItem, IrcConnSetup, LogScope, NewClientEvent, NickUserHost, ServerCapability, - SharedClientDbFields, Topic, User) + SharedClientDbFields, User) CMD_SHORTCUTS['disconnect'] = 'window.disconnect' CMD_SHORTCUTS['join'] = 'window.join' @@ -78,7 +78,10 @@ class _UpdatingNode(AutoAttrMixin): self._set(update.key, update.value) do_report |= True if do_report: - update.results += [(scope, update.value)] + update.results += [(scope, + tuple(sorted(update.value)) + if isinstance(update.value, set) + else update.value)] def _get(self, key: str) -> Any: return getattr(self, key) @@ -212,25 +215,26 @@ class _QueryWindow(_ChatWindow): class _UpdatingChannel(_UpdatingNode, Channel): - log_scopes = {'user_ids': LogScope.CHAT, 'topic': LogScope.CHAT} user_ids: set[str] exits: _UpdatingDict[str] def recursive_set_and_report_change(self, update: _Update) -> None: super().recursive_set_and_report_change(update) - if update.key == 'user_ids': - update.results.clear() - scope = self._scope(update.key) + if update.key == 'topic': + msg = f':{self.topic.who} set topic: {self.topic.what}' + update.results += [(LogScope.CHAT, [msg])] + elif update.key == 'user_ids': if not update.old_value: nicks = [] for id_ in sorted(update.value): nicks += [f'NICK:{id_}', ':, '] nicks.pop() - update.results += [(scope, [':residents: '] + nicks)] + update.results += [(LogScope.CHAT, [':residents: '] + nicks)] else: for id_ in (id_ for id_ in update.value if id_ not in update.old_value): - update.results += [(scope, [':joining: ', f'NUH:{id_}'])] + update.results += [(LogScope.CHAT, + [':joining: ', f'NUH:{id_}'])] for id_ in (id_ for id_ in update.old_value if id_ not in update.value): quits = self.exits[id_][0] == 'Q' @@ -239,7 +243,7 @@ class _UpdatingChannel(_UpdatingNode, Channel): f'NUH:{id_}'] if part_msg: exit_msg += [f':: {part_msg}'] - update.results += [(scope, exit_msg)] + update.results += [(LogScope.CHAT, exit_msg)] class _UpdatingUser(_UpdatingNode, User): @@ -316,7 +320,7 @@ class _ClientWindowsManager: return win return self._new_win(scope=scope, chatname=chatname) - def windows_for_userid(self, user_id: str, w_channels = True + def windows_for_userid(self, user_id: str, w_channels=True ) -> list[_ClientWindow]: 'Return windows interacting with userid (all if "me").' if user_id == 'me': @@ -358,10 +362,7 @@ class _ClientWindowsManager: if scope in {LogScope.CHAT, LogScope.USER, LogScope.USER_NO_CHANNELS}: log_kwargs |= {'target': update.full_path[1]} - if isinstance(result, Topic): - self.log(f'{result.who} set topic: {result.what}', - **log_kwargs) - elif isinstance(result, list): + if isinstance(result, list): msg = '' for item in result: transform, content = item.split(':', maxsplit=1) diff --git a/test.txt b/test.txt index 2573a63..2443df5 100644 --- a/test.txt +++ b/test.txt @@ -190,11 +190,15 @@ 2 < :foo.bar.baz 332 foo #test :foo bar baz 1,2 $ channels:#test:exits cleared 2 < :foo.bar.baz 333 foo #test bar!~bar@bar.bar 1234567890 +1,2 $ 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 2 < :foo.bar.baz 353 foo @ #test :foo @bar 1,2 $ users:1:nick set to: [?] 1,2 $ users:1:nick set to: [bar] 2 < :foo.bar.baz 366 foo #test :End of /NAMES list. +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 +1,2 $ me 4 $ residents: bar, foo # deliver PRIVMSG to channel window, update sender's user+host from metadata @@ -206,6 +210,7 @@ # check _changing_ TOPIC message is communicated to channel window 2 < :bar!~bar@bar.bar TOPIC #test :foo bar baz 2 < :bar!~bar@bar.bar TOPIC #test :abc def ghi +1,2 $ channels:#test:topic set to: [Topic(what='abc def ghi', who=NickUserHost(nick='bar', user='~bar', host='bar.bar'))] 4 $ bar!~bar@bar.bar set topic: abc def ghi # process non-self channel JOIN @@ -214,6 +219,10 @@ 1,2 $ users:2:nick set to: [baz] 1,2 $ users:2:user set to: [~baz] 1,2 $ users:2:host set to: [baz.baz] +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 +1,2 $ 2 +1,2 $ me 4 $ joining: baz!~baz@baz.baz # handle non-self renaming @@ -224,6 +233,9 @@ # handle non-self PART 2 < :bazbaz!~baz@baz.baz PART :#test 1,2 $ channels:#test:exits:2 set to: [P] +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 +1,2 $ me 4 $ parts: bazbaz!~baz@baz.baz 1,2 $ channels:#test:exits:2 cleared 1,2 $ users:2 cleared @@ -234,12 +246,19 @@ 1,2 $ users:3:nick set to: [bazbaz] 1,2 $ users:3:user set to: [~baz] 1,2 $ users:3:host set to: [baz.baz] +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 +1,2 $ 3 +1,2 $ me 4 $ joining: bazbaz!~baz@baz.baz # handle non-self QUIT 2 < :bazbaz!~baz@baz.baz QUIT :Client Quit , $ bazbaz!~baz@baz.baz quits: Client Quit 1,2 $ channels:#test:exits:3 set to: [QClient Quit] +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 +1,2 $ me 4 $ quits: bazbaz!~baz@baz.baz: Client Quit 1,2 $ channels:#test:exits:3 cleared 1,2 $ users:3 cleared @@ -247,6 +266,8 @@ # handle self-PART: clear channel, and its squatters 2 < :foo!~foobarbaz@baz.bar.foo PART :#test 1,2 $ channels:#test:exits:me set to: [P] +1,2 $ channels:#test:user_ids set to: +1,2 $ 1 4 $ parts: foo!~foobarbaz@baz.bar.foo 1,2 $ channels:#test:exits:me cleared 1,2 $ channels:#test cleared @@ -277,7 +298,7 @@ 1,2,3,4 $ connection_state set to: [connecting] 1,2,3,4 $ connection_state set to: [connected] repeat 64:147 -repeat 158:273 +repeat 158:295 > /quit 0 <