diff --git a/docs/index.rst b/docs/index.rst index d3acc41..daae043 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -328,7 +328,34 @@ Mention dicts 'acct': # Mentioned users account name (including domain) 'id': # Mentioned users (local) account ID } - + +Scheduled toot dicts +~~~~~~~~~~~~~~~~~~~~ +.. _scheduled toot dict: + +.. code-block:: python + + api2.status_post("text", scheduled_at=the_future) + # Returns the following dictionary: + { + 'id': # Scheduled toot ID (note: Not the id of the toot once it gets posted!) + 'scheduled_at': # datetime object describing when the toot is to be posted + 'params': # Parameters for the scheduled toot, specifically + { + 'text': # Toot text + 'in_reply_to_id': # ID of the toot this one is a reply to + 'media_ids': # IDs of media attached to this toot + 'sensitive': # Whether this toot is sensitive or not + 'visibility': # Visibility of the toot + 'idempotency': # Idempotency key for the scheduled toot + 'scheduled_at': # Present, but generally "None" + 'spoiler_text': # CW text for this toot + 'application_id': # ID of the application that scheduled the toot + 'poll': # Poll parameters, as a poll dict + }, + 'media_attachments': # Array of media dicts for the attachments to the scheduled toot + } + Conversation dicts ~~~~~~~~~~~~~~~~~~ .. _conversation dict: diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index d4c458f..97e8461 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -802,6 +802,18 @@ class Mastodon: url = '/api/v1/statuses/{0}/favourited_by'.format(str(id)) return self.__api_request('GET', url) + ### + # Reading data: Scheduled statuses + ### + @api_version("2.7.0", "2.7.0", __DICT_VERSION_SCHEDULED_STATUS) + def scheduled_statuses(self): + """ + Fetch a list of scheduled statuses + + Returns a list of `scheduled toot dicts`_. + """ + return self.__api_request('GET', '/api/v1/scheduled_statuses') + ### # Reading data: Notifications ### @@ -1358,7 +1370,7 @@ class Mastodon: in_reply_to_id = self.__unpack_id(in_reply_to_id) if scheduled_at != None: - scheduled_at = scheduled_at.isoformat() + scheduled_at = scheduled_at.astimezone(pytz.utc).isoformat() params_initial = locals() @@ -1554,15 +1566,17 @@ class Mastodon: # Writing data: Scheduled statuses ### @api_version("2.7.0", "2.7.0", __DICT_VERSION_SCHEDULED_STATUS) - def update_scheduled_status(self, id, scheduled_at): + def scheduled_status_update(self, id, scheduled_at): """ Update the scheduled time of a scheduled status. New time must be at least 5 minutes into the future. + + Returns a `scheduled toot dict`_ """ - scheduled_at = scheduled_at.isoformat() + scheduled_at = scheduled_at.astimezone(pytz.utc).isoformat() id = self.__unpack_id(id) - self.__generate_params(locals(), ['id']) + params = self.__generate_params(locals(), ['id']) url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) return self.__api_request('PUT', url, params)