def do_reload(self, c, target, cmdargs, msgtype): """The reloading magic. | First, reload handler.py. | Then make copies of all the handler data we want to keep. | Create a new handler and restore all the data. """ output = None if cmdargs == 'pull': output = misc.do_pull(dirname(__file__), c.real_nickname) c.privmsg(target, output) for x in modutils.get_enabled(dirname(__file__) + '/helpers'): imp.reload(sys.modules['helpers.%s' % x]) imp.reload(handler) self.config = ConfigParser() configfile = join(dirname(__file__), 'config.cfg') self.config.read_file(open(configfile)) # preserve data data = self.handler.get_data() self.do_shutdown() self.handler = handler.BotHandler(self.config) self.server = server.init_server(self) self.handler.set_data(data) self.handler.connection = c self.handler.channels = self.channels workers.start_workers(self.handler) if output: return output
def do_welcome(self, c): """Do setup when connected to server. | Pass the connection to handler. | Join the primary channel. | Join the control channel. """ logging.info("Connected to server %s" % self.config['core']['host']) self.handler.connection = c self.handler.channels = self.channels self.handler.get_admins(c) c.join(self.config['core']['channel']) c.join(self.config['core']['ctrlchan'], self.config['auth']['ctrlkey']) workers.start_workers(self.handler) extrachans = self.config['core']['extrachans'] if extrachans: extrachans = [x.strip() for x in extrachans.split(',')] for i in range(len(extrachans)): defer.defer(i, c.join, extrachans[i])