X-Git-Url: https://jfr.im/git/erebus.git/blobdiff_plain/a148e37fa5bebe6d0807d076f3deeab6dd28452b..2564f20844e0fdd2354f0cb94599eddc93d6e41a:/modules/help.py diff --git a/modules/help.py b/modules/help.py index 9c66731..f07320c 100644 --- a/modules/help.py +++ b/modules/help.py @@ -24,6 +24,7 @@ def modstart(parent, *args, **kwargs): modstop = lib.modstop # module code +import functools import os.path helps = {} cmds = {} @@ -63,6 +64,7 @@ def dereghelp(func, *args, **kwargs): del cmds[c] del helps[func] +@functools.total_ordering class HelpLine(object): def __init__(self, cmd, syntax, shorthelp, admin, glevel, module, clevel): self.cmd = cmd @@ -73,6 +75,15 @@ class HelpLine(object): self.module = module self.clevel = clevel + def __lt__(self, other): + if self.glevel == other.glevel: + return self.cmd < other.cmd + else: + return self.glevel < other.glevel + + def __eq__(self, other): + return self.glevel == other.glevel and self.cmd == other.cmd + def __cmp__(self, other): if self.glevel == other.glevel: return cmp(self.cmd, other.cmd) @@ -186,7 +197,7 @@ def help_nolag(bot, user, chan, realtarget, *args): if len(args) == 0: # list commands lines = [] for func in helps.values(): - lines += _mkhelp(user, func) + lines += _mkhelp(user.glevel, func) for line in sorted(lines): bot.slowmsg(user, str(line)) bot.slowmsg(user, "End of command listing.") @@ -195,7 +206,7 @@ def help_nolag(bot, user, chan, realtarget, *args): mod = args[0][1:].lower() for func in helps.values(): if func.module == mod: - lines += _mkhelp(user, func) + lines += _mkhelp(user.glevel, func) for line in sorted(lines): bot.slowmsg(user, str(line)) bot.slowmsg(user, "End of command listing.")