'Log msg.raw, then process incoming msg into appropriate client steps.'
self._log(msg.raw, scope=LogScope.RAW, out=False)
match msg.verb:
+ case '001' | '002' | '003' | '004':
+ pass # explicitly ignored verbs/numerics
+ case '375':
+ self._db.set('motd', [], False)
+ case '372':
+ motd = self._db.get_force('motd')[0]
+ assert isinstance(motd, list)
+ motd += [msg.params[-1]]
+ case '376':
+ motd = self._db.get_force('motd')[0]
+ assert isinstance(motd, list)
+ self._db.set('motd', motd, True)
+ for line in self._db.motd:
+ self._log(line, as_notice=True)
case 'PING':
self.send(IrcMessage(verb='PONG', params=(msg.params[0],)))
case 'ERROR':
case 'NOTICE' | 'PRIVMSG':
scope = LogScope.CHAT if '!' in msg.source else LogScope.SERVER
self._log(msg.params[-1], scope=scope, channel=msg.params[0],
- out=False, is_notice=msg.verb == 'NOTICE',
+ out=False, as_notice=msg.verb == 'NOTICE',
sender=msg.nick_from_source)
case 'PRIVMSG':
self._log(msg.params[-1], scope=LogScope.CHAT, out=False,
user, channel = msg.nick_from_source, msg.params[-1]
self._log(f'{user} {msg.verb.lower()}s {channel}',
scope=LogScope.CHAT, channel=channel)
+ case _:
+ self._log(f'PLEASE IMPLEMENT HANDLER FOR: {msg.raw}')
@dataclass
if 'out' in kwargs and scope != LogScope.SERVER:
first_char = _LOG_PREFIX_OUT if kwargs['out'] else _LOG_PREFIX_IN
if scope == LogScope.CHAT:
- nickname = (self._db.nickname if kwargs['out']
- else kwargs['sender'])
- sender_label = f' [{nickname}]'
- if kwargs.get('is_notice', False):
+ sender_label = ' [' + (self._db.nickname if kwargs['out']
+ else kwargs['sender']) + ']'
+ if kwargs.get('as_notice', False):
first_char *= 3
prefix = f'{first_char}{sender_label}'
self._tui_log(msg, scope=scope, prefix=prefix, **kwargs)