Mercurial > xib
comparison bridge.py @ 19:c1b84196c100
Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Thu, 20 Aug 2009 13:20:50 +0200 |
parents | 3cdf7bb580da |
children | 801160b4136f |
comparison
equal
deleted
inserted
replaced
18:3cdf7bb580da | 19:c1b84196c100 |
---|---|
60 if error == None: | 60 if error == None: |
61 self.irc_connection.join(self.irc_room) | 61 self.irc_connection.join(self.irc_room) |
62 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) | 62 self.bot.error('===> Debug: successfully connected on IRC side of bridge "'+str(self)+'"', debug=True) |
63 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) | 63 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_xmpp=False) |
64 if error == 'nicknameinuse': | 64 if error == 'nicknameinuse': |
65 self.bot.error('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') | 65 self.bot.error('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') |
66 raise Exception('Error: "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') | 66 raise Exception('[Error] "'+self.bot.nickname+'" is already used in the IRC chan or reserved on the IRC server of bridge "'+str(self)+'"') |
67 elif error == 'erroneusnickname': | 67 elif error == 'erroneusnickname': |
68 self.bot.error('Error: "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') | 68 self.bot.error('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') |
69 raise Exception('Error: "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') | 69 raise Exception('[Error] "'+self.bot.nickname+'" got "erroneusnickname" on bridge "'+str(self)+'"') |
70 elif error == 'nicknametoolong': | 70 elif error == 'nicknametoolong': |
71 self.bot.error('Error: "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) | 71 self.bot.error('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) |
72 raise Exception('Error: "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) | 72 raise Exception('[Error] "'+self.bot.nickname+'" got "nicknametoolong" on bridge "'+str(self)+'", limit seems to be '+str(arguments[0])) |
73 | 73 |
74 | 74 |
75 def _xmpp_join_callback(self, errors): | 75 def _xmpp_join_callback(self, errors): |
76 """Called by muc._xmpp_presence_handler""" | 76 """Called by muc._xmpp_presence_handler""" |
77 if len(errors) == 0: | 77 if len(errors) == 0: |
79 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) | 79 self.say('[Notice] bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) |
80 for error in errors: | 80 for error in errors: |
81 try: | 81 try: |
82 raise error | 82 raise error |
83 except xmpp.muc.NicknameConflict: | 83 except xmpp.muc.NicknameConflict: |
84 self.bot.error('Error: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') | 84 self.bot.error('[Error] "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') |
85 raise Exception('Error: "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') | 85 raise Exception('[Error] "'+self.nickname+'" is already used in the XMPP MUC or reserved on the XMPP server of bridge "'+str(self)+'"') |
86 | 86 |
87 | 87 |
88 def addParticipant(self, protocol, nickname): | 88 def addParticipant(self, protocol, nickname): |
89 """Add a participant to the bridge.""" | 89 """Add a participant to the bridge.""" |
90 if (protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (protocol == 'xmpp' and nickname == self.xmpp_room.nickname): | 90 if (protocol == 'irc' and nickname == self.irc_connection.get_nickname()) or (protocol == 'xmpp' and nickname == self.xmpp_room.nickname): |
96 if protocol == 'irc': | 96 if protocol == 'irc': |
97 p.createDuplicateOnXMPP() | 97 p.createDuplicateOnXMPP() |
98 elif protocol == 'xmpp': | 98 elif protocol == 'xmpp': |
99 p.createDuplicateOnIRC() | 99 p.createDuplicateOnIRC() |
100 else: | 100 else: |
101 raise Exception('Internal Error: bad protocol') | 101 raise Exception('[Internal Error] bad protocol') |
102 return | 102 return |
103 except NoSuchParticipantException: | 103 except NoSuchParticipantException: |
104 pass | 104 pass |
105 self.bot.error('===> Debug: adding participant "'+nickname+'" from "'+protocol+'" to bridge "'+str(self)+'"', debug=True) | 105 self.bot.error('===> Debug: adding participant "'+nickname+'" from "'+protocol+'" to bridge "'+str(self)+'"', debug=True) |
106 p = participant(self, protocol, nickname) | 106 p = participant(self, protocol, nickname) |
154 p.createDuplicateOnIRC() | 154 p.createDuplicateOnIRC() |
155 else: | 155 else: |
156 was_on_both = False | 156 was_on_both = False |
157 | 157 |
158 else: | 158 else: |
159 raise Exception('Internal Error: bad protocol') | 159 raise Exception('[Internal Error] bad protocol') |
160 | 160 |
161 if was_on_both == True: | 161 if was_on_both == True: |
162 self.bot.error('===> Debug: "'+nickname+'" was on both sides of bridge "'+str(self)+'" but left '+left_protocol, debug=True) | 162 self.bot.error('===> Debug: "'+nickname+'" was on both sides of bridge "'+str(self)+'" but left '+left_protocol, debug=True) |
163 | 163 |
164 elif was_on_both == False: | 164 elif was_on_both == False: |