Time: Make argument to @at optional. (Replacement for GH-533 that does not need nesting.)

This commit is contained in:
Valentin Lorentz 2013-12-28 23:05:23 +00:00
parent df375e075a
commit 9ff1483da2
1 changed files with 7 additions and 3 deletions

View File

@ -95,13 +95,17 @@ class Time(callbacks.Plugin):
irc.reply(str(seconds)) irc.reply(str(seconds))
@internationalizeDocstring @internationalizeDocstring
def at(self, irc, msg, args, s): def at(self, irc, msg, args, s=None):
"""<time string> """[<time string>]
Returns the number of seconds since epoch <time string> is. Returns the number of seconds since epoch <time string> is.
<time string> can be any number of natural formats; just try something <time string> can be any number of natural formats; just try something
and see if it will work. and see if it will work.
If the <time string> is not given, defaults to now.
""" """
if not s:
irc.reply(str(int(time.time())))
return
if not parse: if not parse:
irc.error(_('This command is not available on this bot, ask the ' irc.error(_('This command is not available on this bot, ask the '
'owner to install the python-dateutil library.'), Raise=True) 'owner to install the python-dateutil library.'), Raise=True)
@ -111,7 +115,7 @@ class Time(callbacks.Plugin):
irc.reply(str(new)) irc.reply(str(new))
else: else:
irc.error(_('That\'s right now!')) irc.error(_('That\'s right now!'))
at = wrap(at, ['text']) at = wrap(at, [optional('text')])
@internationalizeDocstring @internationalizeDocstring
def until(self, irc, msg, args, s): def until(self, irc, msg, args, s):