mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-07 19:49:23 +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 True
|
||||||
return False
|
return False
|
||||||
everythingReplace(tokens)
|
everythingReplace(tokens)
|
||||||
|
Owner = irc.getCallback('Owner')
|
||||||
|
Owner.disambiguate(irc, tokens)
|
||||||
self.Proxy(irc.irc, msg, tokens)
|
self.Proxy(irc.irc, msg, tokens)
|
||||||
f = types.FunctionType(f.func_code, f.func_globals,
|
f = types.FunctionType(f.func_code, f.func_globals,
|
||||||
name, closure=f.func_closure)
|
name, closure=f.func_closure)
|
||||||
|
@ -88,7 +88,9 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
setattr(self.__class__, 'exec', self.__class__._exec)
|
setattr(self.__class__, 'exec', self.__class__._exec)
|
||||||
self.defaultPlugins = {}
|
self.defaultPlugins = {}
|
||||||
|
|
||||||
def _disambiguate(self, irc, tokens, ambiguousCommands):
|
def disambiguate(self, irc, tokens, ambiguousCommands=None):
|
||||||
|
if ambiguousCommands is None:
|
||||||
|
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:
|
||||||
@ -104,7 +106,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
ambiguousCommands[command] = names
|
ambiguousCommands[command] = names
|
||||||
for elt in tokens:
|
for elt in tokens:
|
||||||
if isinstance(elt, list):
|
if isinstance(elt, list):
|
||||||
self._disambiguate(irc, elt, ambiguousCommands)
|
self.disambiguate(irc, elt, ambiguousCommands)
|
||||||
|
|
||||||
def doPrivmsg(self, irc, msg):
|
def doPrivmsg(self, irc, msg):
|
||||||
callbacks.Privmsg.handled = False
|
callbacks.Privmsg.handled = False
|
||||||
@ -118,7 +120,7 @@ class Owner(privmsgs.CapabilityCheckingPrivmsg):
|
|||||||
irc.queueMsg(callbacks.error(msg, str(e)))
|
irc.queueMsg(callbacks.error(msg, str(e)))
|
||||||
return
|
return
|
||||||
ambiguousCommands = {}
|
ambiguousCommands = {}
|
||||||
self._disambiguate(irc, tokens, ambiguousCommands)
|
self.disambiguate(irc, tokens, ambiguousCommands)
|
||||||
if ambiguousCommands:
|
if ambiguousCommands:
|
||||||
if len(ambiguousCommands) == 1: # Common case.
|
if len(ambiguousCommands) == 1: # Common case.
|
||||||
(command, names) = ambiguousCommands.popitem()
|
(command, names) = ambiguousCommands.popitem()
|
||||||
|
@ -231,7 +231,7 @@ def tokenize(s):
|
|||||||
_lastTokenized = None
|
_lastTokenized = None
|
||||||
_lastTokenizedResult = None
|
_lastTokenizedResult = None
|
||||||
raise SyntaxError, str(e)
|
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)
|
return copy.deepcopy(_lastTokenizeResult)
|
||||||
|
|
||||||
def getCommands(tokens):
|
def getCommands(tokens):
|
||||||
@ -328,7 +328,8 @@ class IrcObjectProxy:
|
|||||||
self._callInvalidCommands()
|
self._callInvalidCommands()
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
assert len(cbs) == 1
|
assert len(cbs) == 1, \
|
||||||
|
'Got command that wasn\'t disambiguated: %s' % name
|
||||||
del self.args[0]
|
del self.args[0]
|
||||||
cb = cbs[0]
|
cb = cbs[0]
|
||||||
anticap = ircdb.makeAntiCapability(name)
|
anticap = ircdb.makeAntiCapability(name)
|
||||||
|
Loading…
Reference in New Issue
Block a user