'Handle a presence in a muc.'

def handle_groupchat_presence(self, pr):

    got_offline = False
    got_online = False
    if (pr['muc']['room'] not in self.rooms.keys()):
        return
    entry = pr['muc'].getStanzaValues()
    entry['show'] = pr['show']
    entry['status'] = pr['status']
    entry['alt_nick'] = pr['nick']
    if (pr['type'] == 'unavailable'):
        if (entry['nick'] in self.rooms[entry['room']]):
            del self.rooms[entry['room']][entry['nick']]
        if ('{}/{}'.format(entry['room'], entry['nick']) == self.getOurJidInRoom(entry['room'])):
            log.debug(('I    got    kicked    :(    from    %s' % entry['room']))
            del self.rooms[entry['room']]
        got_offline = True
    else:
        if (entry['nick'] not in self.rooms[entry['room']]):
            got_online = True
        self.rooms[entry['room']][entry['nick']] = entry
    log.debug('MUC    presence    from    %s/%s    :    %s', entry['room'], entry['nick'], entry)
    self.xmpp.event('groupchat_presence', pr)
    self.xmpp.event(('muc::%s::presence' % entry['room']), pr)
    if got_offline:
        self.xmpp.event(('muc::%s::got_offline' % entry['room']), pr)
    if got_online:
        self.xmpp.event(('muc::%s::got_online' % entry['room']), pr)
