def _on_disconnect(self, c, e): """[Internal]""" self.channels = IRCDict() if self.runCond: self.connection.execute_delayed(self.reconnection_interval, self._connected_checker) if hasattr(self, "disconnect_event"): self.disconnect_event.set()
def __init__(self, channels=[], nickname="", password="", realname="", server="", port=6667, module_list=[], encoding=""): """MooBot initializer - gets values from config files and uses those unless passed values directly""" Debug("possible config files: " + ", ".join(self.config_files)) # Get values from config files and replace any of the empty ones above configs = self.get_configs() config_nick = configs['nick'] config_username = configs['username'] config_realname = configs['realname'] config_server = configs['server'] config_port = configs['port'] config_encoding = configs['encoding'] config_password = configs['password'] config_channels = configs['channels'] config_module_list = configs['module_list'] config_others = configs['others'] # If we are passed any values directly, use those, but if they are empty # we will fall back to the values we got from the config file # for var in \ # ['channels', 'nickname', 'username', 'server', # 'port', 'module_list', 'others']: # if kwargs.has_key(var): # if kwargs.has_key('channels'): channels = kwargs['channels'] # else: channels = config_channels if channels == []: channels = config_channels if nickname == "": nickname = config_nick if realname == "": realname = config_realname if server == "": server = config_server if port == 6667: port = config_port if password == "": password = config_password if module_list == []: module_list = config_module_list if encoding == "": encoding = config_encoding # Now that we have our values, initialize it all SingleServerIRCBot.__init__( self, [(server, port, password, encoding.upper())], nickname, realname) self.serve_nick = config_nick self.serve_password = config_password self.serve_channels = [ channel for channel in channels if channel.strip() ] self.channels = IRCDict() self.handlers = {} self.configs = config_others self.module_list = module_list
def __init__(self, botConfig): CNBCon.__init__(self, botConfig) config = CNBConfig.getInstance() username = botConfig.get('bot', 'username') nickname = username realname = username channels = botConfig.get('bot', 'channels') password = botConfig.get('bot', 'password') server = botConfig.get('bot', 'server') autostart = botConfig.get('bot', 'auto-start') autoreconnect = botConfig.get('bot', 'auto-reconnect') reconInterval = 60 self.ircobj = IRC() self.connection = self.ircobj.server() self.dcc_connections = [] self.ircobj.add_global_handler("all_events", self._dispatcher, -10) #self.ircobj.add_global_handler("dcc_disconnect", self._dcc_disconnect, -10) self.autoReconnect = autoreconnect self.server_list.append([server, self.IRC_PORT]) self.channelsToJoin = channels self.channels = IRCDict() if not reconInterval or reconInterval < 0: reconInterval = 2**31 self.reconInterval = reconInterval self._nickname = nickname self._realname = realname self._password = password if autostart == '1': self.log.info('Auto-start = 1') self.startBot() if autoreconnect == '1': self.log.info('Auto-reconnect = 1')
def _on_disconnect(self, c, e): """[Internal]""" self.channels = IRCDict() self.connection.execute_delayed(self.reconInterval, self._connected_checker)