From 731781069ac7715ef4f2b1df6b562b91e4656a1c Mon Sep 17 00:00:00 2001 From: n Date: Sat, 6 Feb 2021 15:27:52 +0100 Subject: [PATCH 1/2] add pleroma's content_type support --- docs/source/configure.rst | 9 +++++++++ feed2toot/tootpost.py | 13 ++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/source/configure.rst b/docs/source/configure.rst index a16fd82..bd0be7e 100644 --- a/docs/source/configure.rst +++ b/docs/source/configure.rst @@ -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:: diff --git a/feed2toot/tootpost.py b/feed2toot/tootpost.py index 43eae3f..fed10c9 100644 --- a/feed2toot/tootpost.py +++ b/feed2toot/tootpost.py @@ -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''' From 83cf09c555c109cfa84eabf31adef55bd0805b0f Mon Sep 17 00:00:00 2001 From: n Date: Sun, 7 Feb 2021 17:30:54 +0100 Subject: [PATCH 2/2] use confparser to get pleroma's options --- feed2toot/confparse.py | 5 +++++ feed2toot/confparsers/pleroma.py | 26 ++++++++++++++++++++++++++ feed2toot/tootpost.py | 12 +++--------- 3 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 feed2toot/confparsers/pleroma.py diff --git a/feed2toot/confparse.py b/feed2toot/confparse.py index baa67c3..c9a9f15 100644 --- a/feed2toot/confparse.py +++ b/feed2toot/confparse.py @@ -34,6 +34,7 @@ from feed2toot.confparsers.hashtags.nohashtags import parsenotagsintoot from feed2toot.confparsers.feedparser import parsefeedparser from feed2toot.confparsers.lock import parselock from feed2toot.confparsers.media import parsemedia +from feed2toot.confparsers.pleroma import parsepleroma from feed2toot.confparsers.plugins import parseplugins from feed2toot.confparsers.rss.ignoressl import parseignoressl from feed2toot.confparsers.rss.pattern import parsepattern @@ -113,6 +114,10 @@ class ConfParse: ########################### options['media'] = parsemedia(config) ########################### + # the pleroma section + ########################### + options['mastodon_feature_set'], options['toot_content_type'] = parsepleroma(config) + ########################### # the plugins section ########################### plugins = parseplugins(config) diff --git a/feed2toot/confparsers/pleroma.py b/feed2toot/confparsers/pleroma.py new file mode 100644 index 0000000..42ee81c --- /dev/null +++ b/feed2toot/confparsers/pleroma.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Copyright © 2015-2020 Carl Chenet +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see