Added a repr keyword argument to errorInvalid and used it to fix bug #1030474.

This commit is contained in:
Jeremy Fincher 2004-09-22 22:41:58 +00:00
parent b898142039
commit 16b9fb386e
3 changed files with 9 additions and 4 deletions

View File

@ -144,7 +144,7 @@ def makeNewAlias(name, alias):
everythingReplace(tokens) everythingReplace(tokens)
Owner = irc.getCallback('Owner') Owner = irc.getCallback('Owner')
self.Proxy(irc.irc, msg, tokens) self.Proxy(irc.irc, msg, tokens)
doc ='<an alias, %s>\n\nAlias for %r' % \ doc ='<an alias, %s>\n\nAlias for <<%s>>' % \
(utils.nItems('argument', biggestDollar), alias) (utils.nItems('argument', biggestDollar), alias)
f = utils.changeFunctionName(f, name, doc) f = utils.changeFunctionName(f, name, doc)
return f return f

View File

@ -108,7 +108,7 @@ class Misc(callbacks.Privmsg):
channel = msg.args[0] channel = msg.args[0]
if conf.get(conf.supybot.reply.whenNotCommand, channel): if conf.get(conf.supybot.reply.whenNotCommand, channel):
command = tokens and tokens[0] or '' command = tokens and tokens[0] or ''
irc.errorInvalid('command', command) irc.errorInvalid('command', command, repr=False)
else: else:
if tokens: if tokens:
# echo [] will get us an empty token set, but there's no need # echo [] will get us an empty token set, but there's no need

View File

@ -479,13 +479,18 @@ class RichReplyMethods(object):
v = self._getConfig(conf.supybot.replies.requiresPrivacy) v = self._getConfig(conf.supybot.replies.requiresPrivacy)
self._error(self.__makeReply(v, s), **kwargs) self._error(self.__makeReply(v, s), **kwargs)
def errorInvalid(self, what, given=None, s='', **kwargs): def errorInvalid(self, what, given=None, s='', repr=True, **kwargs):
if given is not None: if given is not None:
v = '%r is not a valid %s.' % (given, what) if repr:
given = _repr(given)
else:
given = '"%s"' % given
v = '%s is not a valid %s.' % (given, what)
else: else:
v = 'That\'s not a valid %s.' % what v = 'That\'s not a valid %s.' % what
self._error(self.__makeReply(v, s), **kwargs) self._error(self.__makeReply(v, s), **kwargs)
_repr = repr
class IrcObjectProxy(RichReplyMethods): class IrcObjectProxy(RichReplyMethods):
"A proxy object to allow proper nested of commands (even threaded ones)." "A proxy object to allow proper nested of commands (even threaded ones)."