more reliable method (hack) of checking if they've posted
This commit is contained in:
parent
ba9b697a63
commit
ab43960e61
1 changed files with 5 additions and 1 deletions
6
run.py
6
run.py
|
@ -30,6 +30,7 @@ for row in dc.fetchall():
|
||||||
j = r.json()
|
j = r.json()
|
||||||
if 'error' in j:
|
if 'error' in j:
|
||||||
continue
|
continue
|
||||||
|
posted = False
|
||||||
if len(j['posts']) > 0 and not (len(j['posts']) == 1 and int(j['posts'][0]['timestamp']) == int(row['latest_post'])):
|
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
|
#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'])
|
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
|
#this is the one we've already seen
|
||||||
continue
|
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?
|
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']:
|
if settings['cw']:
|
||||||
client.status_post(toot, spoiler_text="Curious Cat post")
|
client.status_post(toot, spoiler_text="Curious Cat post")
|
||||||
else:
|
else:
|
||||||
client.status_post(toot)
|
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']))
|
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
|
#we checked, and they haven't made a post
|
||||||
tbc = int(row['time_between_checks']) + 1
|
tbc = int(row['time_between_checks']) + 1
|
||||||
if tbc > int(cfg['max_time_between_checks']):
|
if tbc > int(cfg['max_time_between_checks']):
|
||||||
|
|
Loading…
Reference in a new issue