home · contact · privacy
Fix disconnect command still expecting single hardcoded server connection.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 5 Jun 2025 14:00:00 +0000 (16:00 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 5 Jun 2025 14:00:00 +0000 (16:00 +0200)
ircplom.py

index 83ff8d15428dc48240fe513cf3e7fa3b8357ab84..16c3ca7036d4fbe2f8f3736ec85f33323c49e9db 100755 (executable)
@@ -662,9 +662,15 @@ class TuiLoop(Loop):
         self.broadcast('INIT_CONNECTION',
                        (hostname, (username, nickname, realname)))
 
-    def cmd__disconnect(self, quit_msg: str = 'ircplom says bye') -> None:
-        'Send QUIT command to server.'
-        self.broadcast('SEND', IrcMessage('QUIT', [quit_msg]))
+    def cmd__disconnect(self,
+                        quit_msg: str = 'ircplom says bye'
+                        ) -> Optional[str]:
+        'Send QUIT command to server if in connection window.'
+        if self.window not in self._conn_windows:
+            return 'what to disconnect from? (not in connection window!)'
+        self.broadcast('SEND', (self._conn_windows.index(self.window),
+                                IrcMessage('QUIT', [quit_msg])))
+        return None
 
     def cmd__prompt_enter(self) -> None:
         'Get prompt content from .window.prompt.enter, parse to & run command.'