From f734a45fb667baf40d2cae3696934f91f1d5d8d0 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 18:46:43 -0700 Subject: Added spoiler text support --- mastodon/Mastodon.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index b9ab05b..1d0e69f 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -318,7 +318,7 @@ class Mastodon: ### # Writing data: Statuses ### - def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = ''): + def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = '', spoiler_text = None): """ 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 @@ -338,6 +338,10 @@ class Mastodon: If not passed in, visibility defaults to match the current account's privacy setting (private if the account is locked, public otherwise). + The spoiler_text parameter is a string to be shown as a warning before + the text of the status. If no text is passed in, no warning will be + displayed. + Returns a toot dict with the new status. """ params_initial = locals() -- cgit v1.2.3 From 9eaf955bfc8bda2a2e114721347f9b2ccf06b055 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 10:35:42 -0700 Subject: Added local timeline support --- mastodon/Mastodon.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 1d0e69f..641c415 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -162,14 +162,20 @@ class Mastodon: ## def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None): """ - Fetch statuses, most recent ones first. Timeline can be home, mentions, public - or tag/hashtag. See the following functions documentation for what those do. + Fetch statuses, most recent ones first. Timeline can be home, mentions, local, + public, or tag/hashtag. See the following functions documentation for what those do. The default timeline is the "home" timeline. Returns a list of toot dicts. """ - params = self.__generate_params(locals(), ['timeline']) + params_initial = locals() + + if timeline == "local": + timeline = "public" + params_initial['local'] = True + + params = self.__generate_params(params_initial, ['timeline']) return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) def timeline_home(self, max_id = None, since_id = None, limit = None): @@ -188,6 +194,14 @@ class Mastodon: """ return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit) + def timeline_local(self, max_id = None, since_id = None, limit = None): + """ + Fetches the local / instance-wide timeline. + + Returns a list of toot dicts. + """ + return self.timeline('local', max_id = max_id, since_id = since_id, limit = limit) + def timeline_public(self, max_id = None, since_id = None, limit = None): """ Fetches the public / visible-network timeline. -- cgit v1.2.3 From 36781699c135b3a4cd89973ef2f5079f123a0567 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 20:20:38 -0700 Subject: Add (un)muting accounts and reading mutes/blocks --- mastodon/Mastodon.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 641c415..1c9ca4b 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -329,6 +329,25 @@ class Mastodon: params = self.__generate_params(locals()) return self.__api_request('GET', '/api/v1/accounts/search', params) + ### + # Reading data: Mutes and Blocks + ### + def mutes(self): + """ + Fetch a list of users muted by the authenticated user. + + Returns a list of user dicts. + """ + return self.__api_request('GET', '/api/v1/mutes') + + def blocks(self): + """ + Fetch a list of users blocked by the authenticated user. + + Returns a list of user dicts. + """ + return self.__api_request('GET', '/api/v1/blocks') + ### # Writing data: Statuses ### @@ -462,6 +481,22 @@ class Mastodon: """ return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unblock") + def account_mute(self, id): + """ + Mute a user. + + Returns a relationship dict containing the updated relationship to the user. + """ + return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/mute") + + def account_unmute(self, id): + """ + Unmute a user. + + Returns a relationship dict containing the updated relationship to the user. + """ + return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unmute") + ### # Writing data: Media ### -- cgit v1.2.3 From 38ebcda76bc0c264f8384f55c5b32bf049b2d6be Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 20:48:10 -0700 Subject: Added getting a list of favourited toots --- mastodon/Mastodon.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 1c9ca4b..d42c13f 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -348,6 +348,17 @@ class Mastodon: """ return self.__api_request('GET', '/api/v1/blocks') + ### + # Reading data: Favourites + ### + def favourites(self): + """ + Fetch the authenticated user's favourited statuses. + + Returns a list of toot dicts. + """ + return self.__api_request('GET', '/api/v1/favourites') + ### # Writing data: Statuses ### @@ -440,7 +451,8 @@ class Mastodon: return self.__api_request('POST', '/api/v1/statuses/' + str(id) + "/favourite") def status_unfavourite(self, id): - """Favourite a status. + """ + Un-favourite a status. Returns a toot dict with the un-favourited status. """ -- cgit v1.2.3 From ca0b6c115bcb8f6b79b22f5ccd648a2d6b7d7fc5 Mon Sep 17 00:00:00 2001 From: Erin Congden Date: Sun, 2 Apr 2017 20:53:32 -0700 Subject: Added follow requests support --- mastodon/Mastodon.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'mastodon/Mastodon.py') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index d42c13f..06fe8a1 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -359,6 +359,18 @@ class Mastodon: """ return self.__api_request('GET', '/api/v1/favourites') + ### + # Reading data: Follow requests + ### + def follow_requests(self, max_id = None, since_id = None, limit = None): + """ + Fetch the authenticated user's incoming follow requests. + + Returns a list of user dicts. + """ + params = self.__generate_params(locals()) + return self.__api_request('GET', '/api/v1/follow_requests', params) + ### # Writing data: Statuses ### @@ -509,6 +521,25 @@ class Mastodon: """ return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unmute") + ### + # Writing data: Follow requests + ### + def follow_request_authorize(self, id): + """ + Accept an incoming follow request. + + Returns a user dict of the authorized account. + """ + return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/authorize") + + def follow_request_reject(self, id): + """ + Reject an incoming follow request. + + Returns a user dict of the rejected account. + """ + return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/reject") + ### # Writing data: Media ### -- cgit v1.2.3