plugin XEP-0045: in case of nickname conflict when entering a room, a new one is automaticaly assigned
This commit is contained in:
parent
225d3ac5f1
commit
ef6dbda917
1 changed files with 8 additions and 3 deletions
|
|
@ -100,8 +100,13 @@ class XEP_0045():
|
|||
return room
|
||||
|
||||
|
||||
def __err_joining_room(self, failure, profile):
|
||||
def __err_joining_room(self, failure, room_jid, nick, history_options, password, profile):
|
||||
"""Called when something is going wrong when joining the room"""
|
||||
if failure.value.condition == 'conflict':
|
||||
# we have a nickname conflict, we try again with "_" suffixed to current nickname
|
||||
nick += '_'
|
||||
return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile':profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
|
||||
|
||||
mess = _("Error when joining the room")
|
||||
error (mess)
|
||||
self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile)
|
||||
|
|
@ -129,7 +134,7 @@ class XEP_0045():
|
|||
|
||||
def isNickInRoom(self, room_jid, nick, profile):
|
||||
"""Tell if a nick is currently present in a room"""
|
||||
profile = self.host.memory.getProfileName(profile_key)
|
||||
profile = self.host.memory.getProfileName(profile)
|
||||
if not self.__check_profile(profile):
|
||||
raise exceptions.UnknownProfileError("Unknown or disconnected profile")
|
||||
if not self.clients[profile].joined_rooms.has_key(room_jid.userhost()):
|
||||
|
|
@ -166,7 +171,7 @@ class XEP_0045():
|
|||
history_options = options["history"] == "True" if options.has_key("history") else None
|
||||
password = options["password"] if options.has_key("password") else None
|
||||
|
||||
return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile':profile}, errbackKeywords={'profile':profile})
|
||||
return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile':profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
|
||||
|
||||
def _join(self, room_jid_s, nick, options={}, profile_key='@DEFAULT@'):
|
||||
"""join method used by bridge: use the _join method, but doesn't return any deferred"""
|
||||
|
|
|
|||
Loading…
Reference in a new issue