def handle_todosettime(bot, ievent): """ todo-settime [<channel|name>] <itemnr> <timestring> .. set time \ on todo item """ ttime = strtotime(ievent.txt) if ttime == None: ievent.reply("can't detect time") return txt = striptime(ievent.txt) try: (who, itemnr) = txt.split() except ValueError: try: (itemnr, ) = txt.split() who = users.getname(ievent.userhost) except ValueError: ievent.missing('[<channe|namel>] <itemnr> <timestring>') return try: itemnr = int(itemnr) except ValueError: ievent.missing('[<channel|name>] <itemnr> <timestring>') return who = who.lower() if not todo.settime(who, itemnr, ttime): ievent.reply('no todo %s found for %s' % (itemnr, who)) return ievent.reply('time of todo %s set to %s' % (itemnr, time.ctime(ttime)))
def handle_settodo(bot, ievent): """ todo-set <name> <txt> .. add a todo to another user's todo list""" try: who = ievent.args[0] what = ' '.join(ievent.args[1:]) except IndexError: ievent.missing('<nick> <what>') return if not what: ievent.missing('<nick> <what>') return userhost = getwho(bot, who) if not userhost: ievent.reply("can't find userhost for %s" % who) return whouser = users.getname(userhost) if not whouser: ievent.reply("can't find user for %s" % userhost) return name = users.getname(ievent.userhost) if not users.permitted(userhost, name, 'todo'): ievent.reply("%s doesn't permit todo sharing for %s " % \ (who, name)) return what = "%s: %s" % (ievent.nick, what) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) alarmnr = alarms.add(bot.name, who, ttime, what) nr = todo.add(whouser, what, ttime, alarmnr=alarmnr) else: nr = todo.add(whouser, what, 0) ievent.reply('todo item %s added' % nr)
def handle_chantodo2(bot, ievent): """ set todo item for channel""" what = ievent.rest ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) result = '(%s) ' % ievent.nick + striptime(what) alarmnr = alarms.add(bot.name, ievent.channel, ttime, result) nr = todo.add(ievent.channel, result, ttime, alarmnr=alarmnr) else: result = '(%s) ' % ievent.nick + what nr = todo.add(ievent.channel, result, 0) ievent.reply('todo item %s added' % nr)
def handle_todo2(bot, ievent): """ set todo item """ if not ievent.rest: ievent.missing("<what>") return else: what = ievent.rest name = users.getname(ievent.userhost) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) alarmnr = alarms.add(bot.name, ievent.nick, ttime, what) nr = todo.add(name, what, ttime, alarmnr=alarmnr) else: nr = todo.add(name, what) ievent.reply('todo item %s added' % nr)
def handle_tomorrow(bot, ievent): """ todo-tomorrow .. show time related todo items for tomorrow """ username = users.getname(ievent.userhost) if ievent.rest: what = ievent.rest ttime = strtotime(what) if ttime != None: if ttime < today() or ttime > today() + 24*60*60: ievent.reply("%s is not tomorrow" % \ time.ctime(ttime + 24*60*60)) return ttime += 24*60*60 ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) else: ttime = today() + 42*60*60 todo.add(username, what, ttime) ievent.reply('todo added') return todoos = todo.withintime(username, today()+24*60*60, today()+2*24*60*60) saytodo(bot, ievent, todoos)
def handle_tomorrow(bot, ievent): """ todo-tomorrow .. show time related todo items for tomorrow """ username = users.getname(ievent.userhost) if ievent.rest: what = ievent.rest ttime = strtotime(what) if ttime != None: if ttime < today() or ttime > today() + 24 * 60 * 60: ievent.reply("%s is not tomorrow" % \ time.ctime(ttime + 24*60*60)) return ttime += 24 * 60 * 60 ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) else: ttime = today() + 42 * 60 * 60 todo.add(username, what, ttime) ievent.reply('todo added') return todoos = todo.withintime(username, today() + 24 * 60 * 60, today() + 2 * 24 * 60 * 60) saytodo(bot, ievent, todoos)
return # add alarm nrid = alarms.add(bot.name, ievent.nick, ttime, \ ' '.join(ievent.args[1:]), ievent.printto) ievent.reply("alarm %s set at %s" % (nrid, time.ctime(ttime))) return except Exception, ex: handle_exception(ievent) return # see if we can determine time from txt alarmtime = strtotime(alarmtxt) if not alarmtime: ievent.reply("can't detect time") return # check if alarm txt is provided txt = striptime(alarmtxt).strip() if not txt: ievent.reply('i need txt to remind you') return if time.time() > alarmtime: ievent.reply("we are already past %s" % time.ctime(alarmtime)) return # add alarm nrid = alarms.add(bot.name, ievent.nick, alarmtime, txt, ievent.printto) ievent.reply("alarm %s set at %s" % (nrid, time.ctime(alarmtime))) cmnds.add('alarm', handle_alarmadd, 'USER', allowqueue=False) examples.add('alarm', 'say txt at a specific time or time diff', \ '1) alarm 12:00 lunchtime 2) alarm 3-11-2008 0:01 birthday ! 3) alarm +180 \ egg ready') tests.add('alarm 23:59 sleeptime', 'alarm (\d+) set at').add('alarm-del %s')