from ircplom.irc_conn import IrcMessage
from ircplom.client import (CHAT_GLOB, IrcConnSetup, Client, ClientEvent,
ClientIdMixin, ClientQueueMixin,
- InitReconnectEvent, NewClientEvent, SendEvent)
+ InitReconnectEvent, NewClientEvent)
CMD_SHORTCUTS['connect'] = 'window.connect'
def status_title(self) -> str:
return f'{super().status_title}|{self.client_id}|{self.chat}'
+ def _send_msg(self, verb, params, **kwargs) -> None:
+ self._cput(ClientEvent.make_subtype(
+ 'send', msg=IrcMessage(verb=verb, params=params), **kwargs))
+
def cmd__disconnect(self, quit_msg: str = 'ircplom says bye') -> None:
'Send QUIT command to server.'
- self._cput(SendEvent,
- payload=IrcMessage(verb='QUIT', params=(quit_msg,)))
+ self._send_msg('QUIT', (quit_msg,))
def cmd__connect(self,
host_port: str = '',
def cmd__nick(self, new_nick: str) -> None:
'Attempt nickname change.'
- self._cput(SendEvent,
- payload=IrcMessage(verb='NICK', params=(new_nick,)))
+ self._send_msg('NICK', (new_nick,))
def cmd__privmsg(self, target: str, msg: str) -> None:
'Send chat message msg to target.'
- self._cput(ClientEvent.make_subtype(
- method_to_call='send',
- msg=IrcMessage(verb='PRIVMSG', params=(target, msg)),
- chat=target, to_log=f'>[MYSELF] {msg}'))
+ self._send_msg('PRIVMSG', (target, msg), chat=target,
+ to_log=f'>[MYSELF] {msg}')
class _PrivmsgPromptWidget(_ClientPromptWidget):