changeset 221:1a82d5d40d90

moved irc_id handling to irclib Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sun, 07 Mar 2010 14:00:21 +0100
parents 5726a0833537
children 1439d3274e6a
files bot.py bridge.py irclib.py
diffstat 3 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bot.py
+++ b/bot.py
@@ -666,7 +666,7 @@ class Bot(threading.Thread):
 				return
 			elif event.eventtype() == 'join':
 				bridge = self.get_bridge(irc_room=event.target().lower(), irc_server=connection.server)
-				bridge.add_participant('irc', nickname, irc_id=event.source())
+				bridge.add_participant('irc', nickname)
 				return
 		
 		
--- a/bridge.py
+++ b/bridge.py
@@ -127,7 +127,7 @@ class Bridge:
 			self.stop(message='Failed to connect to the XMPP room, stopping bridge')
 	
 	
-	def add_participant(self, from_protocol, nickname, real_jid=None, irc_id=None):
+	def add_participant(self, from_protocol, nickname, real_jid=None):
 		"""Add a participant to the bridge."""
 		if (from_protocol == 'irc' and nickname == self.bot.nickname) or (from_protocol == 'xmpp' and nickname == self.bot.nickname):
 			self.bot.error(3, 'not adding self ('+self.bot.nickname+') to bridge "'+str(self)+'"', debug=True)
@@ -136,8 +136,6 @@ class Bridge:
 			p = self.get_participant(nickname)
 			if p.protocol != from_protocol:
 				if from_protocol == 'irc' and isinstance(p.irc_connection, ServerConnection) and p.irc_connection.logged_in and p.irc_connection.real_nickname == nickname or from_protocol == 'xmpp' and isinstance(p.xmpp_c, xmpp.client.Client) and isinstance(p.muc, xmpp.muc) and p.xmpp_c.nickname == nickname:
-					if irc_id:
-						p.irc_connection.irc_id = irc_id
 					return p
 				p.set_both_sides()
 			return p
--- a/irclib.py
+++ b/irclib.py
@@ -770,6 +770,11 @@ class ServerConnection(Connection):
                     if not is_channel(target):
                         command = "umode"
 
+                if command == "join":
+                    self.irc_id = prefix
+                    if DEBUG:
+                        print "irc_id: %s" % (prefix)
+
                 if DEBUG:
                     print "command: %s, source: %s, target: %s, arguments: %s" % (
                         command, prefix, target, arguments)