comparison 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
comparison
equal deleted inserted replaced
1391:1276e6a0716b 1392:c7082457d03f
151 pass 151 pass
152 log.error(mess) 152 log.error(mess)
153 self.host.bridge.newAlert(mess, D_("Group chat error"), "ERROR", profile) 153 self.host.bridge.newAlert(mess, D_("Group chat error"), "ERROR", profile)
154 raise failure 154 raise failure
155 155
156 def isRoom(self, entity_bare, profile_key):
157 """Tell if a bare entity is a MUC room.
158
159 @param entity_bare (jid.JID): bare entity
160 @param profile_key (unicode): %(doc_profile_key)s
161 @return bool
162 """
163 profile = self.host.memory.getProfileName(profile_key)
164 return entity_bare in self.clients[profile].joined_rooms
165
156 def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE): 166 def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE):
157 """Return room where user is""" 167 """Return room where user is"""
158 profile = self.host.memory.getProfileName(profile_key) 168 profile = self.host.memory.getProfileName(profile_key)
159 result = [] 169 result = []
160 if not self.checkClient(profile): 170 if not self.checkClient(profile):
613 if mess_data['type'] != "groupchat": 623 if mess_data['type'] != "groupchat":
614 return 624 return
615 if target_jid.userhostJID() not in self.clients[profile].joined_rooms: 625 if target_jid.userhostJID() not in self.clients[profile].joined_rooms:
616 log.warning(_("This room has not been joined")) 626 log.warning(_("This room has not been joined"))
617 return 627 return
628 if not target_jid.resource:
629 return
618 user = self.clients[profile].joined_rooms[target_jid.userhostJID()].getUser(target_jid.resource) 630 user = self.clients[profile].joined_rooms[target_jid.userhostJID()].getUser(target_jid.resource)
619 whois_msg.append(_("Nickname: %s") % user.nick) 631 whois_msg.append(_("Nickname: %s") % user.nick)
620 if user.entity: 632 if user.entity:
621 whois_msg.append(_("Entity: %s") % user.entity) 633 whois_msg.append(_("Entity: %s") % user.entity)
622 if user.affiliation != 'none': 634 if user.affiliation != 'none':