From 54e9b4be098388c8d86140d76c8d9ea1cec2a7da Mon Sep 17 00:00:00 2001 From: jacksonmj Date: Sat, 22 Aug 2015 11:08:34 +0000 Subject: [PATCH] Alias: add a list command to list aliases, optionally filtered by locked status ("list Alias" includes Alias plugin commands as well as aliases, and cannot be filtered by locked status) --- plugins/Alias/plugin.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/plugins/Alias/plugin.py b/plugins/Alias/plugin.py index d8e91da58..7ecd5f852 100644 --- a/plugins/Alias/plugin.py +++ b/plugins/Alias/plugin.py @@ -425,6 +425,36 @@ class Alias(callbacks.Plugin): irc.error(str(e)) remove = wrap(remove, ['commandName']) + @internationalizeDocstring + def list(self, irc, msg, args, optlist): + """[--{locked,unlocked}] + + Lists alias names of a particular type, defaults to all aliases if no + --locked or --unlocked option is given. + """ + optlist = dict(optlist) + if len(optlist)>1: + irc.error(_('Cannot specify --locked and --unlocked simultaneously')) + return + aliases = [] + for name in self.aliases.keys(): + if self.isCommandMethod(name): + if 'locked' in optlist: + if self.aliases[name][1]: aliases.append(name) + elif 'unlocked' in optlist: + if not self.aliases[name][1]: aliases.append(name) + else: + aliases.append(name) + if aliases: + aliases.sort() + irc.reply(format('%L', aliases)) + else: + if len(optlist): + irc.reply(_('There are no aliases of that type.')) + else: + irc.reply(_('There are no aliases.')) + list = wrap(list, [getopts({'locked':'', 'unlocked':''})]) + Class = Alias