+def tell_more(inp, pid):
+ def find_query(inp):
+ key1 = ["Tell me more", "tell me more"]
+ if inp[:12] in key1:
+ return inp[11:]
+ else:
+ return False
+
+ def query_lookup(pid):
+ old = int(time.time()) - 150
+ c.execute("SELECT query FROM queries WHERE pid = (?) AND time > (?)",
+ (str(pid), old))
+ return c.fetchone()
+
+ if find_query(inp):
+ return query_lookup(pid)
+ else:
+ return False
+
+def prep_database():
+ c.execute("""CREATE TABLE IF NOT EXISTS queries(
+ time INTEGER,
+ pid TEXT,
+ query TEXT)""")
+ conn.commit()
+
+def log_query(search, pid):
+ c.execute("DELETE FROM queries WHERE pid = (?)", (str(pid),))
+ c.execute("""INSERT INTO queries
+ (time, pid, query) VALUES(?, ?, ?)""",
+ (int(time.time()), str(pid), str(search)))
+ conn.commit()
+