'Attempt joining a channel.'
self._send_msg('JOIN', (channel,))
- def cmd__part(self, channel: str) -> None:
- 'Attempt joining a channel.'
- self._send_msg('PART', (channel,))
-
def cmd__privmsg(self, target: str, msg: str) -> None:
'Send chat message msg to target.'
self._send_msg('PRIVMSG', (target, msg), log_target=target, to_log=msg)
self._send_msg(verb, tuple(params))
-class _PrivmsgPromptWidget(PromptWidget):
+class _ChatPrompt(PromptWidget):
_nickname: str = ''
_nick_confirmed: bool = False
return f'/window.chat {to_return}'
-class _PrivmsgWindow(_ClientWindow):
- prompt: _PrivmsgPromptWidget
+class _ChatWindow(_ClientWindow):
+ prompt: _ChatPrompt
def __init__(self, chatname: str, get_nick_data: Callable, **kwargs
) -> None:
self.cmd__privmsg(target=self.chatname, msg=msg)
+class _ChannelWindow(_ChatWindow):
+
+ def cmd__part(self) -> None:
+ 'Attempt joining a channel.'
+ self._send_msg('PART', (self.chatname,))
+
+
@dataclass
class _ClientWindowsManager:
_tui_log: Callable
def _new_win(self, scope: LogScope, chatname: str = '') -> _ClientWindow:
kwargs = {'scope': scope, 'log': self.log, 'win_cls': _ClientWindow}
if scope == LogScope.CHAT:
- kwargs['win_cls'] = _PrivmsgWindow
+ kwargs['win_cls'] = (_ChannelWindow if chatname[0] == '#'
+ else _ChatWindow)
kwargs['chatname'] = chatname
kwargs['get_nick_data'] = lambda: self._db.get_force('nickname')
win = self._tui_new_window(**kwargs)
'Return client window of scope.'
for win in [w for w in self.windows if w.scope == scope]:
if scope == LogScope.CHAT:
- if isinstance(win, _PrivmsgWindow)\
- and win.chatname == chatname:
+ if isinstance(win, _ChatWindow) and win.chatname == chatname:
return win
continue
return win
if changes[i]:
self.log(f'changing {t[0]}{key} to: [{t[1]}]', scope=scope)
for win in [w for w in self.windows
- if isinstance(w, _PrivmsgWindow)]:
+ if isinstance(w, _ChatWindow)]:
win.set_prompt_prefix()
return bool([w for w in self.windows if w.tainted])