diff plugins/plugin_xep_0045.py @ 93:2f87651a5ad8

Tarot game: basic trick - plugin xep-0045: new method getRoomNick - plugin tarot: basic trick - wix: played card are shown in CardPanel
author Goffi <goffi@goffi.org>
date Sun, 30 May 2010 15:33:08 +0930
parents 39c672544593
children 7201851d9aed
line wrap: on
line diff
--- a/plugins/plugin_xep_0045.py	Sat May 29 20:53:03 2010 +0930
+++ b/plugins/plugin_xep_0045.py	Sun May 30 15:33:08 2010 +0930
@@ -110,6 +110,17 @@
             result.append((room.roomIdentifier, room.service, [user.nick for user in room.roster.values()], room.nick))
         return result
 
+    def getRoomNick(self, room_jid, profile_key='@DEFAULT@'):
+        """return nick used in room by user
+        @param room_jid: unicode room id
+        @profile_key: profile
+        @return: nick or empty string in case of error"""
+        profile = self.host.memory.getProfileName(profile_key)
+        if not self.__check_profile(profile) or not self.clients[profile].joined_rooms.has_key(room_jid):
+            return ''
+        return self.clients[profile].joined_rooms[room_jid].nick
+
+
     def getRoomSubjects(self, profile_key='@DEFAULT@'):
         """Return received subjects of rooms"""
         profile = self.host.memory.getProfileName(profile_key)