def __init__(self, server, port, channels, nick, db, loop=None): irclib.SimpleIRCClient.__init__(self) # tornado ioloop if loop is None: loop = ioloop.IOLoop.instance() self.loop = loop self._last_connected = time.time() self._reconnect_interval = 30 #IRC details self.server = server self.port = port self.channels = channels self.names = {} for channel in self.channels: self.names[channel] = set() self.nick = nick #DB details self.db = IRCDatabase( db ) #Regexes self.nick_reg = re.compile("^" + nick + "[:,](?iu)") #Message Cache self.message_cache = [] #messages are stored here before getting pushed to the db #Disconnect Countdown self.disconnect_countdown = 5 self._connect() self.last_ping = time.time() self.ping_callback = pc = ioloop.PeriodicCallback(self._no_ping, 60000, self.loop) pc.start()