added __main__ stuff

This commit is contained in:
Lynne Megido 2018-11-13 22:03:57 +10:00
parent df1e73d271
commit d7f9a309b1
Signed by: lynnesbian
GPG Key ID: FB7B970303ACE499
2 changed files with 6 additions and 3 deletions

6
run.py
View File

@ -32,15 +32,15 @@ for row in dc.fetchall():
client = Mastodon(client_id=row['client_id'], client_secret=row['client_secret'], access_token=row['secret'], api_base_url=row['instance'])
for post in j['posts']:
if post['senderData']['id'] == False:
sender = "Anonymous user"
sender = "(anonymous)"
else:
sender = post['senderData']['username']
if int(post['timestamp']) == int(row['latest_post']):
#this is the one we've already seen
continue
toot = "Curious cat question from {}: \"{}\"\nMy 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?
toot = "Curious cat user {} asks: {}\nMy 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?
if settings['cw']:
client.status_post(toot, spoiler_text="Curious Cat post")
else:

3
web.py
View File

@ -244,3 +244,6 @@ def ccc_c():
@app.route('/cc_connect/complete')
def cc_connect_complete():
return render_template('cc_connect_complete.html', bg="background-image:url('{}')".format(session['ccavi']))
if __name__ == "__main__":
app.run(host="0.0.0.0", port=4734) #4734 is t9 for 'greg'