Compare commits

..

3 commits

Author SHA1 Message Date
n
4a3e3664ad
use confparser to get pleroma's options 2024-08-27 20:36:47 +02:00
n
acc98829cc
add pleroma's content_type support 2024-08-27 20:36:47 +02:00
n
8b0d5b59ff
pleroma support 2024-08-27 20:36:46 +02:00
4 changed files with 44 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

@ -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)

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright © 2015-2020 Carl Chenet <carl.chenet@ohmytux.com>
# 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 <http://www.gnu.org/licenses/
# Get values of the pleroma section
'''Get values of the pleroma section'''
def parsepleroma(config):
'''Parse configuration values and get values of the pleroma section'''
mastodon_feature_set = 'mainline'
toot_content_type = None
if 'pleroma' in config.sections():
mastodon_feature_set = 'pleroma'
toot_content_type = config.get('pleroma', 'content_type', fallback='text/plain')
return mastodon_feature_set,toot_content_type

View file

@ -34,14 +34,15 @@ class TootPost:
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=self.options['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=self.options['toot_content_type'])
else:
mastodon.status_post(self.toot, visibility=toot_visibility)
mastodon.status_post(self.toot, visibility=toot_visibility, content_type=self.options['toot_content_type'])
def storeit(self):
'''Indicate if the tweet should be stored or not'''