home · contact · privacy
Differentiate (dis-)connection message from debugging on .connection_status content.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 23:33:16 +0000 (01:33 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 19 Sep 2025 23:33:16 +0000 (01:33 +0200)
ircplom/client_tui.py
test.txt

index 3a0d7ed4cd2befd4a815817031e5709c4a57ea0a..8bc3a797fc560f730cafab928ba335f5d9ba4152 100644 (file)
@@ -283,7 +283,14 @@ class _TuiClientDb(_UpdatingNode, SharedClientDbFields):
     motd: tuple[str, ...] = tuple()
     users: _UpdatingDict[_UpdatingUser]
     channels: _UpdatingDict[_UpdatingChannel]
-    log_scopes = {'connection_state': LogScope.ALL}
+
+    def recursive_set_and_report_change(self, update: _Update) -> None:
+        super().recursive_set_and_report_change(update)
+        if update.key == 'connection_state':
+            if update.value == 'connected':
+                update.results += [(LogScope.ALL, [':CONNECTED'])]
+            elif not update.value:
+                update.results += [(LogScope.ALL, [':DISCONNECTED'])]
 
 
 class _ClientWindowsManager:
index 43b9bd34ae9399be9a228f8f7bd24ed07a688dee..3bb10c6aa96802aef6d7956b2a52a783d382c9be 100644 (file)
--- a/test.txt
+++ b/test.txt
@@ -44,6 +44,7 @@
 
 # on /connect init databases, log in new windows
 > /connect foo.bar.baz foo:bar foobarbazquux:baz
+1,2 $ DISCONNECTED
 1,2 $ isupport cleared
 1,2 $ isupport:CHANTYPES set to: [#&]
 1,2 $ isupport:PREFIX set to: [(ov)@+]
@@ -62,6 +63,7 @@
 1,2 $ port set to: [6697]
 1,2 $ connection_state set to: [connecting]
 1,2 $ connection_state set to: [connected]
+1,2 $ CONNECTED
 2 > CAP LS :302
 2 > USER foobarbazquux 0 * :baz
 2 > NICK :foo
 5 $ quits: foo!~foobarbaz@baz.bar.foo: Client Quit
 1,2 $ channels:#testtest:exits:me cleared
 2 < ERROR :Closing link: (~foobarbaz@baz.bar.foo) [Quit: ircplom says bye]
-1,2,3,4,5,6 $ connection_state set to: [Closing link: (~foobarbaz@baz.bar.foo) [Quit: ircplom says bye]]
-1,2,3,4,5,6 $ connection_state set to: []
+1,2 $ connection_state set to: [Closing link: (~foobarbaz@baz.bar.foo) [Quit: ircplom says bye]]
+1,2 $ connection_state set to: []
+1,2,3,4,5,6 $ DISCONNECTED
 1,2 $ isupport cleared
 1,2 $ isupport:CHANTYPES set to: [#&]
 1,2 $ isupport:PREFIX set to: [(ov)@+]
 
 # check that (save TUI tests assuming start on window 0, and no 4 yet) on reconnect, all the same effects can be expected
 > /reconnect
-1,2,3,4,5,6 $ connection_state set to: [connecting]
-1,2,3,4,5,6 $ connection_state set to: [connected]
-repeat 64:147
-repeat 158:338
+repeat 63:65
+1,2,3,4,5,6 $ CONNECTED
+repeat 66:147
+repeat 159:341
 
 > /quit
 0 <