From 645302a1630e26ef91ccaba94b3b8e7b080f1313 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Mon, 20 Oct 2003 11:34:54 +0000 Subject: [PATCH] Added handling for ambiguous commands to doPrivmsg. --- src/MiscCommands.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/MiscCommands.py b/src/MiscCommands.py index 6f44c711e..0c862d0d6 100755 --- a/src/MiscCommands.py +++ b/src/MiscCommands.py @@ -80,14 +80,28 @@ class MiscCommands(callbacks.Privmsg): if r.search(s): return notCommands = [] + ambiguousCommands = {} tokens = callbacks.tokenize(s) for command in callbacks.getCommands(tokens): command = callbacks.canonicalName(command) - if not callbacks.findCallbackForCommand(irc, command): + cbs = callbacks.findCallbackForCommand(irc, command) + if not cbs: notCommands.append(repr(command)) + elif len(cbs) > 1: + ambiguousCommands[command] = [cb.name() for cb in cbs] if notCommands: irc = callbacks.IrcObjectProxyRegexp(irc) replyWhenNotCommand(irc, msg, notCommands) + elif ambiguousCommands: + L = [] + while ambiguousCommands: + (command, cbs) = ambiguousCommands.popitem() + L.append('%s is available in the %s plugins' % \ + (command, utils.commaAndify(cbs))) + s = '%s; please specify which plugins to call %s from.' % \ + ('; '.join(L), + len(L) > 1 and 'these commands' or 'this command') + irc.error(msg, s) def list(self, irc, msg, args): """[--private] []