def _load(parent, modname, dependent=False):
if not isloaded(modname):
- sys.path.insert(0, 'modules')
try:
- mod = __import__(modname)
+ mod = __import__('modules.'+modname, globals(), locals(), ['*'], -1)
+ # ^ fromlist doesn't actually do anything(?) but it means we don't have to worry about this returning the top-level "modules" object
reload(mod) #in case it's been previously loaded.
- except BaseException as e: #we don't want even sys.exit() to crash us (in case of malicious module) so use BaseException
+ except Exception as e:
return modlib.error(e)
- finally:
- del sys.path[0] #remove ./modules from path, in case there's a name conflict
if not hasattr(mod, 'modinfo'):
for m in modlist: unload(parent, m)
def reloadall(parent, modlist):
for m in modlist: reloadmod(parent, m)
-
-sys.path.append('modules')
self.helps = []
self.parent = None
- self.name = name
+ self.name = (name.split(".", 1))[1]
def modstart(self, parent):
self.parent = parent
def modlist(bot, user, chan, realtarget, *args):
mods = ctlmod.modules
for mod in mods.itervalues():
- bot.msg(user, "- %s (%s)" % (mod.__name__, mod.__file__))
+ bot.msg(user, "- %s (%s)" % ((mod.__name__.split(".", 1))[1], mod.__file__))
bot.msg(user, "Done.")
def _whois(user, chan, showglevel=True, showclevel=True):