changeset 88:8b071629558e

Handle IRC "kill" event Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 07 Sep 2009 18:33:59 +0200
parents 500d47b1d8cd
children 94fc538cdf65
files bot.py
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -475,7 +475,7 @@ class bot(Thread):
 		self.error(event_str, debug=True)
 		
 		
-		if event.eventtype() == 'disconnect':
+		if event.eventtype() in ['disconnect', 'kill']:
 			if len(event.arguments()) > 0 and event.arguments()[0] == 'Connection reset by peer':
 				return
 			
@@ -484,9 +484,16 @@ class bot(Thread):
 				if connection.server != bridge.irc_server:
 					continue
 				try:
-					bridge.getParticipant(connection.get_nickname())
+					p = bridge.getParticipant(connection.get_nickname())
 					if bridge.mode == 'normal':
 						bridge.switchFromNormalToLimitedMode()
+					else:
+						if p.irc_connection.really_connected == True:
+							p.irc_connection.part(bridge.irc_room, message=message)
+						p.irc_connection.used_by -= 1
+						if p.irc_connection.used_by < 1:
+							p.irc_connection.close(message)
+						p.irc_connection = None
 				except NoSuchParticipantException:
 					pass
 			return