comparison bot.py @ 39:3b06450d60cd

Improved debug output. Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 23 Aug 2009 20:09:49 +0200
parents 7e500d4064fb
children 4c4f4ee72e17
comparison
equal deleted inserted replaced
38:984e1e5c5e51 39:3b06450d60cd
271 271
272 if event.eventtype() in ['pubmsg', 'action', 'privmsg', 'quit', 'part', 'nick']: 272 if event.eventtype() in ['pubmsg', 'action', 'privmsg', 'quit', 'part', 'nick']:
273 if nickname == None: 273 if nickname == None:
274 return 274 return
275 275
276 handled = False
277
278 if event.eventtype() in ['quit', 'part', 'nick']:
279 self.error(event_str, debug=True)
280
276 # TODO: lock self.bridges for thread safety 281 # TODO: lock self.bridges for thread safety
277 for bridge in self.bridges: 282 for bridge in self.bridges:
278 if connection.server != bridge.irc_server: 283 if connection.server != bridge.irc_server:
279 continue 284 continue
280 285
281 try: 286 try:
282 from_ = bridge.getParticipant(nickname) 287 from_ = bridge.getParticipant(nickname)
283 288
284 except NoSuchParticipantException: 289 except NoSuchParticipantException:
285 self.error('===> Debug: NoSuchParticipantException "'+nickname+'" in bridge "'+str(bridge)+'"', debug=True)
286 continue 290 continue
287 291
288 292
289 # Private message 293 # Private message
290 if event.eventtype() == 'privmsg': 294 if event.eventtype() == 'privmsg':
309 313
310 # From here we skip if the event was not received on bot connection 314 # From here we skip if the event was not received on bot connection
311 if connection.get_nickname() != self.nickname: 315 if connection.get_nickname() != self.nickname:
312 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True) 316 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True)
313 continue 317 continue
314
315 self.error(event_str, debug=True)
316 318
317 319
318 # Leaving events 320 # Leaving events
319 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == bridge.irc_room: 321 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target() == bridge.irc_room:
320 if len(event.arguments()) > 0: 322 if len(event.arguments()) > 0:
324 elif event.eventtype() == 'part': 326 elif event.eventtype() == 'part':
325 leave_message = 'Left channel.' 327 leave_message = 'Left channel.'
326 else: 328 else:
327 leave_message = '' 329 leave_message = ''
328 bridge.removeParticipant('irc', from_.nickname, leave_message) 330 bridge.removeParticipant('irc', from_.nickname, leave_message)
331 handled = True
329 continue 332 continue
330 333
331 334
332 # Nickname change 335 # Nickname change
333 if event.eventtype() == 'nick' and from_.protocol == 'irc': 336 if event.eventtype() == 'nick' and from_.protocol == 'irc':
334 from_.changeNickname(event.target(), 'xmpp') 337 from_.changeNickname(event.target(), 'xmpp')
338 handled = True
335 continue 339 continue
336 340
337 341
338 # Chan message 342 # Chan message
339 if event.eventtype() in ['pubmsg', 'action']: 343 if event.eventtype() in ['pubmsg', 'action']:
340 if bridge.irc_room == event.target() and bridge.irc_server == connection.server: 344 if bridge.irc_room == event.target() and bridge.irc_server == connection.server:
345 self.error(event_str, debug=True)
341 message = event.arguments()[0] 346 message = event.arguments()[0]
342 if event.eventtype() == 'action': 347 if event.eventtype() == 'action':
343 message = '/me '+message 348 message = '/me '+message
344 from_.sayOnXMPP(message) 349 from_.sayOnXMPP(message)
345 return 350 return
346 else: 351 else:
347 continue 352 continue
348 353
354 if handled == False:
355 if not event.eventtype() in ['quit', 'part', 'nick']:
356 self.error(event_str, debug=True)
357 self.error('=> Debug: event was not handled')
349 return 358 return
350 359
351 360
352 if event.eventtype() in ['namreply', 'join']: 361 if event.eventtype() in ['namreply', 'join']:
353 if connection.get_nickname() != self.nickname: 362 if connection.get_nickname() != self.nickname: