print "%09.3f [MOD] [?] Loading %s..." % (time.time() % 100000, modname),
modstatus = _load(parent, modname, dependent)
if not modstatus:
- print str(modstatus)
+ if dependent:
+ print "failed: %s)" % (modstatus),
+ else:
+ print "failed: %s." % (modstatus)
elif modstatus == True:
if dependent:
print "OK)",
else:
print "OK."
else:
- print modstatus
+ if dependent:
+ print "OK: %s)" % (modstatus),
+ else:
+ print "OK: %s." % (modstatus)
return modstatus
def _load(parent, modname, dependent=False):
+ successstatus = []
if not isloaded(modname):
try:
mod = __import__('modules.'+modname, globals(), locals(), ['*'], -1)
dependents[modname] = []
for dep in mod.modinfo['depends']:
- if dep not in modules:
- depret = load(parent, dep, dependent=True)
- if depret is not None and not depret:
- return depret #TODO FIXME
+ if bool(int(parent.cfg.get('autoloads', dep, default=1))):
+ if dep not in modules:
+ depret = load(parent, dep, dependent=True)
+ if depret is not None and not depret:
+ return depret
+ else:
+ return modlib.error("dependent %s disabled" % (dep))
dependents[dep].append(modname)
+ for dep in mod.modinfo['softdeps']:
+ if bool(int(parent.cfg.get('autoloads', dep, default=1))):
+ if dep not in modules:
+ depret = load(parent, dep, dependent=True)
+ if depret is not None:
+ if not depret:
+ successstatus.append("softdep %s failed" % (dep))
+ else:
+ successstatus.append("softdep %s disabled" % (dep))
+ #swallow errors loading - softdeps are preferred, not required
+
ret = mod.modstart(parent)
- if ret is not None and not ret:
+ if ret is None:
+ ret = True
+ if not ret:
del modules[modname]
del dependents[modname]
for dep in mod.modinfo['depends']:
dependents[dep].remove(modname)
- return ret
+
+ successstatus = ';'.join(successstatus)
+ if len(successstatus) > 0 and ret:
+ if ret == True:
+ return successstatus
+ else:
+ return "%s (%s)" % (ret, successstatus)
+ else:
+ return ret
else: #if not isloaded...else:
return modlib.error('already loaded')
import bot, config, ctlmod
class Erebus(object): #singleton to pass around
- APIVERSION = 1
+ APIVERSION = 2
RELEASE = 0
bots = {}
self.name = (name.split("."))[-1]
def modstart(self, parent):
+ #modstart can return a few things...
+ # None: unspecified success
+ # False: unspecified error
+ # modlib.error (or anything else False-y): specified error
+ # True: unspecified success
+ # non-empty string (or anything else True-y): specified success
+ #"specified" values will be printed. unspecified values will result in "OK" or "failed"
self.parent = parent
for cmd, func in self.hooks.iteritems():
self.parent.hook(cmd, func)
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
}
# preamble
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1],
+ 'compatible': [1,2],
'depends': [],
+ 'softdeps': ['help'],
}
# preamble
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1],
+ 'compatible': [1,2],
'depends': [],
+ 'softdeps': ['help'],
}
# preamble
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
+ 'compatible': [1,2], # compatible module API versions
'depends': [], # other modules required to work properly?
+ 'softdeps': ['help'], # modules which are preferred but not required
}
+# note: softdeps will be loaded before this module, IF not disabled in the configuration (autoload.module = 0) (and if it exists)
+# however, if it is disabled it will be silently ignored, and if it is unloaded at runtime it won't cause this one to unload.
+#
+# basically, softdeps are things this module will use if available, but does not require (no errors will occur if it's not loaded)
+# for example, @lib.help() will attempt to use the help module, but swallow errors if it is not loaded
# preamble
import modlib
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
}
# preamble
# Erebus IRC bot - Author: Erebus Team
-# simple module example
+# resource-usage module
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],
}
# preamble
# Erebus IRC bot - Author: Erebus Team
-# simple module example
+# twilio sms module
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],
}
# preamble
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': ['userinfo'], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': ['userinfo'],
+ 'softdeps': ['help'],
}
# preamble
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': [],
}
# http://embed.ly/tools/generator
# Erebus IRC bot - Author: Erebus Team
-# trivia module
+# userinfo module
# This file is released into the public domain; see http://unlicense.org/
# module info
modinfo = {
'author': 'Erebus Team',
'license': 'public domain',
- 'compatible': [1], # compatible module API versions
- 'depends': [], # other modules required to work properly?
+ 'compatible': [1,2],
+ 'depends': [],
+ 'softdeps': ['help'],
}
# preamble