def __init__(self, config): irc.Bot.__init__(self, config.core) self.config = config """The ``Config`` for the current Willie instance.""" self.doc = {} """ A dictionary of command names to their docstring and example, if declared. The first item in a callable's commands list is used as the key in version *3.2* onward. Prior to *3.2*, the name of the function as declared in the source code was used. """ self.stats = {} """ A dictionary which maps a tuple of a function name and where it was used to the nuber of times it was used there. """ self.times = {} """ A dictionary mapping lower-case'd nicks to dictionaries which map funtion names to the time which they were last used by that nick. """ self.acivity = {} self.server_capabilities = set() """A set containing the IRCv3 capabilities that the server supports. For servers that do not support IRCv3, this will be an empty set.""" self.enabled_capabilities = set() """A set containing the IRCv3 capabilities that the bot has enabled.""" self._cap_reqs = dict() """A dictionary of capability requests Maps the capability name to a list of tuples of the prefix ('-', '=', or ''), the name of the requesting module, and the function to call if the request is rejected.""" self.privileges = dict() """A dictionary of channels to their users and privilege levels The value associated with each channel is a dictionary of Identifiers to a bitwise integer value, determined by combining the appropriate constants from `module`.""" self.db = WillieDB(config) """The bot's database.""" self.memory = tools.WillieMemory() """ A thread-safe dict for storage of runtime data to be shared between modules. See `WillieMemory <#tools.Willie.WillieMemory>`_ """ self.scheduler = Willie.JobScheduler(self) self.scheduler.start() #Set up block lists #Default to empty if not self.config.core.nick_blocks: self.config.core.nick_blocks = [] if not self.config.core.nick_blocks: self.config.core.host_blocks = [] #Add nicks blocked under old scheme, if present if self.config.core.other_bots: nicks = self.config.core.get_list('nick_blocks') bots = self.config.core.get_list('other_bots') nicks.extend(bots) self.config.core.nick_blocks = nicks self.config.core.other_bots = False self.config.save() self.setup()
def db(): config = Config('', False) config.core.db_filename = db_filename db = WillieDB(config) # TODO add tests to ensure db creation works properly, too. return db
def __init__(self, config, daemon=False): irc.Bot.__init__(self, config) self._daemon = daemon # Used for iPython. TODO something saner here # `re.compile('.*') is re.compile('.*')` because of caching, so we need # to associate a list with each regex, since they are unexpectedly # indistinct. self._callables = { 'high': collections.defaultdict(list), 'medium': collections.defaultdict(list), 'low': collections.defaultdict(list) } self.config = config """The ``Config`` for the current Willie instance.""" self.doc = {} """ A dictionary of command names to their docstring and example, if declared. The first item in a callable's commands list is used as the key in version *3.2* onward. Prior to *3.2*, the name of the function as declared in the source code was used. """ self.stats = {} """ A dictionary which maps a tuple of a function name and where it was used to the nuber of times it was used there. """ self.times = {} """ A dictionary mapping lower-case'd nicks to dictionaries which map funtion names to the time which they were last used by that nick. """ self.acivity = {} self.server_capabilities = set() """A set containing the IRCv3 capabilities that the server supports. For servers that do not support IRCv3, this will be an empty set.""" self.enabled_capabilities = set() """A set containing the IRCv3 capabilities that the bot has enabled.""" self._cap_reqs = dict() """A dictionary of capability requests Maps the capability name to a list of tuples of the prefix ('-', '=', or ''), the name of the requesting module, and the function to call if the request is rejected.""" self.privileges = dict() """A dictionary of channels to their users and privilege levels The value associated with each channel is a dictionary of Identifiers to a bitwise integer value, determined by combining the appropriate constants from `module`.""" self.db = WillieDB(config) """The bot's database.""" self.memory = tools.WillieMemory() """ A thread-safe dict for storage of runtime data to be shared between modules. See `WillieMemory <#tools.Willie.WillieMemory>`_ """ self.scheduler = willie.tools.jobs.JobScheduler(self) self.scheduler.start() # Set up block lists # Default to empty if not self.config.core.nick_blocks: self.config.core.nick_blocks = [] if not self.config.core.nick_blocks: self.config.core.host_blocks = [] self.setup()