mirror of
https://github.com/ihabunek/toot.git
synced 2024-11-03 04:17:21 -05:00
parent
ea94d6bfe1
commit
8f93b255ad
@ -1,6 +1,10 @@
|
|||||||
Changelog
|
Changelog
|
||||||
---------
|
---------
|
||||||
|
|
||||||
|
**0.19.0 (TBA)**
|
||||||
|
|
||||||
|
* Add support for replying to a toot (#6)
|
||||||
|
|
||||||
**0.18.0 (2018-06-12)**
|
**0.18.0 (2018-06-12)**
|
||||||
|
|
||||||
* Add support for public, tag and list timelines in `toot timeline` (#52)
|
* Add support for public, tag and list timelines in `toot timeline` (#52)
|
||||||
|
@ -39,6 +39,7 @@ def test_post_defaults(mock_post, capsys):
|
|||||||
'media_ids[]': None,
|
'media_ids[]': None,
|
||||||
'sensitive': False,
|
'sensitive': False,
|
||||||
'spoiler_text': None,
|
'spoiler_text': None,
|
||||||
|
'in_reply_to_id': None,
|
||||||
})
|
})
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
@ -49,7 +50,13 @@ def test_post_defaults(mock_post, capsys):
|
|||||||
|
|
||||||
@mock.patch('toot.http.post')
|
@mock.patch('toot.http.post')
|
||||||
def test_post_with_options(mock_post, capsys):
|
def test_post_with_options(mock_post, capsys):
|
||||||
args = ['Hello world', '--visibility', 'unlisted', '--sensitive', '--spoiler-text', 'Spoiler!']
|
args = [
|
||||||
|
'Hello world',
|
||||||
|
'--visibility', 'unlisted',
|
||||||
|
'--sensitive',
|
||||||
|
'--spoiler-text', 'Spoiler!',
|
||||||
|
'--reply-to', '123'
|
||||||
|
]
|
||||||
|
|
||||||
mock_post.return_value = MockResponse({
|
mock_post.return_value = MockResponse({
|
||||||
'url': 'https://habunek.com/@ihabunek/1234567890'
|
'url': 'https://habunek.com/@ihabunek/1234567890'
|
||||||
@ -63,6 +70,7 @@ def test_post_with_options(mock_post, capsys):
|
|||||||
'visibility': 'unlisted',
|
'visibility': 'unlisted',
|
||||||
'sensitive': True,
|
'sensitive': True,
|
||||||
'spoiler_text': "Spoiler!",
|
'spoiler_text': "Spoiler!",
|
||||||
|
'in_reply_to_id': 123,
|
||||||
})
|
})
|
||||||
|
|
||||||
out, err = capsys.readouterr()
|
out, err = capsys.readouterr()
|
||||||
|
17
toot/api.py
17
toot/api.py
@ -76,14 +76,27 @@ def request_access_token(app, authorization_code):
|
|||||||
return http.process_response(response).json()
|
return http.process_response(response).json()
|
||||||
|
|
||||||
|
|
||||||
def post_status(app, user, status, visibility='public', media_ids=None,
|
def post_status(
|
||||||
sensitive=False, spoiler_text=None):
|
app,
|
||||||
|
user,
|
||||||
|
status,
|
||||||
|
visibility='public',
|
||||||
|
media_ids=None,
|
||||||
|
sensitive=False,
|
||||||
|
spoiler_text=None,
|
||||||
|
in_reply_to_id=None
|
||||||
|
):
|
||||||
|
"""
|
||||||
|
Posts a new status.
|
||||||
|
https://github.com/tootsuite/documentation/blob/master/Using-the-API/API.md#posting-a-new-status
|
||||||
|
"""
|
||||||
return http.post(app, user, '/api/v1/statuses', {
|
return http.post(app, user, '/api/v1/statuses', {
|
||||||
'status': status,
|
'status': status,
|
||||||
'media_ids[]': media_ids,
|
'media_ids[]': media_ids,
|
||||||
'visibility': visibility,
|
'visibility': visibility,
|
||||||
'sensitive': sensitive,
|
'sensitive': sensitive,
|
||||||
'spoiler_text': spoiler_text,
|
'spoiler_text': spoiler_text,
|
||||||
|
'in_reply_to_id': in_reply_to_id,
|
||||||
}).json()
|
}).json()
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ def post(app, user, args):
|
|||||||
media_ids=media_ids,
|
media_ids=media_ids,
|
||||||
sensitive=args.sensitive,
|
sensitive=args.sensitive,
|
||||||
spoiler_text=args.spoiler_text,
|
spoiler_text=args.spoiler_text,
|
||||||
|
in_reply_to_id=args.reply_to,
|
||||||
)
|
)
|
||||||
|
|
||||||
print_out("Toot posted: <green>{}</green>".format(response.get('url')))
|
print_out("Toot posted: <green>{}</green>".format(response.get('url')))
|
||||||
|
@ -198,7 +198,11 @@ POST_COMMANDS = [
|
|||||||
(["-p", "--spoiler-text"], {
|
(["-p", "--spoiler-text"], {
|
||||||
"type": str,
|
"type": str,
|
||||||
"help": 'text to be shown as a warning before the actual content',
|
"help": 'text to be shown as a warning before the actual content',
|
||||||
})
|
}),
|
||||||
|
(["-r", "--reply-to"], {
|
||||||
|
"type": int,
|
||||||
|
"help": 'local ID of the status you want to reply to',
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
require_auth=True,
|
require_auth=True,
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user