changeset 123:75a03f10a863

Code refactoring (new method participant.set_both_sides()) Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Wed, 13 Jan 2010 22:27:00 +0100
parents 9e90e15913a7
children 99f3dee1fad7
files bridge.py participant.py
diffstat 2 files changed, 15 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/bridge.py
+++ b/bridge.py
@@ -145,17 +145,7 @@ class bridge:
 					if irc_id:
 						p.irc_connection.irc_id = irc_id
 					return p
-				self.bot.error('===> Debug: "'+nickname+'" is on both sides of bridge "'+str(self)+'"', debug=True)
-				self.say('[Warning] The nickname "'+nickname+'" is used on both sides of the bridge, please avoid that if possible')
-				if isinstance(p.irc_connection, ServerConnection):
-					p.irc_connection.close('')
-				if p.irc_connection != 'both':
-					p.irc_connection = 'both'
-				if isinstance(p.muc, xmpp.muc):
-					p.muc.leave('')
-					self.bot.close_xmpp_connection(p.nickname)
-				if p.xmpp_c != 'both':
-					p.xmpp_c = 'both'
+				p.set_both_sides()
 			return p
 		except NoSuchParticipantException:
 			pass
--- a/participant.py
+++ b/participant.py
@@ -170,6 +170,20 @@ class participant:
 				self.irc_connection = error
 	
 	
+	def set_both_sides(self):
+		self.bridge.bot.error('===> Debug: "'+self.nickname+'" is on both sides of bridge "'+str(self.bridge)+'"', debug=True)
+		self.bridge.say('[Warning] The nickname "'+self.nickname+'" is used on both sides of the bridge, please avoid that if possible')
+		if isinstance(self.irc_connection, ServerConnection):
+			self.irc_connection.close('')
+		if self.irc_connection != 'both':
+			self.irc_connection = 'both'
+		if isinstance(self.muc, xmpp.muc):
+			self.muc.leave('')
+			self.bridge.bot.close_xmpp_connection(self.nickname)
+		if self.xmpp_c != 'both':
+			self.xmpp_c = 'both'
+	
+	
 	def changeNickname(self, newnick, on_protocol):
 		"""Change participant's nickname."""