mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-25 19:44:13 +01:00
Made it always default to src/ plugins unless explicitly overridden.
This commit is contained in:
parent
0de26afa99
commit
6b4d03fecc
26
src/Owner.py
26
src/Owner.py
@ -82,19 +82,27 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
# things will happen when adding callbacks.
|
# things will happen when adding callbacks.
|
||||||
priority = ~sys.maxint-1 # This must be first!
|
priority = ~sys.maxint-1 # This must be first!
|
||||||
capability = 'owner'
|
capability = 'owner'
|
||||||
|
_srcPlugins = ('Owner', 'Misc', 'Admin', 'User', 'Channel')
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
setattr(self.__class__, 'exec', self.__class__._exec)
|
setattr(self.__class__, 'exec', self.__class__._exec)
|
||||||
self.defaultPlugins = {'join': 'admin',
|
self.defaultPlugins = {}
|
||||||
'load': 'owner',
|
|
||||||
'reload': 'owner',
|
|
||||||
'unload': 'owner'}
|
|
||||||
|
|
||||||
def _disambiguate(self, tokens):
|
def _disambiguate(self, irc, tokens, ambiguousCommands):
|
||||||
if tokens:
|
if tokens:
|
||||||
command = callbacks.canonicalName(tokens[0])
|
command = callbacks.canonicalName(tokens[0])
|
||||||
if command in self.defaultPlugins:
|
if command in self.defaultPlugins:
|
||||||
tokens.insert(0, self.defaultPlugins[command])
|
tokens.insert(0, self.defaultPlugins[command])
|
||||||
|
else:
|
||||||
|
cbs = callbacks.findCallbackForCommand(irc, command)
|
||||||
|
if len(cbs) > 1:
|
||||||
|
names = [cb.name() for cb in cbs]
|
||||||
|
for name in names:
|
||||||
|
if name in self._srcPlugins:
|
||||||
|
tokens.insert(0, name)
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
ambiguousCommands[command] = names
|
||||||
for elt in tokens:
|
for elt in tokens:
|
||||||
if isinstance(elt, list):
|
if isinstance(elt, list):
|
||||||
self._disambiguate(elt)
|
self._disambiguate(elt)
|
||||||
@ -108,14 +116,8 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
except SyntaxError, e:
|
except SyntaxError, e:
|
||||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||||
return
|
return
|
||||||
self._disambiguate(tokens)
|
|
||||||
ambiguousCommands = {}
|
ambiguousCommands = {}
|
||||||
commands = callbacks.getCommands(tokens)
|
self._disambiguate(irc, tokens, ambiguousCommands)
|
||||||
for command in commands:
|
|
||||||
command = callbacks.canonicalName(command)
|
|
||||||
cbs = callbacks.findCallbackForCommand(irc, command)
|
|
||||||
if len(cbs) > 1:
|
|
||||||
ambiguousCommands[command] = [cb.name() for cb in cbs]
|
|
||||||
if ambiguousCommands:
|
if ambiguousCommands:
|
||||||
if len(ambiguousCommands) == 1: # Common case.
|
if len(ambiguousCommands) == 1: # Common case.
|
||||||
(command, names) = ambiguousCommands.popitem()
|
(command, names) = ambiguousCommands.popitem()
|
||||||
|
Loading…
Reference in New Issue
Block a user