home · contact · privacy
Add CONN_ALERT event type to alert specifically in connection window.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 5 Jun 2025 19:05:46 +0000 (21:05 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 5 Jun 2025 19:05:46 +0000 (21:05 +0200)
ircplom.py

index 54a8599f3c7f3a2ba7d00f7b699de541ab25dfd8..203c8b2ceeae1d801275fa9a68d558315dfd394f 100755 (executable)
@@ -213,8 +213,8 @@ class IrcConnection:
     def _write_line(self, line: str) -> None:
         'Send line-separator-delimited message over socket.'
         if not self._assumed_open:
-            self._q_to_main.eput('ALERT',
-                                 'cannot send, assuming connection closed')
+            self._broadcast('CONN_ALERT',
+                            'cannot send, assuming connection closed')
             return
         self._socket.sendall(line.encode('utf-8') + IRCSPEC_LINE_SEPARATOR)
 
@@ -622,6 +622,16 @@ class TuiLoop(Loop):
         elif event.type_ == 'ALERT':
             self.window.log.append(f'{event.type_} {event.payload}')
             self.window.log.draw()
+        elif event.type_ in {'RECV', 'SEND', 'CONN_ALERT'}:
+            conn_win = self._conn_windows[event.payload[0]]
+            if event.type_ == 'CONN_ALERT':
+                msg = f'ALERT {event.payload[1]}'
+            else:
+                msg = (('<-' if event.type_ == 'RECV' else '->')
+                       + event.payload[1].raw)
+            conn_win.log.append(msg)
+            if conn_win == self.window:
+                self.window.log.draw()
         elif event.type_ in {'RECV', 'SEND'}:
             conn_win = self._conn_windows[event.payload[0]]
             prefix = '<-' if event.type_ == 'RECV' else '->'