mirror of
https://github.com/cquest/tootbot.git
synced 2024-11-27 14:01:07 +00:00
first threads support...
This commit is contained in:
parent
6154b7d5a9
commit
e6ec0b20d7
31
tootbot.py
31
tootbot.py
|
@ -230,13 +230,24 @@ else:
|
||||||
# print('Quoted:', c)
|
# print('Quoted:', c)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
# check if this tweet has been processed
|
# detect threads
|
||||||
id = t['id']
|
in_reply_to = None
|
||||||
db.execute('SELECT * FROM tweets WHERE tweet = ? AND twitter = ? and mastodon = ? and instance = ?', (id, source, mastodon, instance)) # noqa
|
if 'conversation_id' in t and t['conversation_id'] not in t['link']:
|
||||||
last = db.fetchone()
|
db.execute('SELECT toot FROM tweets WHERE tweet = ? AND twitter = ?', (t['conversation_id'], source)) # noqa
|
||||||
|
thread = db.fetchone()
|
||||||
|
if thread:
|
||||||
|
print("Thread :", t['conversation_id'], t['link'], thread[0])
|
||||||
|
in_reply_to = thread[0]
|
||||||
|
|
||||||
# process only unprocessed tweets
|
# check if this tweet has been processed
|
||||||
if last:
|
id = t['id'] # old id
|
||||||
|
db.execute('SELECT * FROM tweets WHERE tweet = ? AND twitter = ? and mastodon = ? and instance = ?', (id, source, mastodon, instance)) # noqa
|
||||||
|
if db.fetchone():
|
||||||
|
continue
|
||||||
|
|
||||||
|
id = t['link'].split('/')[-1] # new id from status link to support threads
|
||||||
|
db.execute('SELECT * FROM tweets WHERE tweet = ? AND twitter = ? and mastodon = ? and instance = ?', (id, source, mastodon, instance)) # noqa
|
||||||
|
if db.fetchone():
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if c[-1] == "…":
|
if c[-1] == "…":
|
||||||
|
@ -335,16 +346,16 @@ else:
|
||||||
if len(toot_media)>0:
|
if len(toot_media)>0:
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
toot = mastodon_api.status_post(c,
|
toot = mastodon_api.status_post(c,
|
||||||
in_reply_to_id=None,
|
in_reply_to_id=in_reply_to,
|
||||||
media_ids=toot_media,
|
media_ids=toot_media,
|
||||||
sensitive=False,
|
sensitive=False,
|
||||||
visibility='unlisted',
|
visibility='unlisted',
|
||||||
spoiler_text=None)
|
spoiler_text=None)
|
||||||
except:
|
except:
|
||||||
print("10s delay")
|
print("delay")
|
||||||
time.sleep(10)
|
time.sleep(30)
|
||||||
toot = mastodon_api.status_post(c,
|
toot = mastodon_api.status_post(c,
|
||||||
in_reply_to_id=None,
|
in_reply_to_id=in_reply_to,
|
||||||
media_ids=toot_media,
|
media_ids=toot_media,
|
||||||
sensitive=False,
|
sensitive=False,
|
||||||
visibility='unlisted',
|
visibility='unlisted',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user