diff bot.py @ 219:63289aa1dea7

moved "nicknametoolong" and ServerConnection.really_connected handling to irclib, renamed ServerConnection.really_connected to .logged_in Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 12:08:29 +0100
parents d527d7b75f56
children 5726a0833537
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -459,7 +459,7 @@ class Bot(threading.Thread):
 		# Events we always want to ignore
 		if 'all' in event.eventtype() or 'motd' in event.eventtype() or event.eventtype() in ['nicknameinuse', 'nickcollision', 'erroneusnickname']:
 			return
-		if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo', '328', 'pubnotice', '042']:
+		if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo', '328', 'pubnotice', '042', 'umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'luserconns']:
 			self.error(1, 'ignoring IRC '+event.eventtype(), debug=True)
 			return
 		
@@ -470,19 +470,6 @@ class Bot(threading.Thread):
 				nickname = event.source().split('!')[0]
 		
 		
-		# Events that we want to ignore only in some cases
-		if event.eventtype() in ['umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'luserconns']:
-			if connection.really_connected == False:
-				if event.target() == connection.nickname:
-					connection.really_connected = True
-					connection._call_nick_callbacks(None)
-				elif len(connection.nick_callbacks) > 0:
-					self.error(3, 'event target ('+event.target()+') and connection nickname ('+connection.nickname+') don\'t match', debug=True)
-					connection._call_nick_callbacks('nicknametoolong', arguments=[len(event.target())])
-			self.error(1, 'ignoring '+event.eventtype(), debug=True)
-			return
-		
-		
 		# A string representation of the event
 		event_str = '\nconnection='+connection.__str__()+'\neventtype='+event.eventtype()+'\nsource='+repr(event.source())+'\ntarget='+repr(event.target())+'\narguments='+repr(event.arguments())
 		debug_str = 'Received IRC event.'+event_str
@@ -499,7 +486,7 @@ class Bot(threading.Thread):
 				return
 			
 			if event.eventtype() in ['quit', 'part', 'nick', 'kick']:
-				if connection.get_nickname() != self.nickname:
+				if connection.real_nickname != self.nickname:
 					self.error(1, 'ignoring IRC '+event.eventtype()+' not received on bot connection', debug=True)
 					return
 				else:
@@ -511,7 +498,7 @@ class Bot(threading.Thread):
 				return
 			
 			if event.eventtype() in ['pubmsg', 'action']:
-				if connection.get_nickname() != self.nickname:
+				if connection.real_nickname != self.nickname:
 					self.error(1, 'ignoring IRC '+event.eventtype()+' not received on bot connection', debug=True)
 					return
 				if nickname == self.nickname:
@@ -654,17 +641,17 @@ class Bot(threading.Thread):
 			if len(bridges) > 1:
 				raise Exception, 'more than one bridge for one irc chan, WTF ?'
 			bridge = bridges[0]
-			if connection.get_nickname() == self.nickname:
+			if connection.real_nickname == self.nickname:
 				bridge._join_irc_failed(event.eventtype())
 			else:
-				p = bridge.get_participant(connection.get_nickname())
+				p = bridge.get_participant(connection.real_nickname)
 				p._close_irc_connection('')
 				p.irc_connection = event.eventtype()
 			return
 		
 		
 		# Ignore events not received on bot connection
-		if connection.get_nickname() != self.nickname:
+		if connection.real_nickname != self.nickname:
 			self.error(1, 'ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True)
 			return