home · contact · privacy
Turn connection messages into another DB field auto-sending messages. master
authorChristian Heller <c.heller@plomlompom.de>
Sun, 17 Aug 2025 00:50:54 +0000 (02:50 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 17 Aug 2025 00:50:54 +0000 (02:50 +0200)
ircplom/client.py
ircplom/client_tui.py

index 834104c0190450fa0e86bfdb7af5f18a62e3acbc..036430fc7b9c0ea34630c8be408585949ee8f7a8 100644 (file)
@@ -313,6 +313,7 @@ class _ChannelDb(_Db):
 
 
 class _ClientDb(_Db, IrcConnSetup):
+    connection_state: str
     client_host: str
     nickname_confirmed: bool
     user_modes: str
@@ -366,7 +367,7 @@ class Client(ABC, ClientQueueMixin):
             except Exception as e:  # pylint: disable=broad-exception-caught
                 self._put(ExceptionEvent(CrashingException(e)))
 
-        self._log('connecting …')
+        self._db.connection_state = 'connecting'
         Thread(target=connect, daemon=True, args=(self,)).start()
 
     @abstractmethod
@@ -375,9 +376,7 @@ class Client(ABC, ClientQueueMixin):
 
     def _on_connect(self) -> None:
         assert self.conn is not None
-        self._log('connected to server (SSL: '
-                  f'{"yes" if self.conn.ssl else "no"})',
-                  scope=LogScope.ALL)
+        self._db.connection_state = 'connected'
         self._caps.start_negotation()
         self.send(IrcMessage(verb='USER',
                              params=(getuser(), '0', '*', self._db.realname)))
@@ -408,7 +407,7 @@ class Client(ABC, ClientQueueMixin):
 
     def close(self) -> None:
         'Close both recv Loop and socket.'
-        self._log(msg='disconnecting from server …', scope=LogScope.ALL)
+        self._db.connection_state = 'disconnected'
         if self.conn:
             self.conn.close()
         self.conn = None
index cfe7ed49223943325f752568f91fac910cbafad8..ce5961f7483e62b0ebab60bf5990e81a4f4c8ace 100644 (file)
@@ -144,6 +144,7 @@ class _ChannelDb(_Db):
 class _TuiClientDb(_Db, IrcConnSetup):
     caps: tuple[str]
     client_host: str
+    connection_state: str
     isupports: tuple[str]
     motd: tuple[str]
     nickname_confirmed: bool
@@ -214,6 +215,8 @@ class _ClientWindowsManager:
             db = self._db.chan(chan_name)
             scope = LogScope.CHAT
             log_kwargs |= {'channel': chan_name}
+        elif key == 'connection_state':
+            scope = LogScope.ALL
         if not db.set_and_check_for_change(key, value):
             return False
         if key != CLEAR_WORD: