# HG changeset patch # User souliane # Date 1427293682 -3600 # Node ID c7082457d03f770b2f8eae797ff2309f47028157 # Parent 1276e6a0716b4bbcccba3b0fdf0b45109f78bccf memory, plugin XEP-0045: getMainResource returns None when asking a MUC entity + fixes /whois on a MUC (bare) entity diff -r 1276e6a0716b -r c7082457d03f src/memory/memory.py --- a/src/memory/memory.py Wed Mar 25 15:21:17 2015 +0100 +++ b/src/memory/memory.py Wed Mar 25 15:28:02 2015 +0100 @@ -514,6 +514,11 @@ """ if entity_jid.resource: raise ValueError("getMainResource must be used with a bare jid (got {})".format(entity_jid)) + try: + if self.host.plugins["XEP-0045"].isRoom(entity_jid, profile_key): + return None # MUC rooms have no main resource + except KeyError: # plugin not found + pass resources = self.getAllResources(entity_jid, profile_key) priority_resources = [] for resource in resources: diff -r 1276e6a0716b -r c7082457d03f src/plugins/plugin_xep_0045.py --- a/src/plugins/plugin_xep_0045.py Wed Mar 25 15:21:17 2015 +0100 +++ b/src/plugins/plugin_xep_0045.py Wed Mar 25 15:28:02 2015 +0100 @@ -153,6 +153,16 @@ self.host.bridge.newAlert(mess, D_("Group chat error"), "ERROR", profile) raise failure + def isRoom(self, entity_bare, profile_key): + """Tell if a bare entity is a MUC room. + + @param entity_bare (jid.JID): bare entity + @param profile_key (unicode): %(doc_profile_key)s + @return bool + """ + profile = self.host.memory.getProfileName(profile_key) + return entity_bare in self.clients[profile].joined_rooms + def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE): """Return room where user is""" profile = self.host.memory.getProfileName(profile_key) @@ -615,6 +625,8 @@ if target_jid.userhostJID() not in self.clients[profile].joined_rooms: log.warning(_("This room has not been joined")) return + if not target_jid.resource: + return user = self.clients[profile].joined_rooms[target_jid.userhostJID()].getUser(target_jid.resource) whois_msg.append(_("Nickname: %s") % user.nick) if user.entity: