def handle_age(bot, ievent): """ age <nick> .. show age of user """ try: who = ievent.args[0].lower() except IndexError: ievent.missing('<nick>') return userhost = getwho(bot, who) if not userhost: ievent.reply("don't know userhost of %s" % who) return name = users.getname(userhost) if not name: ievent.reply("can't find user for %s" % userhost) return s = create_session() bd = s.query(Birthday).filter(Birthday.name==name).first() try: birthday = bd.birthday except (TypeError, AttributeError): ievent.reply("can't find birthday data for %s" % who) return btime = strtotime(birthday) if btime == None: ievent.reply("can't make a date out of %s" % birthday) return age = int(time.time()) - int(btime) ievent.reply("age of %s is %s" % (who, elapsedstring(age, ywd=True)))
def handle_idle2(bot, ievent): """ show how idle a channel has been """ chan = ievent.channel try: elapsed = elapsedstring(time.time()-idle.data[jsonstring((bot.name, chan))]) except KeyError: ievent.reply("nobody said anything on channel %s yet" % chan) return if elapsed: ievent.reply("channel %s is idle for %s" % (chan, elapsed)) else: ievent.reply("channel %s is not idle" % chan)
def handle_idle2(bot, ievent): """ show how idle a channel has been """ chan = ievent.channel try: elapsed = elapsedstring(time.time() - idle.data[jsonstring((bot.name, chan))]) except KeyError: ievent.reply("nobody said anything on channel %s yet" % chan) return if elapsed: ievent.reply("channel %s is idle for %s" % (chan, elapsed)) else: ievent.reply("channel %s is not idle" % chan)
def handle_idle(bot, ievent): """ idle [<nick>] .. show how idle an channel/user has been """ try: who = ievent.args[0] except IndexError: handle_idle2(bot, ievent) return userhost = getwho(bot, who) if not userhost: ievent.reply("can't get userhost of %s" % who) return try: elapsed = elapsedstring(time.time() - idle.data[jsonstring((bot.name, userhost))]) except KeyError: ievent.reply("i haven't seen %s" % who) return if elapsed: ievent.reply("%s is idle for %s" % (who, elapsed)) return else: ievent.reply("%s is not idle" % who) return
def handle_uptime(bot, ievent): """ show uptime. """ ievent.reply("uptime is %s" % elapsedstring(time.time() - bot.starttime))
def handle_uptime(bot, ievent): """ show uptime. """ ievent.reply("uptime is %s" % elapsedstring(time.time()-bot.starttime))