mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-11 12:42:34 +01:00
Add a pluginCommands kwarg to Commands.listCommands.
Plugins which implement their own listCommands method should pass their non-typically discoverable commands to Commands.listCommands via this mechanism. This means that the de-duplication of commands is performed in one spot instead of having each plugin implement it on their on in their listCommands method. This reverts commits 0ce829af6215b97e725f4d6d580d1151950be869 and 09fb0e6fc974445a3414fb03a94625f8538d4570. Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
parent
fa3a2dd23b
commit
54dda880d4
@ -1,5 +1,6 @@
|
||||
###
|
||||
# Copyright (c) 2002-2004, Jeremiah Fincher
|
||||
# Copyright (c) 2009, James Vega
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
@ -202,6 +203,9 @@ class Alias(callbacks.Plugin):
|
||||
else:
|
||||
return True
|
||||
|
||||
def listCommands(self):
|
||||
return self.__parent.listCommands(self.aliases.keys())
|
||||
|
||||
def getCommandMethod(self, command):
|
||||
try:
|
||||
return self.__parent.getCommandMethod(command)
|
||||
|
@ -90,6 +90,9 @@ class RSS(callbacks.Plugin):
|
||||
else:
|
||||
return True
|
||||
|
||||
def listCommands(self):
|
||||
return self.__parent.listCommands(self.feedNames.keys())
|
||||
|
||||
def getCommandMethod(self, command):
|
||||
try:
|
||||
return self.__parent.getCommandMethod(command)
|
||||
|
@ -1145,20 +1145,21 @@ class Commands(BasePlugin):
|
||||
else:
|
||||
raise AttributeError
|
||||
|
||||
def listCommands(self):
|
||||
commands = []
|
||||
def listCommands(self, pluginCommands=[]):
|
||||
commands = set(pluginCommands)
|
||||
for s in dir(self):
|
||||
if self.isCommandMethod(s):
|
||||
commands.append(s)
|
||||
commands.add(s)
|
||||
for cb in self.cbs:
|
||||
name = cb.canonicalName()
|
||||
for command in cb.listCommands():
|
||||
if command == name:
|
||||
commands.append(command)
|
||||
commands.add(command)
|
||||
else:
|
||||
commands.append(' '.join([name, command]))
|
||||
commands.sort()
|
||||
return commands
|
||||
commands.add(' '.join([name, command]))
|
||||
L = list(commands)
|
||||
L.sort()
|
||||
return L
|
||||
|
||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||
method = self.getCommandMethod(command)
|
||||
|
Loading…
Reference in New Issue
Block a user