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) 2002-2004, Jeremiah Fincher
|
||||||
|
# Copyright (c) 2009, James Vega
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -202,6 +203,9 @@ class Alias(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def listCommands(self):
|
||||||
|
return self.__parent.listCommands(self.aliases.keys())
|
||||||
|
|
||||||
def getCommandMethod(self, command):
|
def getCommandMethod(self, command):
|
||||||
try:
|
try:
|
||||||
return self.__parent.getCommandMethod(command)
|
return self.__parent.getCommandMethod(command)
|
||||||
|
@ -90,6 +90,9 @@ class RSS(callbacks.Plugin):
|
|||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def listCommands(self):
|
||||||
|
return self.__parent.listCommands(self.feedNames.keys())
|
||||||
|
|
||||||
def getCommandMethod(self, command):
|
def getCommandMethod(self, command):
|
||||||
try:
|
try:
|
||||||
return self.__parent.getCommandMethod(command)
|
return self.__parent.getCommandMethod(command)
|
||||||
|
@ -1145,20 +1145,21 @@ class Commands(BasePlugin):
|
|||||||
else:
|
else:
|
||||||
raise AttributeError
|
raise AttributeError
|
||||||
|
|
||||||
def listCommands(self):
|
def listCommands(self, pluginCommands=[]):
|
||||||
commands = []
|
commands = set(pluginCommands)
|
||||||
for s in dir(self):
|
for s in dir(self):
|
||||||
if self.isCommandMethod(s):
|
if self.isCommandMethod(s):
|
||||||
commands.append(s)
|
commands.add(s)
|
||||||
for cb in self.cbs:
|
for cb in self.cbs:
|
||||||
name = cb.canonicalName()
|
name = cb.canonicalName()
|
||||||
for command in cb.listCommands():
|
for command in cb.listCommands():
|
||||||
if command == name:
|
if command == name:
|
||||||
commands.append(command)
|
commands.add(command)
|
||||||
else:
|
else:
|
||||||
commands.append(' '.join([name, command]))
|
commands.add(' '.join([name, command]))
|
||||||
commands.sort()
|
L = list(commands)
|
||||||
return commands
|
L.sort()
|
||||||
|
return L
|
||||||
|
|
||||||
def callCommand(self, command, irc, msg, *args, **kwargs):
|
def callCommand(self, command, irc, msg, *args, **kwargs):
|
||||||
method = self.getCommandMethod(command)
|
method = self.getCommandMethod(command)
|
||||||
|
Loading…
Reference in New Issue
Block a user