From: John Runyon Date: Wed, 13 Mar 2024 02:31:21 +0000 (-0600) Subject: control - use new flags feature X-Git-Url: https://jfr.im/git/erebus.git/commitdiff_plain/1a22718c01b73a6cdc5ff3e92b12fc74f5364181 control - use new flags feature --- diff --git a/modules/control.py b/modules/control.py index 693770d..4939fa1 100644 --- a/modules/control.py +++ b/modules/control.py @@ -34,20 +34,11 @@ def die(bot, user, chan, realtarget, *args): @lib.hook(needchan=False, glevel=lib.MANAGER) @lib.help("[-autoload] ", "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) @@ -60,23 +51,12 @@ def modload(bot, user, chan, realtarget, *args): @lib.hook(needchan=False, glevel=lib.MANAGER) @lib.help("[-force] [-autoload] ", "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, "Incorrect syntax - can only name one module") - return - module = arg - elif arg.lower() == "-autoload": - autoload = True - elif arg.lower() == "-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)