Format mastodon output
This commit is contained in:
@@ -59,18 +59,19 @@ class MastodonPlugin(BasePlugin):
|
||||
)
|
||||
return {'status': 'skipped', 'plugin': self.name, 'reason': 'not_configured'}
|
||||
|
||||
status_parts = [event.get('title') or event.get('url', '')]
|
||||
if event.get('comment'):
|
||||
status_parts.append(event['comment'])
|
||||
post_prefix = config.get('post_prefix')
|
||||
if post_prefix is None and config.get('hashtag'):
|
||||
post_prefix = f'#{str(config["hashtag"]).strip().lstrip("#")} '
|
||||
post_prefix = str(post_prefix if post_prefix is not None else DEFAULT_POST_PREFIX)
|
||||
status = f'{post_prefix}{event.get("url", "")}'.strip()
|
||||
post_prefix = str(post_prefix if post_prefix is not None else DEFAULT_POST_PREFIX).strip()
|
||||
title = str(event.get('title') or '').strip()
|
||||
status_parts = [f'{post_prefix} {title}'.strip()]
|
||||
if event.get('comment'):
|
||||
status_parts.append(event['comment'])
|
||||
if title:
|
||||
status_parts.append(f'from: {event.get("url", "")}')
|
||||
if event.get('tags'):
|
||||
status = f'{status} {" ".join(event["tags"])}'
|
||||
status_parts.append(status)
|
||||
post_body = '\n'.join(status_parts)
|
||||
status_parts.append(' '.join(event['tags']))
|
||||
post_body = '\n\n'.join(status_parts)
|
||||
endpoint = f'{instance}/api/v1/statuses'
|
||||
logger.debug(
|
||||
'Posting link to Mastodon: endpoint=%s user_id=%s event_id=%s body_length=%d',
|
||||
|
||||
Reference in New Issue
Block a user