diff src/plugins/plugin_xep_0045.py @ 1392:c7082457d03f

memory, plugin XEP-0045: getMainResource returns None when asking a MUC entity + fixes /whois on a MUC (bare) entity
author souliane <souliane@mailoo.org>
date Wed, 25 Mar 2015 15:28:02 +0100
parents 73f8582c7c99
children 069ad98b360d
line wrap: on
line diff
--- 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: