Introduction
Introduction Statistics Contact Development Disclaimer Help
Add --visibility option to post command - toot - Unnamed repository; edit this …
Log
Files
Refs
LICENSE
---
commit 3864563520a83ee1ec5a326f9304d5e10ad27bdb
parent 9b861ec9ccebd219b308651548eb100894248647
Author: Ivan Habunek <[email protected]>
Date: Sat, 15 Apr 2017 12:39:14 +0200
Add --visibility option to post command
Diffstat:
README.rst | 6 ++++++
toot/__init__.py | 5 ++---
toot/console.py | 9 ++++++++-
3 files changed, 16 insertions(+), 4 deletions(-)
---
diff --git a/README.rst b/README.rst
@@ -73,3 +73,9 @@ To post a new status to your timeline:
Optionally attach an image or video to the status:
toot post "Hello world!" --media=path/to/world.jpg
+
+To set post visibility:
+
+ toot post "Hello world!" --visibility=unlisted
+
+Possible visibility values are: ``public`` (default), ``unlisted``, ``private`…
diff --git a/toot/__init__.py b/toot/__init__.py
@@ -7,10 +7,8 @@ from requests import Request, Session
App = namedtuple('App', ['base_url', 'client_id', 'client_secret'])
User = namedtuple('User', ['username', 'access_token'])
-APP_NAME = 'toot'
DEFAULT_INSTANCE = 'mastodon.social'
-
logger = logging.getLogger('toot')
@@ -94,10 +92,11 @@ def login(app, username, password):
return User(username, access_token)
-def post_status(app, user, status, media_ids=None):
+def post_status(app, user, status, visibility='public', media_ids=None):
return _post(app, user, '/api/v1/statuses', {
'status': status,
'media_ids[]': media_ids,
+ 'visibility': visibility,
})
diff --git a/toot/console.py b/toot/console.py
@@ -145,19 +145,26 @@ def cmd_post_status(app, user):
parser.add_option("-m", "--media", dest="media", type="string",
help="path to the media file to attach")
+ parser.add_option("-v", "--visibility", dest="visibility", type="string", …
+ help='post visibility, either "public" (default), "direc…
+
(options, args) = parser.parse_args()
if len(args) < 2:
parser.print_help()
raise ConsoleError("No text given")
+ if options.visibility not in ['public', 'unlisted', 'private', 'direct']:
+ raise ConsoleError("Invalid visibility value given: '{}'".format(optio…
+
if options.media:
media = do_upload(app, user, options.media)
media_ids = [media['id']]
else:
media_ids = None
- response = post_status(app, user, args[1], media_ids=media_ids)
+ response = post_status(
+ app, user, args[1], media_ids=media_ids, visibility=options.visibility)
print("Toot posted: " + green(response.get('url')))
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.