-@lib.help("<mod>", "unloads a module")
-@lib.argsGE(1)
-def modunload(bot, user, chan, realtarget, *args):
- if len(ctlmod.dependents[args[0]]) > 0:
- if len(args) == 1 or args[1].lower() != "force":
- bot.msg(user, "That module has dependents! Say MODUNLOAD %s FORCE to unload it and any dependents." % (args[0]))
+@lib.help("[-force] [-autoload] <mod>", "unloads a module", "will refuse to unload a module which is depended on by others unless you specify FORCE.", "optionally removes from autoloads")
+@lib.flags('force','autoload')
+@lib.argsEQ(1)
+def modunload(bot, user, chan, realtarget, flags, *args):
+ autoload = flags['autoload']
+ force = flags['force']
+ module = args[0]
+
+ if autoload:
+ bot.parent.cfg.delete('autoloads', module)
+ bot.msg(user, "Unmarked %s for autoloading." % (module))
+ if not ctlmod.isloaded(module):
+ bot.msg(user, "%s is not loaded" % (module))
+ return
+ if len(ctlmod.dependents[module]) > 0:
+ if not force:
+ bot.msg(user, "That module has dependents! Say MODUNLOAD -force %s to unload it and any dependents." % (module))