def on_names(self, channel_name, users: List[IrcNickWithMode]): channel_id = ChannelID.public(channel_name) if channel_id not in self._chat: return channel = self._chat[channel_id] for nick in users: self._add_or_update_from_nick(channel, nick)
def on_join(self, channel_name, nick: IrcNickWithMode): channel_id = ChannelID.public(channel_name) if nick.nick == self._irc.my_username: self._add_channel(channel_id) if channel_id not in self._chat: return channel = self._chat[channel_id] self._add_or_update_from_nick(channel, nick)
def on_part(self, channel_name, nick: IrcNickWithMode, message): channel_id = ChannelID.public(channel_name) if channel_id not in self._chat: return channel = self._chat[channel_id] self._remove_from_nick(channel, nick) if nick.nick == self._irc.my_username: self._remove_channel(channel_id)
def join_private_channel(self, nick: str, from_channel): cid = ChannelID.public(from_channel) if cid not in self._chat: return channel = self._chat[cid] if nick not in channel.chatters: return chatter = channel.chatters[nick] nwm = IrcNickWithMode(chatter.nick, chatter.mode) self._join_private_channel(nwm)
def on_message(self, nick: IrcNickWithMode, target, text, type_: MessageType): if self._chat_filter(nick.nick): return public_channel = ChannelID.public(target) if public_channel in self._chat: channel = self._chat[public_channel] self._on_public_msg(nick, channel, text, type_) elif target == self._irc.my_username: self._on_other_private_msg(nick, text, type_) elif nick.nick == self._irc.my_username: self._on_my_private_msg(target, text, type_)
def on_topic(self, channel, message): channel_id = ChannelID.public(channel) if channel_id not in self._chat: return channel = self._chat[channel_id] channel.topic = message