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

View File

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