Only create API if new toots

This commit is contained in:
spla 2021-09-11 18:27:54 +02:00
pare 1160303498
commit e098fac88c

Veure arxiu

@ -32,11 +32,12 @@ def create_api():
wait_on_rate_limit_notify=True)
try:
api.verify_credentials()
logged_in = True
except Exception as e:
logger.error("Error creating API", exc_info=True)
raise e
logger.info("API created")
return api
return (api, logged_in)
def mastodon():
@ -111,10 +112,9 @@ if __name__ == '__main__':
feeds_db, feeds_db_user, feeds_url = db_config()
api_key, api_key_secret, access_token, access_token_secret = twitter_config()
api = create_api()
publish = 0
logged_in = False
try:
@ -137,6 +137,7 @@ if __name__ == '__main__':
try:
conn = None
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
cur = conn.cursor()
@ -173,6 +174,9 @@ if __name__ == '__main__':
print("Tooting...")
print(toot_text)
if not logged_in:
api, logged_in = create_api()
if len(toot_text) < 280: