mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-20 09:29:24 +01:00
RFE #810366: --private option to MiscCommands.list.
This commit is contained in:
parent
3a329b04f9
commit
d2eff8fdaf
@ -81,16 +81,21 @@ class MiscCommands(callbacks.Privmsg):
|
||||
irc.queueMsg(callbacks.reply(msg, s))
|
||||
|
||||
def list(self, irc, msg, args):
|
||||
"""[<module name>]
|
||||
"""[--private] [<module name>]
|
||||
|
||||
Lists the commands available in the given plugin. If no plugin is
|
||||
given, lists the public plugins available.
|
||||
given, lists the public plugins available. If --private is given,
|
||||
lists all commands, not just the public ones.
|
||||
"""
|
||||
name = privmsgs.getArgs(args, needed=0, optional=1)
|
||||
(optlist, rest) = getopt.getopt(args, '', ['private'])
|
||||
for (option, argument) in optlist:
|
||||
if option == '--private':
|
||||
evenPrivate = True
|
||||
name = privmsgs.getArgs(rest, needed=0, optional=1)
|
||||
name = name.lower()
|
||||
if not name:
|
||||
names = [cb.name() for cb in irc.callbacks
|
||||
if hasattr(cb, 'public') and cb.public]
|
||||
if evenPrivate or hasattr(cb, 'public') and cb.public]
|
||||
names.sort()
|
||||
irc.reply(msg, ', '.join(names))
|
||||
else:
|
||||
@ -106,7 +111,7 @@ class MiscCommands(callbacks.Privmsg):
|
||||
irc.reply(msg, ', '.join(commands))
|
||||
return
|
||||
irc.error(msg, 'There is no plugin named %s, ' \
|
||||
'or that plugin has no commands.' % name)
|
||||
'or that plugin has no commands.' % name)
|
||||
|
||||
def help(self, irc, msg, args):
|
||||
"""<command>
|
||||
|
@ -32,7 +32,7 @@
|
||||
from test import *
|
||||
|
||||
class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
plugins = ('MiscCommands', 'Utilities', 'ChannelDB')
|
||||
plugins = ('MiscCommands', 'Utilities', 'ChannelDB', 'Ctcp')
|
||||
def testReplyWhenNotCommand(self):
|
||||
try:
|
||||
conf.replyWhenNotCommand = True
|
||||
@ -71,6 +71,13 @@ class MiscCommandsTestCase(ChannelPluginTestCase, PluginDocumentation):
|
||||
def testList(self):
|
||||
self.assertNotError('list MiscCommands')
|
||||
self.assertNotError('list misccommands')
|
||||
# If Ctcp changes to public, these tests will break. So if
|
||||
# the next assert fails, change the plugin we test for public/private
|
||||
# to some other non-public plugin.
|
||||
name = 'Ctcp'
|
||||
self.failIf(self.irc.getCallback(name).public)
|
||||
self.assertNotRegexp('list', name)
|
||||
self.assertRegexp('list --private', name)
|
||||
|
||||
def testBug(self):
|
||||
self.assertNotError('bug')
|
||||
|
Loading…
Reference in New Issue
Block a user