Allow posting media without text

issue #24
This commit is contained in:
Ivan Habunek 2017-12-30 16:42:52 +01:00
parent 92d4dc745a
commit fde6bd6125
No known key found for this signature in database
GPG key ID: CDBD63C43A30BB95
2 changed files with 8 additions and 0 deletions

View file

@ -74,8 +74,15 @@ def post(app, user, args):
media = _do_upload(app, user, args.media)
media_ids = [media['id']]
else:
media = None
media_ids = None
if media and not args.text:
args.text = media['text_url']
if not args.text:
raise ConsoleError("You must specify either text or media to post.")
response = api.post_status(app, user, args.text, args.visibility, media_ids)
print_out("Toot posted: <green>{}</green>".format(response.get('url')))

View file

@ -144,6 +144,7 @@ POST_COMMANDS = [
arguments=[
(["text"], {
"help": "The status text to post.",
"nargs": "?",
}),
(["-m", "--media"], {
"type": FileType('rb'),