comparison bot.py @ 41:4c4f4ee72e17

Fixed IRC "nick" event handling. Fixed bot's XMPP infinite loop. Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 24 Aug 2009 16:56:04 +0200
parents 3b06450d60cd
children b8c9ddf320f8
comparison
equal deleted inserted replaced
40:faa468731d8a 41:4c4f4ee72e17
71 71
72 def _xmpp_loop(self): 72 def _xmpp_loop(self):
73 """[Internal] XMPP infinite loop.""" 73 """[Internal] XMPP infinite loop."""
74 while True: 74 while True:
75 try: 75 try:
76 self.xmpp_c.lock.acquire()
77 self.xmpp_c.Process(0.5)
78 self.xmpp_c.lock.release()
79 try: 76 try:
77 if len(self.xmpp_connections) == 1:
78 sleep(0.5) # avoid bot connection being locked all the time
80 for c in self.xmpp_connections.itervalues(): 79 for c in self.xmpp_connections.itervalues():
81 if hasattr(c, 'Process'): 80 if hasattr(c, 'Process'):
82 c.lock.acquire() 81 c.lock.acquire()
83 c.Process(0.5) 82 c.Process(0.5)
84 c.lock.release() 83 c.lock.release()
331 handled = True 330 handled = True
332 continue 331 continue
333 332
334 333
335 # Nickname change 334 # Nickname change
336 if event.eventtype() == 'nick' and from_.protocol == 'irc': 335 if event.eventtype() == 'nick':
337 from_.changeNickname(event.target(), 'xmpp') 336 from_.changeNickname(event.target(), 'xmpp')
338 handled = True 337 handled = True
339 continue 338 continue
340 339
341 340