Skip to content

Commit

Permalink
Add option to reply to a toot
Browse files Browse the repository at this point in the history
fixes #6
  • Loading branch information
ihabunek committed Jun 13, 2018
1 parent ea94d6b commit 8f93b25
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 9 additions & 1 deletion tests/test_console.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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'
Expand All @@ -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()
Expand Down
17 changes: 15 additions & 2 deletions toot/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
1 change: 1 addition & 0 deletions toot/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')))
Expand Down
6 changes: 5 additions & 1 deletion toot/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ def visibility(value):
(["-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,
),
Expand Down

0 comments on commit 8f93b25

Please sign in to comment.