from collections import deque
-@lib.hook(('die','restart'), needchan=False, glevel=lib.MANAGER)
+@lib.hook(('die','restart','exit'), needchan=False, glevel=lib.MANAGER)
@lib.help(None, "stops the bot")
def die(bot, user, chan, realtarget, *args):
quitmsg = ' '.join(args)
@lib.hook(needchan=False, glevel=lib.MANAGER)
@lib.help("[-autoload] <mod>", "loads a module, optionally marking it for autoloading")
-@lib.argsGE(1)
-def modload(bot, user, chan, realtarget, *args):
- module = None
- autoload = False
- for arg in args:
- if arg[0] != "-":
- if module is not None:
- bot.msg(user, "Wrong number of arguments.")
- return
- module = arg
- elif arg == "-autoload":
- autoload = True
- else:
- bot.msg(user, "Bad option %s" % (arg))
+@lib.flags('autoload')
+@lib.argsEQ(1)
+def modload(bot, user, chan, realtarget, flags, *args):
+ autoload = flags['autoload']
+ module = args[0]
if autoload:
bot.parent.cfg.set('autoloads', module, 1)
@lib.hook(needchan=False, glevel=lib.MANAGER)
@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.argsGE(1)
-def modunload(bot, user, chan, realtarget, *args):
- module = None
- autoload = False
- force = False
- for arg in args:
- if arg[0] != "-":
- if module is not None:
- bot.msg(user, "Wrong number of arguments.")
- return
- module = arg
- elif arg == "-autoload":
- autoload = True
- elif arg == "-force":
- force = True
- else:
- bot.msg(user, "Bad option %s" % (arg))
+@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)
return
if len(ctlmod.dependents[module]) > 0:
if not force:
- bot.msg(user, "That module has dependents! Say MODUNLOAD %s FORCE to unload it and any dependents." % (module))
+ bot.msg(user, "That module has dependents! Say MODUNLOAD -force %s to unload it and any dependents." % (module))
return
okay = ctlmod.unload(bot.parent, module)