Merge branch 'master' into 'master'

Add config option to change toot visibility

See merge request !5
This commit is contained in:
Carl Chenet 2017-06-28 18:52:05 +00:00
commit 734d9450fb
4 changed files with 23 additions and 3 deletions

View file

@ -40,6 +40,8 @@ Alternatively you can donate cryptocurrencies:
instance_url=https://mastodon.social
user_credentials=feed2toot_usercred.txt
client_credentials=feed2toot_clientcred.txt
; Default visibility is public, but you can override it:
; toot_visibility=unlisted
[cache]
cachefile=cache.db

View file

@ -26,6 +26,8 @@ In order to configure Feed2toot, you need to create a feed2toot.ini file (or any
; Here you need the two files created by register_feed2toot_app
user_credentials=/etc/feed2toot/credentials/feed2toot_usercred.txt
client_credentials=/etc/feed2toot/credentials/feed2toot_clientcred.txt
; Default visibility is public, but you can override it:
; toot_visibility=unlisted
[cache]
cachefile=/var/lib/feed2toot/feed2toot.db
@ -47,6 +49,12 @@ For the [mastodon] section:
- instance_url: the url of your Mastodon instance
- user_credentials: a file with the user credentials, generated by the command register_feed2toot_app
- client_credentials: a file with the client credentials, generated by the command register_feed2toot_app
- toot_visibility: any of the valid options for the *visibility* field
`here`__.
Default is *public*, but *unlisted* prevents flooding
the instance's public timeline (which is more polite).
__ https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#posting-a-new-status
For the [cache] section:

12
feed2toot/main.py Executable file → Normal file
View file

@ -189,13 +189,21 @@ class Main(object):
if clioptions.dryrun:
if entrytosend:
logging.warning('Tweet should have been sent: {tweet}'.format(tweet=finaltweet))
logging.warning('Would toot with visibility "{visibility}": {toot}'.format(
toot=finaltweet,
visibility=config.get(
'mastodon', 'toot_visibility',
fallback='public')))
else:
logging.debug('This rss entry did not meet pattern criteria. Should have not been sent')
else:
storeit = True
if entrytosend and not clioptions.populate:
logging.debug('sending the following tweet:{tweet}'.format(tweet=finaltweet))
logging.debug('Tooting with visibility "{visibility}": {toot}'.format(
toot=finaltweet,
visibility=config.get(
'mastodon', 'toot_visibility',
fallback='public')))
twp = TootPost(config, finaltweet)
storeit = twp.storeit()
else:

View file

@ -44,7 +44,9 @@ class TootPost:
access_token = self.config.get('mastodon', 'user_credentials'),
api_base_url = self.config.get('mastodon', 'instance_url')
)
mastodon.toot(self.toot)
mastodon.status_post(self.toot,
visibility=self.config.get(
'mastodon', 'toot_visibility', fallback='public'))
def storeit(self):
'''Indicate if the tweet should be stored or not'''