From aae07ec140226b34425822c595822c38eb7f08fe Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Sun, 17 Aug 2025 02:50:54 +0200 Subject: [PATCH] Turn connection messages into another DB field auto-sending messages. --- ircplom/client.py | 9 ++++----- ircplom/client_tui.py | 3 +++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ircplom/client.py b/ircplom/client.py index 834104c..036430f 100644 --- a/ircplom/client.py +++ b/ircplom/client.py @@ -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 diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index cfe7ed4..ce5961f 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -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: -- 2.30.2