mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-02 17:29:22 +01:00
Made Aliases disambiguate themselves, and made that API in Owner public.
This commit is contained in:
parent
b8c94599fc
commit
e4f912fc51
@ -144,6 +144,8 @@ def makeNewAlias(name, alias):
|
||||
return True
|
||||
return False
|
||||
everythingReplace(tokens)
|
||||
Owner = irc.getCallback('Owner')
|
||||
Owner.disambiguate(irc, tokens)
|
||||
self.Proxy(irc.irc, msg, tokens)
|
||||
f = types.FunctionType(f.func_code, f.func_globals,
|
||||
name, closure=f.func_closure)
|
||||
|
@ -88,7 +88,9 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
setattr(self.__class__, 'exec', self.__class__._exec)
|
||||
self.defaultPlugins = {}
|
||||
|
||||
def _disambiguate(self, irc, tokens, ambiguousCommands):
|
||||
def disambiguate(self, irc, tokens, ambiguousCommands=None):
|
||||
if ambiguousCommands is None:
|
||||
ambiguousCommands = {}
|
||||
if tokens:
|
||||
command = callbacks.canonicalName(tokens[0])
|
||||
if command in self.defaultPlugins:
|
||||
@ -104,7 +106,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
ambiguousCommands[command] = names
|
||||
for elt in tokens:
|
||||
if isinstance(elt, list):
|
||||
self._disambiguate(irc, elt, ambiguousCommands)
|
||||
self.disambiguate(irc, elt, ambiguousCommands)
|
||||
|
||||
def doPrivmsg(self, irc, msg):
|
||||
callbacks.Privmsg.handled = False
|
||||
@ -118,7 +120,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||
return
|
||||
ambiguousCommands = {}
|
||||
self._disambiguate(irc, tokens, ambiguousCommands)
|
||||
self.disambiguate(irc, tokens, ambiguousCommands)
|
||||
if ambiguousCommands:
|
||||
if len(ambiguousCommands) == 1: # Common case.
|
||||
(command, names) = ambiguousCommands.popitem()
|
||||
|
@ -231,7 +231,7 @@ def tokenize(s):
|
||||
_lastTokenized = None
|
||||
_lastTokenizedResult = None
|
||||
raise SyntaxError, str(e)
|
||||
#debug.msg('tokenize took %s seconds.' % (time.time() - start), 'verbose')
|
||||
debug.msg('tokenize took %s seconds.' % (time.time() - start), 'verbose')
|
||||
return copy.deepcopy(_lastTokenizeResult)
|
||||
|
||||
def getCommands(tokens):
|
||||
@ -328,7 +328,8 @@ class IrcObjectProxy:
|
||||
self._callInvalidCommands()
|
||||
else:
|
||||
try:
|
||||
assert len(cbs) == 1
|
||||
assert len(cbs) == 1, \
|
||||
'Got command that wasn\'t disambiguated: %s' % name
|
||||
del self.args[0]
|
||||
cb = cbs[0]
|
||||
anticap = ircdb.makeAntiCapability(name)
|
||||
|
Loading…
Reference in New Issue
Block a user