def handle_part(data, match, client, channels): """ Someone is leaving a channel. Let's tell everyone about it and remove them from the channel's user listing (and the channel from the client's). '^PART (?P<channel>[^\s]+)( :(?P<message>.*))' :type data: str :type match: dict :type client: Client :type channels: list """ channame = match['channel'] logger.debug("{nick} leaves channel {channame}", nick=client.nick, channame=channame) if not channame in channels: logger.warn("no channel named {channame}", channame=channame) return channel = channels[channame] client.channels.remove(channel) channels[channame].clients.remove(client) announce = Protocol.part(client, channel, match['message'] or 'leaving') channel.send(announce)