From ab43960e613233f00fdba4240b1a7fa25d9b129e Mon Sep 17 00:00:00 2001 From: Lynne Date: Thu, 15 Nov 2018 11:12:20 +1000 Subject: [PATCH] more reliable method (hack) of checking if they've posted --- run.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/run.py b/run.py index 6003e30..1685781 100755 --- a/run.py +++ b/run.py @@ -30,6 +30,7 @@ for row in dc.fetchall(): j = r.json() if 'error' in j: continue + posted = False if len(j['posts']) > 0 and not (len(j['posts']) == 1 and int(j['posts'][0]['timestamp']) == int(row['latest_post'])): #they've made some new posts, log in to masto client = Mastodon(client_id=row['client_id'], client_secret=row['client_secret'], access_token=row['secret'], api_base_url=row['instance']) @@ -43,13 +44,16 @@ for row in dc.fetchall(): #this is the one we've already seen continue + #if we get to this point, they've definitely made a post + posted = True + toot = "Curious Cat user {} asks: {}\n\nMy answer: {}\n\nhttps://curiouscat.me/{}/post/{}".format(sender, post['comment'], post['reply'], row['cc'], post['id']) #TODO: what if this is over 500 characters? if settings['cw']: client.status_post(toot, spoiler_text="Curious Cat post") else: client.status_post(toot) 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: + if not posted: #we checked, and they haven't made a post tbc = int(row['time_between_checks']) + 1 if tbc > int(cfg['max_time_between_checks']):