add pleroma's content_type support

This commit is contained in:
n 2021-02-06 15:27:52 +01:00
parent 02dc5f7887
commit 731781069a
No known key found for this signature in database
GPG key ID: E96086FC951DAE30
2 changed files with 19 additions and 3 deletions

View file

@ -68,6 +68,11 @@ In order to configure Feed2toot, you need to create a feed2toot.ini file (or any
[media]
custom=/var/lib/feed2toot/media/logo.png
; Optional, if you wish to post to a Pleroma instance
[pleroma]
; Specify content_type to set the content type of your post on Pleroma.
content_type=text/plain
For the [mastodon] section:
- instance_url: the url of your Mastodon instance
@ -115,6 +120,10 @@ For the [media] section:
- custom: the path to a media (should be supported by Mastodon) to be posted with every Mastodon post.
For the [pleroma] section:
- content_type: Specify content_type to set the content type of your post on Pleroma. It accepts text/plain (default), text/markdown, text/html and text/bbcode'. This parameter is not supported on Mastodon servers, but will be safely ignored if set. Use proper syntax in toot parameter of [rss] section.
Example of the list of hash tags
================================
The list of hash tags is a simple text file with one hash tag composed by several words on a single line::

View file

@ -31,17 +31,24 @@ class TootPost:
def main(self):
'''Main of the TweetPost class'''
mastodon_feature_set = 'mainline'
toot_content_type = None
if 'pleroma' in self.config.sections():
mastodon_feature_set='pleroma'
if self.config.has_option('pleroma', 'content_type'):
toot_content_type=self.config.get('pleroma', 'content_type', fallback='text/plain')
mastodon = Mastodon(
client_id=self.config.get('mastodon', 'client_credentials'),
access_token=self.config.get('mastodon', 'user_credentials'),
api_base_url=self.config.get('mastodon', 'instance_url')
api_base_url=self.config.get('mastodon', 'instance_url'),
feature_set=mastodon_feature_set
)
toot_visibility = self.config.get('mastodon', 'toot_visibility', fallback='public')
if 'custom' in self.options['media']:
mediaid = mastodon.media_post(self.config['media']['custom'])
mastodon.status_post(self.toot, media_ids=[mediaid], visibility=toot_visibility)
mastodon.status_post(self.toot, media_ids=[mediaid], visibility=toot_visibility, content_type=toot_content_type)
else:
mastodon.status_post(self.toot, visibility=toot_visibility)
mastodon.status_post(self.toot, visibility=toot_visibility, content_type=toot_content_type)
def storeit(self):
'''Indicate if the tweet should be stored or not'''