From aa4a469c1a3696d184d6fa2f25863a85b59c1d54 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 25 Aug 2012 09:37:17 -0400 Subject: [PATCH] Preparing IRC setup. --- irker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/irker.py b/irker.py index 7219e30..5c7c988 100755 --- a/irker.py +++ b/irker.py @@ -18,7 +18,8 @@ class SessionException(exceptions.Exception): class Session(): "IRC session and message queue processing." - def __init__(self, url): + count = 1 + def __init__(self, ircserver, url): self.url = url # The consumer thread self.queue = Queue.Queue() @@ -38,9 +39,10 @@ class Session(): raise SessionException("invalid port number") else: self.port = 6667 - (self.server, self.channel) = parts[0].split("/", 1) + (self.servername, self.channel) = parts[0].split("/", 1) # Client setup - self.client = irclib.SimpleIRCClient() + #self.ircserver.connect(self.servername, self.port, "irk"+str(Session.count)) + Session.count += 1 def enqueue(self, message): "Enque a message for transmission." self.queue.put(message) @@ -60,6 +62,7 @@ class Session(): class Irker: "Persistent IRC multiplexer." def __init__(self): + self.irc = irclib.IRC() self.sessions = {} def logerr(self, errmsg): "Log a processing error." @@ -86,7 +89,7 @@ class Irker: channel = request['channel'] message = request['message'] if channel not in self.sessions: - self.sessions[channel] = Session(channel) + self.sessions[channel] = Session(self.irc.server(), channel) self.sessions[channel].enqueue(message) if __name__ == '__main__': -- 2.26.2