Fixed some bugz0rs.

This commit is contained in:
Jeremy Fincher 2004-11-21 13:18:58 +00:00
parent 8071e0236b
commit de367731f1
5 changed files with 14 additions and 14 deletions

View File

@ -95,7 +95,7 @@ class Babelfish(callbacks.Privmsg):
""" """
irc.reply(utils.commaAndify(babelfish.available_languages)) irc.reply(utils.commaAndify(babelfish.available_languages))
def translate(self, irc, msg, args, fromLang, to, toLang, text): def translate(self, irc, msg, args, fromLang, toLang, text):
"""<from-language> [to] <to-language> <text> """<from-language> [to] <to-language> <text>
Returns <text> translated from <from-language> into <to-language>. Returns <text> translated from <from-language> into <to-language>.
@ -128,9 +128,7 @@ class Babelfish(callbacks.Privmsg):
except babelfish.BabelfishChangedError, e: except babelfish.BabelfishChangedError, e:
irc.error('Babelfish has foiled our plans by changing its ' irc.error('Babelfish has foiled our plans by changing its '
'webpage format.') 'webpage format.')
translate = wrap(translate, translate = wrap(translate, ['something', 'to', 'something', 'text'])
['something', optional(literal('to')),
'something', 'text'])
def babelize(self, irc, msg, args, fromLang, toLang, text): def babelize(self, irc, msg, args, fromLang, toLang, text):
"""<from-language> <to-language> <text> """<from-language> <to-language> <text>

View File

@ -76,7 +76,7 @@ class Currency(callbacks.Privmsg):
r'(.*)</body>', re.I | re.S) r'(.*)</body>', re.I | re.S)
_xeConvert = re.compile(r'<TD[^>]+><FONT[^>]+>\s+([\d.]+\s+\w{3}\s+=' _xeConvert = re.compile(r'<TD[^>]+><FONT[^>]+>\s+([\d.]+\s+\w{3}\s+='
r'\s+[\d.]+\s+\w{3})', re.I | re.S) r'\s+[\d.]+\s+\w{3})', re.I | re.S)
def xe(self, irc, msg, args, number, curr1, to, curr2): def xe(self, irc, msg, args, number, curr1, curr2):
"""[<number>] <currency1> [to] <currency2> """[<number>] <currency1> [to] <currency2>
Converts from <currency1> to <currency2>. If number isn't given, it Converts from <currency1> to <currency2>. If number isn't given, it
@ -107,10 +107,9 @@ class Currency(callbacks.Privmsg):
else: else:
irc.error('XE must\'ve changed the format of their site.') irc.error('XE must\'ve changed the format of their site.')
return return
xe = wrap(xe, [optional('float', 1.0), 'lowered', xe = wrap(xe, [optional('float', 1.0), 'lowered', 'to', 'lowered'])
optional(literal('to')), 'lowered'])
def yahoo(self, irc, msg, args, number, curr1, to, curr2): def yahoo(self, irc, msg, args, number, curr1, curr2):
"""[<number>] <currency1> to <currency2> """[<number>] <currency1> to <currency2>
Converts from <currency1> to <currency2>. If number isn't given, it Converts from <currency1> to <currency2>. If number isn't given, it
@ -135,8 +134,7 @@ class Currency(callbacks.Privmsg):
if '.' not in resp[0] and 'e' not in resp[0]: if '.' not in resp[0] and 'e' not in resp[0]:
resp[0] = '%s.00' % resp[0] resp[0] = '%s.00' % resp[0]
irc.reply(' '.join(resp)) irc.reply(' '.join(resp))
yahoo = wrap(yahoo, [optional(float, 1.0), 'lowered', yahoo = wrap(yahoo, [optional(float, 1.0), 'lowered', 'to', 'lowered'])
optional(literal('to')), 'lowered'])
conf.registerPlugin('Currency') conf.registerPlugin('Currency')
conf.registerChannelValue(conf.supybot.plugins.Currency, 'command', conf.registerChannelValue(conf.supybot.plugins.Currency, 'command',

View File

@ -294,7 +294,7 @@ class Math(callbacks.Privmsg):
s = ', '.join(imap(self._complexToString, imap(complex, stack))) s = ', '.join(imap(self._complexToString, imap(complex, stack)))
irc.reply('Stack: [%s]' % s) irc.reply('Stack: [%s]' % s)
def convert(self, irc, msg, args, number, unit1, to, unit2): def convert(self, irc, msg, args, number, unit1, unit2):
"""[<number>] <unit> to <other unit> """[<number>] <unit> to <other unit>
Converts from <unit> to <other unit>. If number isn't given, it Converts from <unit> to <other unit>. If number isn't given, it
@ -306,8 +306,7 @@ class Math(callbacks.Privmsg):
irc.reply(str(newNum)) irc.reply(str(newNum))
except convertcore.UnitDataError, ude: except convertcore.UnitDataError, ude:
irc.error(str(ude)) irc.error(str(ude))
convert = wrap(convert, [optional('float', 1.0), 'something', convert = wrap(convert, [optional('float', 1.0),'something','to','text'])
additional(('literal', 'to'), ''), 'text'])
def units(self, irc, msg, args, type): def units(self, irc, msg, args, type):
""" [<type>] """ [<type>]

View File

@ -515,7 +515,7 @@ class Services(callbacks.Privmsg):
else: else:
irc.error('You must set supybot.plugins.Services.NickServ before ' irc.error('You must set supybot.plugins.Services.NickServ before '
'I\'m able to do identify.') 'I\'m able to do identify.')
identify = wrap(identify, ['checkCapability', 'admin']) identify = wrap(identify, [('checkCapability', 'admin')])
def ghost(self, irc, msg, args, nick): def ghost(self, irc, msg, args, nick):
"""[<nick>] """[<nick>]

View File

@ -490,6 +490,10 @@ def getLiteral(irc, msg, args, state, literals, errmsg=None):
else: else:
raise callbacks.ArgumentError raise callbacks.ArgumentError
def getTo(irc, msg, args, state):
if args[0].lower() == 'to':
args.pop(0)
def getPlugin(irc, msg, args, state, require=True): def getPlugin(irc, msg, args, state, require=True):
cb = irc.getCallback(args[0]) cb = irc.getCallback(args[0])
if cb is not None: if cb is not None:
@ -530,6 +534,7 @@ wrappers = ircutils.IrcDict({
'haveOp': getHaveOp, 'haveOp': getHaveOp,
'expiry': getExpiry, 'expiry': getExpiry,
'literal': getLiteral, 'literal': getLiteral,
'to': getTo,
'nick': getNick, 'nick': getNick,
'seenNick': getSeenNick, 'seenNick': getSeenNick,
'channel': getChannel, 'channel': getChannel,