Add option to reply to a toot

fixes #6
pull/70/head
Ivan Habunek 2018-06-13 12:43:31 +02:00
rodzic ea94d6bfe1
commit 8f93b255ad
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: CDBD63C43A30BB95
5 zmienionych plików z 34 dodań i 4 usunięć

Wyświetl plik

@ -1,6 +1,10 @@
Changelog
---------
**0.19.0 (TBA)**
* Add support for replying to a toot (#6)
**0.18.0 (2018-06-12)**
* Add support for public, tag and list timelines in `toot timeline` (#52)

Wyświetl plik

@ -39,6 +39,7 @@ def test_post_defaults(mock_post, capsys):
'media_ids[]': None,
'sensitive': False,
'spoiler_text': None,
'in_reply_to_id': None,
})
out, err = capsys.readouterr()
@ -49,7 +50,13 @@ def test_post_defaults(mock_post, capsys):
@mock.patch('toot.http.post')
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({
'url': 'https://habunek.com/@ihabunek/1234567890'
@ -63,6 +70,7 @@ def test_post_with_options(mock_post, capsys):
'visibility': 'unlisted',
'sensitive': True,
'spoiler_text': "Spoiler!",
'in_reply_to_id': 123,
})
out, err = capsys.readouterr()

Wyświetl plik

@ -76,14 +76,27 @@ def request_access_token(app, authorization_code):
return http.process_response(response).json()
def post_status(app, user, status, visibility='public', media_ids=None,
sensitive=False, spoiler_text=None):
def post_status(
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', {
'status': status,
'media_ids[]': media_ids,
'visibility': visibility,
'sensitive': sensitive,
'spoiler_text': spoiler_text,
'in_reply_to_id': in_reply_to_id,
}).json()

Wyświetl plik

@ -62,6 +62,7 @@ def post(app, user, args):
media_ids=media_ids,
sensitive=args.sensitive,
spoiler_text=args.spoiler_text,
in_reply_to_id=args.reply_to,
)
print_out("Toot posted: <green>{}</green>".format(response.get('url')))

Wyświetl plik

@ -198,7 +198,11 @@ POST_COMMANDS = [
(["-p", "--spoiler-text"], {
"type": str,
"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,
),