comparison plugins/plugin_xep_0045.py @ 75:7322a41f8a8e

Basic user joined/left management - plugin XEP-0045: user joined./left signal is sended - wix: user are adder/removed when these signals are catched
author Goffi <goffi@goffi.org>
date Mon, 29 Mar 2010 16:54:53 +1100
parents 6e3a06b4dd36
children 8becde8a967c
comparison
equal deleted inserted replaced
74:6e3a06b4dd36 75:7322a41f8a8e
72 host.bridge.addSignal("roomJoined", ".communication", signature='ssasss') #args: room_id, room_service, room_nicks, user_nick, profile 72 host.bridge.addSignal("roomJoined", ".communication", signature='ssasss') #args: room_id, room_service, room_nicks, user_nick, profile
73 host.bridge.addSignal("roomUserJoined", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile 73 host.bridge.addSignal("roomUserJoined", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile
74 host.bridge.addSignal("roomUserLeft", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile 74 host.bridge.addSignal("roomUserLeft", ".communication", signature='sssa{ss}s') #args: room_id, room_service, user_nick, user_data, profile
75 75
76 def __check_profile(self, profile): 76 def __check_profile(self, profile):
77 """check if profile is used and connected
78 if profile known but disconnected, remove it from known profiles
79 @param profile: profile to check
80 @return: True if the profile is known and connected, else False"""
77 if not profile or not self.clients.has_key(profile) or not self.host.isConnected(profile): 81 if not profile or not self.clients.has_key(profile) or not self.host.isConnected(profile):
78 error (_('Unknown or disconnected profile')) 82 error (_('Unknown or disconnected profile'))
79 if self.clients.has_key(profile): 83 if self.clients.has_key(profile):
80 del self.clients[profile] 84 del self.clients[profile]
81 return False 85 return False
84 def __room_joined(self, room, profile): 88 def __room_joined(self, room, profile):
85 """Called when the user is in the requested room""" 89 """Called when the user is in the requested room"""
86 print "room joined (profile = %s)" % profile 90 print "room joined (profile = %s)" % profile
87 room_jid = room.roomIdentifier+'@'+room.service 91 room_jid = room.roomIdentifier+'@'+room.service
88 self.clients[profile].joined_rooms[room_jid] = room 92 self.clients[profile].joined_rooms[room_jid] = room
89 self.host.bridge.roomJoined(room.roomIdentifier, room.service, room.roster.keys(), room.nick, profile) 93 self.host.bridge.roomJoined(room.roomIdentifier, room.service, [user.nick for user in room.roster.values()], room.nick, profile)
90 94
91 def __err_joining_room(self, failure, profile): #, profile): 95 def __err_joining_room(self, failure, profile):
92 """Called when something is going wrong when joining the room""" 96 """Called when something is going wrong when joining the room"""
93 error ("Error when joining the room") 97 error ("Error when joining the room")
94 pdb.set_trace() 98 pdb.set_trace()
95 99
96 def join(self, service, roomId, nick, profile_key='@DEFAULT@'): 100 def join(self, service, roomId, nick, profile_key='@DEFAULT@'):