mirror of
https://github.com/cquest/tootbot.git
synced 2025-02-17 08:18:07 +00:00
add delay when "Unprocessable Entity" error on post (fixes #9)
This commit is contained in:
parent
994ef0ab2a
commit
35bc4aeb4f
16
tootbot.py
16
tootbot.py
|
@ -2,6 +2,7 @@ import os.path
|
||||||
import sys
|
import sys
|
||||||
import re
|
import re
|
||||||
import html
|
import html
|
||||||
|
import time
|
||||||
|
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
@ -254,15 +255,28 @@ else:
|
||||||
c = c + '\n' + tags
|
c = c + '\n' + tags
|
||||||
|
|
||||||
if toot_media is not None:
|
if toot_media is not None:
|
||||||
toot = mastodon_api.status_post(c,
|
try:
|
||||||
|
toot = mastodon_api.status_post(c,
|
||||||
in_reply_to_id=None,
|
in_reply_to_id=None,
|
||||||
media_ids=toot_media,
|
media_ids=toot_media,
|
||||||
sensitive=False,
|
sensitive=False,
|
||||||
visibility='unlisted',
|
visibility='unlisted',
|
||||||
spoiler_text=None)
|
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
|
||||||
|
|
||||||
#break
|
#break
|
||||||
if "id" in toot:
|
if "id" in toot:
|
||||||
db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )", (id, toot["id"], source, mastodon, instance))
|
db.execute("INSERT INTO tweets VALUES ( ? , ? , ? , ? , ? )", (id, toot["id"], source, mastodon, instance))
|
||||||
sql.commit()
|
sql.commit()
|
||||||
|
|
||||||
|
print("---------------------------")
|
||||||
print()
|
print()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user