From af8ff73fd1ff9cf864ef0705cdef1322e5eaf0b3 Mon Sep 17 00:00:00 2001 From: cquest Date: Wed, 14 Dec 2022 16:48:14 +0100 Subject: [PATCH] delay post only is there is an attachment --- tootbot.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tootbot.py b/tootbot.py index c1d7ae6..7a2bce4 100755 --- a/tootbot.py +++ b/tootbot.py @@ -288,29 +288,31 @@ else: if tags: c = c + '\n' + tags - if toot_media is not None: - try: - toot = mastodon_api.status_post(c, + try: + if len(toot_media)>0: + time.sleep(5) + toot = mastodon_api.status_post(c, + in_reply_to_id=None, + media_ids=toot_media, + sensitive=False, + visibility='unlisted', + spoiler_text=None) + except: + print("10s delay") + time.sleep(10) + toot = mastodon_api.status_post(c, in_reply_to_id=None, media_ids=toot_media, sensitive=False, visibility='unlisted', spoiler_text=None) - except: - print("10s delay") - time.sleep(10) - toot = mastodon_api.status_post(c, - in_reply_to_id=None, - media_ids=toot_media, - sensitive=False, - visibility='unlisted', - spoiler_text=None) - pass + pass - #break - if "id" in toot: - db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )", (id, toot["id"], source, mastodon, instance)) - sql.commit() + #break + if "id" in toot: + db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )", (id, toot["id"], source, mastodon, instance)) + sql.commit() + print(source, ": tweet created at",t['created_at']) print("---------------------------") print()