Browse Source

don't add link if its already in post text, use

master
hfte 2 years ago
parent
commit
eb2ddbeebf
  1. 8
      mastaface.py

8
mastaface.py

@ -1,4 +1,4 @@
#!/usr/bin/env python3
^#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Public Facebook-Page to Mastodon Cross-Poster
@ -29,7 +29,7 @@ from mastodon import Mastodon
# from mastodon.Mastodon import MastodonAPIError, MastodonNetworkError, MastodonRatelimitError, MastodonUnauthorizedError
from vendor import split_tweet
logging.basicConfig(filename='mastaface.log',level=logging.INFO)
logging.basicConfig(filename='mastaface.log',level=logging.ERROR)
# Global variables
database_filename = 'database.pkl'
@ -124,7 +124,7 @@ for bridge in config['bridges']:
# If post is too long, split it into main-toot and non-listed replies.
is_main_toot = True
for toot_text in toots_text:
if post['link'] and is_main_toot:
if post['link'] and is_main_toot and (toot_text.find(post['link']) == -1):
toot = toot_text + '\n\n' + post['link']
else:
toot = toot_text
@ -134,7 +134,7 @@ for bridge in config['bridges']:
else:
statuses.append(mastodon.status_post(toot))
is_main_toot = False
logging.info('Bridged post' + str(post['post_id']) + ' to ' + str(statuses[-1]['id']) )
logging.info('Bridged post ' + str(post['post_id']) + ' to ' + str(statuses[-1]['id']) )
else:
statuses.append(mastodon.status_post(toot, in_reply_to_id = statuses[-1], visibility = 'unlisted'))
# If database structure for current bridge does not exist yet, initialize it.

Loading…
Cancel
Save