From: Christian Heller Date: Tue, 5 Aug 2025 00:43:22 +0000 (+0200) Subject: Allow slash-free direct chatting in PRIVMSG windows. X-Git-Url: https://plomlompom.com/repos/booking/static/%7B%7Bdb.prefix%7D%7D/process_descriptions?a=commitdiff_plain;ds=sidebyside;p=ircplom Allow slash-free direct chatting in PRIVMSG windows. --- diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index c7e60c2..6245571 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -64,14 +64,33 @@ class _ClientWindow(Window, ClientQueueMixin): payload=IrcMessage(verb='PRIVMSG', params=(target, msg))) +class _PrivmsgPromptWidget(_ClientPromptWidget): + + def enter(self) -> str: + to_return = super().enter() + if (not to_return) or to_return[0:1] == '/': + return to_return + return f'/window.chat {to_return}' + + +class _PrivmsgWindow(_ClientWindow): + prompt: _PrivmsgPromptWidget + + def cmd__chat(self, msg: str) -> None: + 'PRIVMSG to .chat.' + self.cmd__privmsg(self.chat, msg) + + class ClientTui(BaseTui): 'TUI expanded towards Client features.' def _new_client_window(self, client_id: UUID, chat: str = '' ) -> _ClientWindow: new_idx = len(self.windows) - win = _ClientWindow(idx=new_idx, term=self.term, q_out=self.q_out, - client_id=client_id, chat=chat) + win_class = (_PrivmsgWindow if (chat and chat[0].isalpha()) + else _ClientWindow) + win = win_class(idx=new_idx, term=self.term, q_out=self.q_out, + client_id=client_id, chat=chat) self.windows += [win] self._switch_window(new_idx) return win