def read_to(serv, chan, nick_to): messages = [] c = sqlite3.connect(settings.datafile_remind) for row in c.execute("SELECT * FROM remind WHERE server = '{0}' AND channel = '{1}'".format(serv, chan)): if nick_to.lower() == row[5].lower(): time_diff = timeutils.timediff(float(row[3])) messages.append(u"{0} to {1} (in {2}): {3}".format(row[4], row[5], time_diff, row[6])) c.close() return messages
def seen_dataconv(data): (ts,dtype,target,msg) = data tdelta = timeutils.timediff(ts) if dtype == 'PART': msg = 'parting '+target elif dtype == 'JOIN': msg = 'joining '+target elif dtype == 'PRIVMSG' or dtype == 'NOTICE': msg = 'saying "'+msg+'" in '+target elif dtype == 'QUIT': msg = 'quitting' msg = msg+' '+tdelta return msg
def add_reminder(serv, chan, tdest, sender, target, msg): if timeutils.validate(tdest): current_time = timeutils.now() time_end = timeutils.parse(tdest) target = misc.sanitize_sql(target) msg = misc.sanitize_sql(msg) c = sqlite3.connect(settings.datafile_remind) c.execute("INSERT INTO remind VALUES ('{0}', '{1}', {2}, {3}, '{4}', '{5}', '{6}')".format(serv, chan, str(current_time), str(time_end), sender, target, msg)) c.commit() c.close() c = sqlite3.connect(settings.datafile_remind + '.archive') c.execute("INSERT INTO remind VALUES ('{0}', '{1}', {2}, {3}, '{4}', '{5}', '{6}')".format(serv, chan, str(current_time), str(time_end), sender, target, msg)) c.commit() c.close() return('Okay, I\'ll remind '+target+' in '+timeutils.timediff(time_end)+'!') else: return ('Invalid input.')