Пример #1
0
def timer(event):
    """ echo txt on a given time. """
    if not event._parsed.rest: return
    seconds = 0
    line = ""
    for word in event._parsed.args:
        if word.startswith("+"):
            try:
                seconds = int(word[1:])
            except:
                event.reply("%s is not an integer" % seconds)
                return
        else:
            line += word + " "
    if seconds: target = time.time() + seconds
    else:
        try:
            target = get_day(event._parsed.rest)
        except ENODATE:
            target = to_day(day())
        hour = get_hour(event._parsed.rest)
        if hour: target += hour
    if not target or time.time() > target:
        event.reply("already passed given time.")
        return
    e = Event()
    e.services = "clock"
    e.prefix = "timer"
    e.txt = event._parsed.rest
    e.time = target
    e.done = False
    e.save()
    timer = Timer(target, e.reply, e.txt)
    launcher.launch(timer.start)
    event.ok(time.ctime(target))
Пример #2
0
def timer(event):
    if not event.rest: return
    day = get_day(event.rest) or today()
    hour = get_hour(event.rest)
    target = day + get_hour(event.rest)
    if time.time() > target: event.reply("already passed given time.") ; return
    event.reply("time is %s" % time.ctime(target))
    e = Event()
    e._bot = event._bot
    e.services = "clock"
    e.prefix = "timer"
    e.txt = event.rest
    e.time = target
    e.done = False
    e.save()
    timer = Timer(target, e.parse())
    launcher.launch(timer.start)
    e.ok()
Пример #3
0
def testcfg(event):
    cfg.workdir = event._parsed.rest
    e = Event()
    path = e.save()
    event.reply(path)