def run(self, bot, data): if data.nick: db = RememberDB(bot) if data.event in ["PART", "QUIT"]: if data.nick == bot.nick: return False db.parted(data.nick) elif data.event == "JOIN": tells = db.joined(data.nick) if tells: for tell in tells: then = datetime.datetime.strptime(tell[4], "%Y-%m-%d %H:%M:%S") now = datetime.datetime.utcnow() delta = now - then ago = timedelta_to_string(delta) bot.private("%s: %s said: \"%s\" %s ago" % \ (tell[1], tell[3], tell[2], ago))
def run(self, bot, data): nick = data.group(1) if not nick: return bot.say("You must specify a nick to query") if nick.lower() == data.origin.nick.lower(): return bot.say("What! Really? That is a weird thing to ask for...") if nick.lower() == "george": return bot.say("Hah. Yeah right!") db = RememberDB(bot) try: seen = db.seen(nick) except RuntimeError: bot.say("I do not remember seeing %s come or go" % nick) else: if seen == 'now': bot.say("%s is here now" % nick) else: then = datetime.datetime.strptime(seen, "%Y-%m-%d %H:%M:%S") now = datetime.datetime.utcnow() delta = now - then ago = timedelta_to_string(delta) if not ago: return bot.say("%s just left" % nick) bot.say("%s was last seen %s ago" % (nick, ago))