From 3d1b71267f8be90b14152041706124764c040d34 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Wed, 13 Aug 2025 07:24:50 +0200 Subject: [PATCH] Add /raw to directly write raw commands. --- ircplom/client_tui.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index bb06b10..8dc36de 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -16,6 +16,7 @@ CMD_SHORTCUTS['part'] = 'window.part' CMD_SHORTCUTS['nick'] = 'window.nick' CMD_SHORTCUTS['privmsg'] = 'window.privmsg' CMD_SHORTCUTS['reconnect'] = 'window.reconnect' +CMD_SHORTCUTS['raw'] = 'window.raw' _LOG_PREFIX_SERVER = '$' _LOG_PREFIX_OUT = '>' @@ -60,6 +61,15 @@ class _ClientWindow(Window, ClientQueueMixin): 'Send chat message msg to target.' self._send_msg('PRIVMSG', (target, msg), log_target=target, to_log=msg) + def cmd__raw(self, verb: str, params_str: str = '') -> None: + 'Send raw command, with direct input of params string.' + if params_str[:1] == ':': + params = [params_str] + else: + params = params_str.split(' :', maxsplit=1) + params = params[0].split() + params[1:2] + self._send_msg(verb, tuple(params)) + class _PrivmsgPromptWidget(PromptWidget): _nickname: str = '' @@ -157,7 +167,7 @@ class _ClientWindowsManager: ) -> bool: 'Apply settings in kwargs, follow representation update triggers.' changes = self._db.set(key, value, confirmed) - for i, t in enumerate((('', value), ('confirmation of', confirmed))): + for i, t in enumerate((('', value), ('confirmation of ', confirmed))): if changes[i]: self.log(f'changing {t[0]}{key} to: [{t[1]}]', scope=scope) for win in [w for w in self.windows @@ -264,7 +274,7 @@ class _ClientKnowingTui(Client): self._client_tui_trigger('log', scope=scope, msg=item, **kwargs) if scope == LogScope.RAW: with open(f'{self.client_id}.log', 'a', encoding='utf8') as f: - f.write((f'>' if kwargs['out'] else '<') + f' {msg}\n') + f.write(('>' if kwargs['out'] else '<') + f' {msg}\n') def _update_db(self, key: str, value: int | str, confirm: bool) -> None: super()._update_db(key, value, confirm) -- 2.30.2