Add status related commands
(un)favourite, (un)reblog & (un)pin. fixes #75
This commit is contained in:
parent
fc57d2695a
commit
82ed630864
6 changed files with 138 additions and 30 deletions
|
@ -6,6 +6,8 @@ Changelog
|
|||
* Enable interaction with instances using http instead of https (#56)
|
||||
* Enable proxy usage via environment variables (#47)
|
||||
* Make `toot post` prompt for input if no text is given (#82)
|
||||
* Add post-related commands: `favourite`, `unfavourite`, `reblog`, `unreblog`,
|
||||
`pin` & `unpin` (#75)
|
||||
|
||||
**0.19.0 (2018-06-27)**
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ toot is a commandline tool for interacting with Mastodon social networks.
|
|||
Features
|
||||
--------
|
||||
|
||||
* Posting, replying, deleting statuses
|
||||
* Posting, replying, deleting, favouriting, reblogging & pinning statuses
|
||||
* Support for media uploads, spoiler text, sensitive content
|
||||
* Search by account or hash tag
|
||||
* Following, muting and blocking accounts
|
||||
|
|
|
@ -13,32 +13,40 @@ Running ``toot <command> -h`` shows the documentation for the given command.
|
|||
toot - a Mastodon CLI client
|
||||
|
||||
Authentication:
|
||||
toot login Log into a mastodon instance using your browser (recommended)
|
||||
toot login_cli Log in from the console, does NOT support two factor authentication
|
||||
toot activate Switch between logged in accounts.
|
||||
toot logout Log out, delete stored access keys
|
||||
toot auth Show logged in accounts and instances
|
||||
toot login Log into a mastodon instance using your browser (recommended)
|
||||
toot login_cli Log in from the console, does NOT support two factor authentication
|
||||
toot activate Switch between logged in accounts.
|
||||
toot logout Log out, delete stored access keys
|
||||
toot auth Show logged in accounts and instances
|
||||
|
||||
Read:
|
||||
toot whoami Display logged in user details
|
||||
toot whois Display account details
|
||||
toot instance Display instance details
|
||||
toot search Search for users or hashtags
|
||||
toot timeline Show recent items in a timeline (home by default)
|
||||
toot curses An experimental timeline app (doesn't work on Windows)
|
||||
toot whoami Display logged in user details
|
||||
toot whois Display account details
|
||||
toot instance Display instance details
|
||||
toot search Search for users or hashtags
|
||||
toot timeline Show recent items in a timeline (home by default)
|
||||
toot curses An experimental timeline app (doesn't work on Windows)
|
||||
|
||||
Post:
|
||||
toot post Post a status text to your timeline
|
||||
toot upload Upload an image or video file
|
||||
toot delete Delete an existing status
|
||||
toot post Post a status text to your timeline
|
||||
toot upload Upload an image or video file
|
||||
|
||||
Status:
|
||||
toot delete Delete a status
|
||||
toot favourite Favourite a status
|
||||
toot unfavourite Unfavourite a status
|
||||
toot reblog Reblog a status
|
||||
toot unreblog Unreblog a status
|
||||
toot pin Pin a status
|
||||
toot unpin Unpin a status
|
||||
|
||||
Accounts:
|
||||
toot follow Follow an account
|
||||
toot unfollow Unfollow an account
|
||||
toot mute Mute an account
|
||||
toot unmute Unmute an account
|
||||
toot block Block an account
|
||||
toot unblock Unblock an account
|
||||
toot follow Follow an account
|
||||
toot unfollow Unfollow an account
|
||||
toot mute Mute an account
|
||||
toot unmute Unmute an account
|
||||
toot block Block an account
|
||||
toot unblock Unblock an account
|
||||
|
||||
To get help for each command run:
|
||||
toot <command> --help
|
||||
|
|
30
toot/api.py
30
toot/api.py
|
@ -17,6 +17,12 @@ def _account_action(app, user, account, action):
|
|||
return http.post(app, user, url).json()
|
||||
|
||||
|
||||
def _status_action(app, user, status_id, action):
|
||||
url = '/api/v1/statuses/{}/{}'.format(status_id, action)
|
||||
|
||||
return http.post(app, user, url).json()
|
||||
|
||||
|
||||
def create_app(domain, scheme='https'):
|
||||
url = '{}://{}/api/v1/apps'.format(scheme, domain)
|
||||
|
||||
|
@ -114,6 +120,30 @@ def delete_status(app, user, status_id):
|
|||
return http.delete(app, user, '/api/v1/statuses/{}'.format(status_id))
|
||||
|
||||
|
||||
def favourite(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'favourite')
|
||||
|
||||
|
||||
def unfavourite(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'unfavourite')
|
||||
|
||||
|
||||
def reblog(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'reblog')
|
||||
|
||||
|
||||
def unreblog(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'unreblog')
|
||||
|
||||
|
||||
def pin(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'pin')
|
||||
|
||||
|
||||
def unpin(app, user, status_id):
|
||||
return _status_action(app, user, status_id, 'unpin')
|
||||
|
||||
|
||||
def timeline_home(app, user):
|
||||
return http.get(app, user, '/api/v1/timelines/home').json()
|
||||
|
||||
|
|
|
@ -77,10 +77,39 @@ def post(app, user, args):
|
|||
|
||||
def delete(app, user, args):
|
||||
api.delete_status(app, user, args.status_id)
|
||||
|
||||
print_out("<green>✓ Status deleted</green>")
|
||||
|
||||
|
||||
def favourite(app, user, args):
|
||||
api.favourite(app, user, args.status_id)
|
||||
print_out("<green>✓ Status favourited</green>")
|
||||
|
||||
|
||||
def unfavourite(app, user, args):
|
||||
api.unfavourite(app, user, args.status_id)
|
||||
print_out("<green>✓ Status unfavourited</green>")
|
||||
|
||||
|
||||
def reblog(app, user, args):
|
||||
api.reblog(app, user, args.status_id)
|
||||
print_out("<green>✓ Status reblogged</green>")
|
||||
|
||||
|
||||
def unreblog(app, user, args):
|
||||
api.unreblog(app, user, args.status_id)
|
||||
print_out("<green>✓ Status unreblogged</green>")
|
||||
|
||||
|
||||
def pin(app, user, args):
|
||||
api.pin(app, user, args.status_id)
|
||||
print_out("<green>✓ Status pinned</green>")
|
||||
|
||||
|
||||
def unpin(app, user, args):
|
||||
api.unpin(app, user, args.status_id)
|
||||
print_out("<green>✓ Status unpinned</green>")
|
||||
|
||||
|
||||
def auth(app, user, args):
|
||||
config_data = config.load_config()
|
||||
|
||||
|
|
|
@ -72,6 +72,10 @@ scheme_arg = (["--disable-https"], {
|
|||
"const": "http",
|
||||
})
|
||||
|
||||
status_id_arg = (["status_id"], {
|
||||
"help": "ID of the status",
|
||||
"type": int,
|
||||
})
|
||||
|
||||
AUTH_COMMANDS = [
|
||||
Command(
|
||||
|
@ -243,15 +247,49 @@ POST_COMMANDS = [
|
|||
],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
||||
STATUS_COMMANDS = [
|
||||
Command(
|
||||
name="delete",
|
||||
description="Delete an existing status",
|
||||
arguments=[
|
||||
(["status_id"], {
|
||||
"help": "ID of the status to delete",
|
||||
"type": int,
|
||||
})
|
||||
],
|
||||
description="Delete a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="favourite",
|
||||
description="Favourite a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="unfavourite",
|
||||
description="Unfavourite a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="reblog",
|
||||
description="Reblog a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="unreblog",
|
||||
description="Unreblog a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="pin",
|
||||
description="Pin a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
Command(
|
||||
name="unpin",
|
||||
description="Unpin a status",
|
||||
arguments=[status_id_arg],
|
||||
require_auth=True,
|
||||
),
|
||||
]
|
||||
|
@ -307,7 +345,7 @@ ACCOUNTS_COMMANDS = [
|
|||
),
|
||||
]
|
||||
|
||||
COMMANDS = AUTH_COMMANDS + READ_COMMANDS + POST_COMMANDS + ACCOUNTS_COMMANDS
|
||||
COMMANDS = AUTH_COMMANDS + READ_COMMANDS + POST_COMMANDS + STATUS_COMMANDS + ACCOUNTS_COMMANDS
|
||||
|
||||
|
||||
def print_usage():
|
||||
|
@ -317,6 +355,7 @@ def print_usage():
|
|||
("Authentication", AUTH_COMMANDS),
|
||||
("Read", READ_COMMANDS),
|
||||
("Post", POST_COMMANDS),
|
||||
("Status", STATUS_COMMANDS),
|
||||
("Accounts", ACCOUNTS_COMMANDS),
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue