optional to additional conversions.

This commit is contained in:
Jeremy Fincher 2004-10-19 12:03:18 +00:00
parent e960bad9d1
commit 75bd81aed7
2 changed files with 6 additions and 12 deletions

View File

@ -300,7 +300,7 @@ class Fun(callbacks.Privmsg):
length, use 0. length, use 0.
""" """
irc.reply(utils.soundex(text, length)) irc.reply(utils.soundex(text, length))
soundex = wrap(soundex, ['text', optional('int', 4)]) soundex = wrap(soundex, ['text', additional('int', 4)])
# The list of words and algorithm are pulled straight the mozbot # The list of words and algorithm are pulled straight the mozbot
# MagicEightBall.bm module: http://tinyurl.com/7ytg7 # MagicEightBall.bm module: http://tinyurl.com/7ytg7
@ -339,7 +339,7 @@ class Fun(callbacks.Privmsg):
irc.reply(self._checkTheBall(len(text))) irc.reply(self._checkTheBall(len(text)))
else: else:
irc.reply(self._checkTheBall(random.randint(0, 2))) irc.reply(self._checkTheBall(random.randint(0, 2)))
eightball = wrap(eightball, [optional('text')]) eightball = wrap(eightball, [additional('text')])
_rouletteChamber = random.randrange(0, 6) _rouletteChamber = random.randrange(0, 6)
_rouletteBullet = random.randrange(0, 6) _rouletteBullet = random.randrange(0, 6)
@ -367,7 +367,7 @@ class Fun(callbacks.Privmsg):
irc.reply('*click*') irc.reply('*click*')
self._rouletteChamber += 1 self._rouletteChamber += 1
self._rouletteChamber %= 6 self._rouletteChamber %= 6
roulette = wrap(roulette, ['public', optional(('literal', 'spin'))]) roulette = wrap(roulette, ['public', additional(('literal', 'spin'))])
def monologue(self, irc, msg, args, channel): def monologue(self, irc, msg, args, channel):
"""[<channel>] """[<channel>]

View File

@ -147,21 +147,15 @@ class Time(callbacks.Privmsg):
else: else:
irc.error('That\'s right now!') irc.error('That\'s right now!')
def ctime(self, irc, msg, args): def ctime(self, irc, msg, args, seconds):
"""[<seconds since epoch>] """[<seconds since epoch>]
Returns the ctime for <seconds since epoch>, or the current ctime if Returns the ctime for <seconds since epoch>, or the current ctime if
no <seconds since epoch> is given. no <seconds since epoch> is given.
""" """
seconds = privmsgs.getArgs(args, required=0, optional=1)
if seconds:
try:
seconds = float(seconds)
except ValueError:
irc.errorInvalid('seconds', seconds, Raise=True)
else:
seconds = time.time()
irc.reply(time.ctime(seconds)) irc.reply(time.ctime(seconds))
ctime = wrap(ctime, [additional(('int', 'number of seconds since epoch'),
TIME.time)])
def time(self, irc, msg, args, channel, format, seconds): def time(self, irc, msg, args, channel, format, seconds):
"""[<format>] [<seconds since epoch>] """[<format>] [<seconds since epoch>]