def handle_server_kick(self, msg: IRCMessage) -> None: who = msg.parse_prefix_as_user() chan, target, *_ = msg.middle if target == self.nickname: try: self._channel_list.remove(msg.trailing) except ValueError: getLogger(__name__).error( "Kicked from a channel that was never joined.") self.bus.broadcast( BotKickedEvent( client=self, channel=chan, who=who, target=target, message=msg.trailing, )) else: self.bus.broadcast( ChannelKickedEvent( client=self, channel=chan, who=who, target=target, message=msg.trailing, ))
def handle_server_invite(self, msg: IRCMessage) -> None: self.bus.broadcast( InvitedEvent( client=self, who=msg.parse_prefix_as_user(), to=msg.trailing, ))
def handle_server_notice(self, msg: IRCMessage) -> None: # If command param is the client nick, set the user as the location who = msg.parse_prefix_as_user() where = msg.middle[0] if where == self.nickname: where = who.nick self.bus.broadcast( NoticedEvent( client=self, who=who, where=where, message=msg.trailing, ))
def handle_server_join(self, msg: IRCMessage) -> None: who = msg.parse_prefix_as_user() if who.nick == self.nickname: self._channel_list.append(msg.trailing) self.bus.broadcast( BotJoinedEvent( client=self, channel=msg.trailing, who=who, )) else: self.bus.broadcast( ChannelJoinedEvent( client=self, channel=msg.trailing, who=who, ))
def handle_server_part(self, msg: IRCMessage) -> None: who = msg.parse_prefix_as_user() if who.nick == self.nickname: try: self._channel_list.remove(msg.trailing) except ValueError: getLogger(__name__).error( "Parted a channel that was never joined.") self.bus.broadcast( BotPartedEvent( client=self, channel=msg.middle[0], who=who, message=msg.trailing, )) else: self.bus.broadcast( ChannelPartedEvent( client=self, channel=msg.middle[0], who=who, message=msg.trailing, ))
def handle_server_nick(self, msg: IRCMessage) -> None: who = msg.parse_prefix_as_user() if who.nick == self.nickname: self.nickname = msg.trailing