mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Added a listCommands method to PrivmsgRegexp, to allow plugins to list their own commands.
This commit is contained in:
parent
4125f97381
commit
fdddefe129
@ -125,28 +125,13 @@ class Misc(callbacks.Privmsg):
|
|||||||
else:
|
else:
|
||||||
irc.reply('There are no public plugins.')
|
irc.reply('There are no public plugins.')
|
||||||
else:
|
else:
|
||||||
if isinstance(cb, callbacks.PrivmsgRegexp) or \
|
commands = cb.listCommands()
|
||||||
not isinstance(cb, callbacks.Privmsg):
|
if commands:
|
||||||
irc.error('That plugin exists, but it has no commands. '
|
commands.sort()
|
||||||
'You may wish to check if it has any useful '
|
irc.reply(format('%L', commands))
|
||||||
'configuration variables with the command '
|
|
||||||
'"config list supybot.plugins.%s".' % cb.name())
|
|
||||||
else:
|
else:
|
||||||
name = callbacks.canonicalName(cb.name())
|
irc.error('That plugin exists, but it has no '
|
||||||
commands = []
|
'commands with help.')
|
||||||
for s in dir(cb):
|
|
||||||
if cb.isCommand(s) and \
|
|
||||||
(s != name or cb._original) and \
|
|
||||||
s == callbacks.canonicalName(s):
|
|
||||||
method = getattr(cb, s)
|
|
||||||
if hasattr(method, '__doc__') and method.__doc__:
|
|
||||||
commands.append(s)
|
|
||||||
if commands:
|
|
||||||
commands.sort()
|
|
||||||
irc.reply(format('%L', commands))
|
|
||||||
else:
|
|
||||||
irc.error('That plugin exists, but it has no '
|
|
||||||
'commands with help.')
|
|
||||||
list = wrap(list, [getopts({'private':''}), additional('plugin')])
|
list = wrap(list, [getopts({'private':''}), additional('plugin')])
|
||||||
|
|
||||||
def apropos(self, irc, msg, args, s):
|
def apropos(self, irc, msg, args, s):
|
||||||
|
@ -1115,6 +1115,19 @@ class Privmsg(irclib.IrcCallback):
|
|||||||
assert self.isCommand(name), format('%s is not a command.', name)
|
assert self.isCommand(name), format('%s is not a command.', name)
|
||||||
return getattr(self, name)
|
return getattr(self, name)
|
||||||
|
|
||||||
|
def listCommands(self):
|
||||||
|
commands = []
|
||||||
|
name = canonicalName(self.name())
|
||||||
|
for s in dir(self):
|
||||||
|
if self.isCommand(s) and \
|
||||||
|
(s != name or self._original) and \
|
||||||
|
s == canonicalName(s):
|
||||||
|
method = getattr(self, s)
|
||||||
|
if hasattr(method, '__doc__') and method.__doc__:
|
||||||
|
commands.append(s)
|
||||||
|
commands.sort()
|
||||||
|
return commands
|
||||||
|
|
||||||
def callCommand(self, name, irc, msg, *L, **kwargs):
|
def callCommand(self, name, irc, msg, *L, **kwargs):
|
||||||
checkCapabilities = kwargs.pop('checkCapabilities', True)
|
checkCapabilities = kwargs.pop('checkCapabilities', True)
|
||||||
if checkCapabilities:
|
if checkCapabilities:
|
||||||
@ -1283,6 +1296,9 @@ class PrivmsgRegexp(Privmsg):
|
|||||||
value.__doc__, e)
|
value.__doc__, e)
|
||||||
utils.gen.sortBy(operator.itemgetter(1), self.res)
|
utils.gen.sortBy(operator.itemgetter(1), self.res)
|
||||||
|
|
||||||
|
def isCommand(self):
|
||||||
|
return []
|
||||||
|
|
||||||
def callCommand(self, name, irc, msg, *L, **kwargs):
|
def callCommand(self, name, irc, msg, *L, **kwargs):
|
||||||
try:
|
try:
|
||||||
self.__parent.callCommand(name, irc, msg, *L, **kwargs)
|
self.__parent.callCommand(name, irc, msg, *L, **kwargs)
|
||||||
|
Loading…
Reference in New Issue
Block a user