diff --git a/run.py b/run.py index 0908246..257af3a 100755 --- a/run.py +++ b/run.py @@ -17,10 +17,10 @@ dc = db.cursor(dictionary=True) dc.execute("SELECT * FROM data") for row in dc.fetchall(): - print(row) + print(row['cc']) t = int(time.time()) next_check = row['last_check'] + row['time_between_checks'] * 60 - if next_check > t: + if next_check <= t: row['time_between_checks'] = cfg['min_time_between_checks'] #time to check if row['cc'] != "None" and row['cc'] != None: @@ -35,5 +35,12 @@ for row in dc.fetchall(): else: sender = post['senderData']['username'] - toot = "Curious cat question from {}: \"{}\"
My answer: {}\nView online at https://curiouscat.me/{}/post/{}".format(sender, post['comment'], post['reply'], row['cc'], post['id']) - + toot = "Curious cat question from {}: \"{}\"
My answer: {}\nView online at https://curiouscat.me/{}/post/{}".format(sender, post['comment'], post['reply'], row['cc'], post['id']) #TODO: what if this is over 500 characters? + c.execute("UPDATE data SET last_check = %s, time_between_checks = %s, latest_post = %s", (t, cfg['min_time_between_checks'], j['posts'][0]['timestamp'])) + else: + #we checked, and they haven't made a post + tbc = int(row['time_between_checks']) + 1 + if tbc > int(cfg['max_time_between_checks']): + tbc = cfg['max_time_between_checks'] + c.execute("UPDATE data SET last_check = %s, time_between_checks = %s", (t, tbc)) +