comparison participant.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 32a35f7eff70
children 1691ab4d131f
comparison
equal deleted inserted replaced
18:3cdf7bb580da 19:c1b84196c100
35 if protocol == 'xmpp': 35 if protocol == 'xmpp':
36 self.createDuplicateOnIRC() 36 self.createDuplicateOnIRC()
37 elif protocol == 'irc': 37 elif protocol == 'irc':
38 self.createDuplicateOnXMPP() 38 self.createDuplicateOnXMPP()
39 else: 39 else:
40 raise Exception('Internal Error: bad protocol') 40 raise Exception('[Internal Error] bad protocol')
41 41
42 42
43 def createDuplicateOnXMPP(self): 43 def createDuplicateOnXMPP(self):
44 if self.xmpp_c != None or self.irc_connection != None or self.bridge.mode == 'minimal': 44 if self.xmpp_c != None or self.irc_connection != None or self.bridge.mode == 'minimal':
45 return 45 return
119 self.createDuplicateOnXMPP() 119 self.createDuplicateOnXMPP()
120 120
121 121
122 def sayOnIRC(self, message): 122 def sayOnIRC(self, message):
123 if self.protocol == 'irc': 123 if self.protocol == 'irc':
124 raise Exception('Internal Error: "'+self.nickname+'" comes from IRC') 124 raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
125 125
126 try: 126 try:
127 if self.irc_connection == None: 127 if self.irc_connection == None:
128 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message) 128 self.bridge.irc_connection.privmsg(self.bridge.irc_room, '<'+self.nickname+'> '+message)
129 else: 129 else:
132 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 132 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
133 133
134 134
135 def sayOnIRCTo(self, to, message): 135 def sayOnIRCTo(self, to, message):
136 if self.protocol == 'irc': 136 if self.protocol == 'irc':
137 raise Exception('Internal Error: "'+self.nickname+'" comes from IRC') 137 raise Exception('[Internal Error] "'+self.nickname+'" comes from IRC')
138 138
139 if self.irc_connection == None: 139 if self.irc_connection == None:
140 if self.bridge.mode != 'normal': 140 if self.bridge.mode != 'normal':
141 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in limited mode.') 141 self.bridge.getParticipant(to).sayOnXMPPTo(self.nickname, 'Sorry but cross-protocol private messages are disabled in limited mode.')
142 else: 142 else:
148 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 148 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
149 149
150 150
151 def sayOnXMPP(self, message): 151 def sayOnXMPP(self, message):
152 if self.protocol == 'xmpp': 152 if self.protocol == 'xmpp':
153 raise Exception('Internal Error: "'+self.nickname+'" comes from XMPP') 153 raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
154 154
155 try: 155 try:
156 if self.xmpp_c == None: 156 if self.xmpp_c == None:
157 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message)) 157 self.bridge.xmpp_room.say('<'+self.nickname+'> '+auto_decode(message))
158 else: 158 else:
161 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 161 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')
162 162
163 163
164 def sayOnXMPPTo(self, to, message): 164 def sayOnXMPPTo(self, to, message):
165 if self.protocol == 'xmpp': 165 if self.protocol == 'xmpp':
166 raise Exception('Internal Error: "'+self.nickname+'" comes from XMPP') 166 raise Exception('[Internal Error] "'+self.nickname+'" comes from XMPP')
167 167
168 try: 168 try:
169 self.muc.sayTo(to, auto_decode(message)) 169 self.muc.sayTo(to, auto_decode(message))
170 except EncodingException: 170 except EncodingException:
171 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding') 171 self.bridge.say('[Warning] "'+self.nickname+'" is sending messages using an unknown encoding')