Implement PR feedback and cull trailing whitespace
Default post privacy to match account privacy setting. Remove sensitive/visibility parameters from simple toot() function.
This commit is contained in:
pare
f60ff60e13
commit
963ec9c5f2
S'han modificat 1 arxius amb 124 adicions i 106 eliminacions
|
@ -318,17 +318,35 @@ class Mastodon:
|
||||||
###
|
###
|
||||||
# Writing data: Statuses
|
# Writing data: Statuses
|
||||||
###
|
###
|
||||||
def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = "public"):
|
def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = ''):
|
||||||
"""
|
"""
|
||||||
Post a status. Can optionally be in reply to another status and contain
|
Post a status. Can optionally be in reply to another status and contain
|
||||||
up to four pieces of media (Uploaded via media_post()). media_ids can
|
up to four pieces of media (Uploaded via media_post()). media_ids can
|
||||||
also be the media dicts returned by media_post - they are unpacked
|
also be the media dicts returned by media_post - they are unpacked
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
|
The 'sensitive' boolean decides whether or not media attached to the post
|
||||||
|
should be marked as sensitive, which hides it by default on the Mastodon
|
||||||
|
web front-end.
|
||||||
|
|
||||||
|
The visibility parameter is a string value and matches the visibility
|
||||||
|
option on the /api/v1/status POST API endpoint. It accepts any of:
|
||||||
|
'private' - post will be visible only to followers
|
||||||
|
'unlisted' - post will be public but not appear on the public timeline
|
||||||
|
'public' - post will be public
|
||||||
|
|
||||||
|
If not passed in, visibility defaults to match the current account's
|
||||||
|
privacy setting (private if the account is locked, public otherwise).
|
||||||
|
|
||||||
Returns a toot dict with the new status.
|
Returns a toot dict with the new status.
|
||||||
"""
|
"""
|
||||||
params_initial = locals()
|
params_initial = locals()
|
||||||
|
|
||||||
|
# Validate visibility parameter
|
||||||
|
valid_visibilities = ['private', 'public', 'unlisted', '']
|
||||||
|
if params_initial['visibility'].lower() not in valid_visibilities:
|
||||||
|
raise ValueError('Invalid visibility value! Acceptable values are %s' % valid_visibilities)
|
||||||
|
|
||||||
if media_ids != None:
|
if media_ids != None:
|
||||||
try:
|
try:
|
||||||
media_ids_proper = []
|
media_ids_proper = []
|
||||||
|
@ -345,13 +363,13 @@ class Mastodon:
|
||||||
params = self.__generate_params(params_initial)
|
params = self.__generate_params(params_initial)
|
||||||
return self.__api_request('POST', '/api/v1/statuses', params)
|
return self.__api_request('POST', '/api/v1/statuses', params)
|
||||||
|
|
||||||
def toot(self, status, sensitive=False, visibility="public"):
|
def toot(self, status):
|
||||||
"""
|
"""
|
||||||
Synonym for status_post that only takes the status text as input.
|
Synonym for status_post that only takes the status text as input.
|
||||||
|
|
||||||
Returns a toot dict with the new status.
|
Returns a toot dict with the new status.
|
||||||
"""
|
"""
|
||||||
return self.status_post(status, sensitive=sensitive, visibility=visibility)
|
return self.status_post(status)
|
||||||
|
|
||||||
def status_delete(self, id):
|
def status_delete(self, id):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Referencia en una nova incidència