From: Christian Heller Date: Sun, 9 Nov 2025 23:40:14 +0000 (+0100) Subject: Catch /join, /part to check if possible via current in/outside-channel status. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/calendar?a=commitdiff_plain;h=e17da4f4bf8600b35a13b01662d679b9b33c6334;p=ircplom Catch /join, /part to check if possible via current in/outside-channel status. --- diff --git a/src/ircplom/client_tui.py b/src/ircplom/client_tui.py index f44fdc3..90708bb 100644 --- a/src/ircplom/client_tui.py +++ b/src/ircplom/client_tui.py @@ -101,7 +101,7 @@ class _ClientWindow(Window, ClientQueueMixin): def cmd__join(self, channel: str) -> None: 'Attempt joining a channel.' - self._send_msg('JOIN', (channel,)) + self._client_trigger('join', chan_name=channel) def cmd__privmsg(self, target: str, msg: str) -> None: 'Send chat message msg to target.' @@ -176,7 +176,7 @@ class _ChannelWindow(_ChatWindow): def cmd__part(self) -> None: 'Attempt parting channel.' - self._send_msg('PART', (self.chatname,)) + self._client_trigger('part', chan_name=self.chatname,) class _QueryWindow(_ChatWindow): @@ -539,6 +539,20 @@ class ClientKnowingTui(Client): return self.connect() + def join(self, chan_name: str) -> None: + 'Catch /join to complain if already in channel.' + if chan_name in self.db.channels.keys(): + self._tui_alert_trigger('already in that channel') + else: + self.send('JOIN', chan_name) + + def part(self, chan_name: str) -> None: + 'Catch /part to complain if not in channel.' + if chan_name not in self.db.channels.keys(): + self._tui_alert_trigger('not in that channel') + else: + self.send('PART', chan_name) + def send(self, verb: str, *args) -> Optional[IrcMessage]: try: msg = super().send(verb, *args)