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)
|
wait_on_rate_limit_notify=True)
|
||||||
try:
|
try:
|
||||||
api.verify_credentials()
|
api.verify_credentials()
|
||||||
|
logged_in = True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error("Error creating API", exc_info=True)
|
logger.error("Error creating API", exc_info=True)
|
||||||
raise e
|
raise e
|
||||||
logger.info("API created")
|
logger.info("API created")
|
||||||
return api
|
return (api, logged_in)
|
||||||
|
|
||||||
def mastodon():
|
def mastodon():
|
||||||
|
|
||||||
|
@ -112,9 +113,8 @@ if __name__ == '__main__':
|
||||||
|
|
||||||
api_key, api_key_secret, access_token, access_token_secret = twitter_config()
|
api_key, api_key_secret, access_token, access_token_secret = twitter_config()
|
||||||
|
|
||||||
api = create_api()
|
|
||||||
|
|
||||||
publish = 0
|
publish = 0
|
||||||
|
logged_in = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
|
@ -137,6 +137,7 @@ if __name__ == '__main__':
|
||||||
try:
|
try:
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|
||||||
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
|
@ -174,6 +175,9 @@ if __name__ == '__main__':
|
||||||
print("Tooting...")
|
print("Tooting...")
|
||||||
print(toot_text)
|
print(toot_text)
|
||||||
|
|
||||||
|
if not logged_in:
|
||||||
|
api, logged_in = create_api()
|
||||||
|
|
||||||
if len(toot_text) < 280:
|
if len(toot_text) < 280:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Referencia en una nova incidència