From d28b015b52c05e3dbd44fb2d416d6863ab294fad Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Wed, 22 Oct 2003 04:32:29 +0000 Subject: [PATCH] Added an apropos command. --- src/Misc.py | 17 +++++++++++++++++ test/test_Misc.py | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/src/Misc.py b/src/Misc.py index 8a7fbd6cc..47dc01725 100755 --- a/src/Misc.py +++ b/src/Misc.py @@ -157,6 +157,23 @@ class Misc(callbacks.Privmsg): irc.error(msg, 'There is no plugin named %s, ' \ 'or that plugin has no commands.' % name) + def apropos(self, irc, msg, args): + """ + + Searches for in the commands currently offered by the bot, + returning a list of the commands containing that string. + """ + s = privmsgs.getArgs(args) + L = [] + for cb in irc.callbacks: + if isinstance(cb, callbacks.Privmsg) and \ + not isinstance(cb, callbacks.PrivmsgRegexp): + for attr in dir(cb): + if s in attr and cb.isCommand(attr): + L.append(callbacks.canonicalName(attr)) + L.sort() + irc.reply(msg, utils.commaAndify(L)) + def help(self, irc, msg, args): """[] diff --git a/test/test_Misc.py b/test/test_Misc.py index 22cccc143..233786189 100644 --- a/test/test_Misc.py +++ b/test/test_Misc.py @@ -135,6 +135,10 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation): def testHostmask(self): self.assertResponse('hostmask', self.prefix) + def testApropos(self): + self.assertNotError('apropos f') + + # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: