# No user-serviceable parts below this line
-import sys, json, exceptions, getopt, urlparse, time
+import sys, json, getopt, urlparse, time
import threading, Queue, SocketServer
import irc.client, logging
# unreliable.
class Connection:
- def __init__(self, irker, servername, port):
- self.irker = irker
+ def __init__(self, irkerd, servername, port):
+ self.irker = irkerd
self.servername = servername
self.port = port
self.connection = None
"The server says our nick has a conflict."
self.irker.debug(1, "nick %s rejected" % self.nickname())
self.nick_trial += 1
- self.nick(self.nickname())
+ self.connection.nick(self.nickname())
def enqueue(self, channel, message):
"Enque a message for transmission."
self.queue.put((channel, message))
class Dispatcher:
"Manage connections to a particular server-port combination."
- def __init__(self, irker, servername, port):
- self.irker = irker
+ def __init__(self, irkerd, servername, port):
+ self.irker = irkerd
self.servername = servername
self.port = port
self.connections = []
"Debugging information."
if self.debuglevel >= level:
sys.stderr.write("irker: %s\n" % errmsg)
- def _handle_ping(self, connection, event):
+ def _handle_ping(self, connection, _event):
"PING arrived, bump the last-received time for the connection."
if connection.context:
connection.context.handle_ping()
- def _handle_welcome(self, connection, event):
+ def _handle_welcome(self, connection, _event):
"Welcome arrived, nick accepted for this connection."
if connection.context:
connection.context.handle_welcome()
- def _handle_badnick(self, connection, event):
+ def _handle_badnick(self, connection, _event):
"Nick not accepted for this connection."
if connection.context:
connection.context.handle_badnick()
for lump in event.arguments():
if lump.startswith("DEAF="):
connection.mode(connection.context.nickname(), "+"+lump[5:])
- def drop_server(servername, port):
+ def drop_server(self, servername, port):
"Drop a server out of the server map."
del self.servers[(servername, port)]
def handle(self, line):
if debuglvl > 1:
logging.basicConfig(level=logging.DEBUG)
elif opt == '-p': # Set the listening port
- port = int(val)
+ srvport = int(val)
elif opt == '-V': # Emit version and exit
sys.stdout.write("irker version %s\n" % version)
sys.exit(0)