channel = msg.params[0]
log_msg = f'{msg.nick_from_source} {msg.verb.lower()}s {channel}'
match msg.verb:
- case '005':
+ case '005' if len(msg.params) > 2:
for param in msg.params[1:-1]:
self._db.append('isupports', param)
- case '372': # RPL_MOTD
+ case '372' if len(msg.params) == 2: # RPL_MOTD
self._db.append('motd', msg.params[-1])
- case '376': # RPL_ENDOFMOTD
+ case '376' if len(msg.params) == 2: # RPL_ENDOFMOTD
self._update_db('motd', None, True)
- case '396': # RPL_VISIBLEHOST/RPL_YOURDISPLAYEDHOST/RPL_HOSTHIDDEN
+ case '396' if len(msg.params) == 3: # RPL_VISIBLEHOST
# '@'-split because <https://defs.ircdocs.horse/defs/numerics>
# claims: "<hostname> can also be in the form <user@hostname>"
self._update_db('client_host', confirm=True,
self.send(IrcMessage('AUTHENTICATE', ('PLAIN',)))
else:
self._caps.end_negotiation()
- case 'ERROR':
+ case 'ERROR' if len(msg.params) == 1:
self.close()
case 'JOIN' if len(msg.params) == 1:
self._log(log_msg, scope=scope, channel=channel)
case 'NICK' if (len(msg.params) == 1
and msg.nick_from_source == self._db.nickname):
self._update_db('nickname', msg.params[0], confirm=True)
- case 'NOTICE' | 'PRIVMSG' if len(msg.params) > 1:
+ case 'NOTICE' | 'PRIVMSG' if len(msg.params) == 2:
scope = LogScope.CHAT if '!' in msg.source else LogScope.SERVER
self._log(msg.params[-1], scope=scope, channel=msg.params[0],
out=False, as_notice=msg.verb == 'NOTICE',
self._log(log_msg, scope=scope, channel=channel)
case 'PING' if len(msg.params) == 1:
self.send(IrcMessage(verb='PONG', params=(msg.params[0],)))
- case '903' | '904':
+ case '903' | '904' if len(msg.params) == 1:
alert = msg.verb == '904'
self._log(f'SASL auth {"failed" if alert else "succeeded"}',
alert=alert)