comparison participant.py @ 82:90baff5dedb2

Fixed callbacks in participant.py Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 05 Sep 2009 20:13:22 +0200
parents a8749705fe94
children 5115ba7d5983
comparison
equal deleted inserted replaced
81:22cfc31f9c90 82:90baff5dedb2
49 49
50 50
51 def _xmpp_join_callback(self, errors): 51 def _xmpp_join_callback(self, errors):
52 if len(errors) == 0: 52 if len(errors) == 0:
53 self.bridge.bot.error('===> Debug: "'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"', debug=True) 53 self.bridge.bot.error('===> Debug: "'+self.nickname+'" duplicate succesfully created on XMPP side of bridge "'+str(self.bridge)+'"', debug=True)
54 else: 54 elif self.xmpp_c != 'both':
55 for error in errors: 55 for error in errors:
56 try: 56 try:
57 raise error 57 raise error
58 except xmpp.muc.NicknameConflict: 58 except xmpp.muc.NicknameConflict:
59 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self.bridge)+'"', debug=True) 59 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self.bridge)+'"', debug=True)
60 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the XMPP server, please avoid that if possible') 60 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the XMPP server, please avoid that if possible')
61 self.muc.leave('Changed nickname to "'+self.nickname+'"') 61 if self.muc.connected == True:
62 self.muc.leave('Changed nickname to "'+self.nickname+'"')
63 self.bridge.bot.close_xmpp_connection(self.nickname)
64 self.xmpp_c = None
65 except xmpp.muc.RoomIsFull:
66 self.bridge.bot.error('[Warning] XMPP MUC of bridge "'+str(self.bridge)+'" is full', debug=True)
67 self.bridge.say('[Warning] XMPP room is full')
62 self.bridge.bot.close_xmpp_connection(self.nickname) 68 self.bridge.bot.close_xmpp_connection(self.nickname)
63 self.xmpp_c = None 69 self.xmpp_c = None
64 70
65 71
66 def createDuplicateOnIRC(self): 72 def createDuplicateOnIRC(self):
73 79
74 def _irc_nick_callback(self, error, arguments=[]): 80 def _irc_nick_callback(self, error, arguments=[]):
75 if error == None: 81 if error == None:
76 self.irc_connection.join(self.bridge.irc_room) 82 self.irc_connection.join(self.bridge.irc_room)
77 self.bridge.bot.error('===> Debug: "'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"', debug=True) 83 self.bridge.bot.error('===> Debug: "'+self.nickname+'" duplicate succesfully created on IRC side of bridge "'+str(self.bridge)+'"', debug=True)
78 else: 84 elif self.irc_connection != 'both':
79 if error == 'nicknameinuse': 85 if error == 'nicknameinuse':
80 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used in the IRC chan of bridge "'+str(self.bridge)+'"', debug=True) 86 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is used or reserved on the IRC server of bridge "'+str(self.bridge)+'"', debug=True)
81 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both rooms or reserved on the IRC server, please avoid that if possible') 87 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used or reserved on the IRC server, please avoid that if possible')
82 if isinstance(self.irc_connection, ServerConnection): 88 if isinstance(self.irc_connection, ServerConnection):
83 self.irc_connection.close('') 89 self.irc_connection.close('')
84 self.irc_connection = 'nicknameinuse' 90 self.irc_connection = error
85 elif error == 'nickcollision': 91 elif error == 'nickcollision':
86 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is already used or reserved on the IRC server of bridge "'+str(self.bridge)+'"', debug=True) 92 self.bridge.bot.error('===> Debug: "'+self.nickname+'" is used or reserved on the IRC server of bridge "'+str(self.bridge)+'"', debug=True)
87 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is already used or reserved on the IRC server, please avoid that if possible') 93 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used or reserved on the IRC server, please avoid that if possible')
88 if isinstance(self.irc_connection, ServerConnection): 94 if isinstance(self.irc_connection, ServerConnection):
89 self.irc_connection.close('') 95 self.irc_connection.close('')
90 self.irc_connection = 'nickcollision' 96 self.irc_connection = error
91 elif error == 'erroneusnickname': 97 elif error == 'erroneusnickname':
92 self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "erroneusnickname" on bridge "'+str(self.bridge)+'"', debug=True) 98 self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "erroneusnickname" on bridge "'+str(self.bridge)+'"', debug=True)
93 self.bridge.say('[Warning] The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel, please avoid that if possible') 99 self.bridge.say('[Warning] The nickname "'+self.nickname+'" contains unauthorized characters and cannot be used in the IRC channel, please avoid that if possible')
94 if isinstance(self.irc_connection, ServerConnection): 100 if isinstance(self.irc_connection, ServerConnection):
95 self.irc_connection.close('') 101 self.irc_connection.close('')
96 self.irc_connection = 'erroneusnickname' 102 self.irc_connection = error
97 elif error == 'nicknametoolong': 103 elif error == 'nicknametoolong':
98 self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "nicknametoolong" on bridge "'+str(self.bridge)+'"', debug=True) 104 self.bridge.bot.error('===> Debug: "'+self.nickname+'" got "nicknametoolong" on bridge "'+str(self.bridge)+'"', debug=True)
99 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel, please avoid that if possible') 105 self.bridge.say('[Warning] The nickname "'+self.nickname+'" is too long (limit seems to be '+str(arguments[0])+') and cannot be used in the IRC channel, please avoid that if possible')
100 if isinstance(self.irc_connection, ServerConnection): 106 if isinstance(self.irc_connection, ServerConnection):
101 self.irc_connection.close('') 107 self.irc_connection.close('')
102 self.irc_connection = 'nicknametoolong' 108 self.irc_connection = error
109 else:
110 self.bridge.bot.error('===> Debug: unknown error while adding "'+self.nickname+'" to IRC side of bridge "'+str(self.bridge)+'"', debug=True)
111 self.bridge.say('[Warning] unknown error while adding "'+self.nickname+'" to IRC side of bridge')
112 if isinstance(self.irc_connection, ServerConnection):
113 self.irc_connection.close('')
114 self.irc_connection = error
103 115
104 116
105 def changeNickname(self, newnick, on_protocol): 117 def changeNickname(self, newnick, on_protocol):
106 """Change participant's nickname.""" 118 """Change participant's nickname."""
107 119