self._log('nickname already in use, trying increment', alert=True)
self.set_nick(self._db.nick_incremented)
elif msg.match('900', 4): # RPL_LOGGEDIN
- nick, remainder = msg.params[1].split('!', maxsplit=1)
- assert nick == self._db.nickname
+ self._db.nickname, remainder = msg.params[1].split('!', maxsplit=1)
self._db.username, self._db.client_host = remainder.split('@')
self._db.sasl_account = msg.params[2]
elif msg.match('903', 2) or msg.match('904', 2): # RPL_SASLSUCCESS, …
self._db.user_modes = msg.params[1]
elif msg.match('NICK') and msg.nick_from_source == self._db.nickname:
self.set_nick(msg.params[0], confirmed=True)
- elif msg.match('NOTICE', 2) or msg.match('PRIVMSG', 2):
- scope = LogScope.CHAT if '!' in msg.source else LogScope.SERVER
- self._log(msg.params[-1], scope=scope, target=msg.params[0],
- out=False, as_notice=msg.verb == 'NOTICE',
- sender=msg.nick_from_source)
+ elif msg.match('NOTICE', 2) and (msg.params[0] != '*'
+ or not self._db.nickname):
+ kw: dict[str, str | LogScope] = {}
+ if '!' in msg.source:
+ kw |= {'sender': msg.nick_from_source, 'scope': LogScope.CHAT}
+ self._log(msg.params[-1], out=False, target=msg.params[0],
+ as_notice=True, **kw)
+ elif msg.match('PRIVMSG', 2) and msg.params[0] != '*':
+ kw = {}
+ if '!' in msg.source:
+ kw |= {'sender': msg.nick_from_source, 'scope': LogScope.CHAT}
+ self._log(msg.params[-1], out=False, target=msg.params[0], **kw)
elif msg.match('PART', len_is_min=True) or msg.match('JOIN'):
channel = msg.params[0]
log_msg = f'{msg.nick_from_source} {msg.verb.lower()}s {channel}'