home · contact · privacy
Add /raw to directly write raw commands.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 13 Aug 2025 05:24:50 +0000 (07:24 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 13 Aug 2025 05:24:50 +0000 (07:24 +0200)
ircplom/client_tui.py

index bb06b10091c3b5d23c2d05c01e64153e40036027..8dc36de38b09994e0e207ea7c619b592a29b10d4 100644 (file)
@@ -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)