Added an apropos command.

This commit is contained in:
Jeremy Fincher 2003-10-22 04:32:29 +00:00
parent e8284ca938
commit d28b015b52
2 changed files with 21 additions and 0 deletions

View File

@ -157,6 +157,23 @@ class Misc(callbacks.Privmsg):
irc.error(msg, 'There is no plugin named %s, ' \ irc.error(msg, 'There is no plugin named %s, ' \
'or that plugin has no commands.' % name) 'or that plugin has no commands.' % name)
def apropos(self, irc, msg, args):
"""<string>
Searches for <string> 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): def help(self, irc, msg, args):
"""[<plugin>] <command> """[<plugin>] <command>

View File

@ -135,6 +135,10 @@ class MiscTestCase(ChannelPluginTestCase, PluginDocumentation):
def testHostmask(self): def testHostmask(self):
self.assertResponse('hostmask', self.prefix) self.assertResponse('hostmask', self.prefix)
def testApropos(self):
self.assertNotError('apropos f')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: