Only create API if new toots
This commit is contained in:
pare
1160303498
commit
e098fac88c
S'han modificat 1 arxius amb 7 adicions i 3 eliminacions
10
mastotuit.py
10
mastotuit.py
|
@ -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:
|
||||
|
||||
|
|
Loading…
Referencia en una nova incidència