aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py106
1 files changed, 101 insertions, 5 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index a5cf428..69d71ec 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -166,14 +166,20 @@ class Mastodon:
166 ## 166 ##
167 def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None): 167 def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None):
168 """ 168 """
169 Fetch statuses, most recent ones first. Timeline can be home, mentions, public 169 Fetch statuses, most recent ones first. Timeline can be home, mentions, local,
170 or tag/hashtag. See the following functions documentation for what those do. 170 public, or tag/hashtag. See the following functions documentation for what those do.
171 171
172 The default timeline is the "home" timeline. 172 The default timeline is the "home" timeline.
173 173
174 Returns a list of toot dicts. 174 Returns a list of toot dicts.
175 """ 175 """
176 params = self.__generate_params(locals(), ['timeline']) 176 params_initial = locals()
177
178 if timeline == "local":
179 timeline = "public"
180 params_initial['local'] = True
181
182 params = self.__generate_params(params_initial, ['timeline'])
177 return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) 183 return self.__api_request('GET', '/api/v1/timelines/' + timeline, params)
178 184
179 def timeline_home(self, max_id = None, since_id = None, limit = None): 185 def timeline_home(self, max_id = None, since_id = None, limit = None):
@@ -192,6 +198,14 @@ class Mastodon:
192 """ 198 """
193 return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit) 199 return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit)
194 200
201 def timeline_local(self, max_id = None, since_id = None, limit = None):
202 """
203 Fetches the local / instance-wide timeline.
204
205 Returns a list of toot dicts.
206 """
207 return self.timeline('local', max_id = max_id, since_id = since_id, limit = limit)
208
195 def timeline_public(self, max_id = None, since_id = None, limit = None): 209 def timeline_public(self, max_id = None, since_id = None, limit = None):
196 """ 210 """
197 Fetches the public / visible-network timeline. 211 Fetches the public / visible-network timeline.
@@ -320,9 +334,51 @@ class Mastodon:
320 return self.__api_request('GET', '/api/v1/accounts/search', params) 334 return self.__api_request('GET', '/api/v1/accounts/search', params)
321 335
322 ### 336 ###
337 # Reading data: Mutes and Blocks
338 ###
339 def mutes(self):
340 """
341 Fetch a list of users muted by the authenticated user.
342
343 Returns a list of user dicts.
344 """
345 return self.__api_request('GET', '/api/v1/mutes')
346
347 def blocks(self):
348 """
349 Fetch a list of users blocked by the authenticated user.
350
351 Returns a list of user dicts.
352 """
353 return self.__api_request('GET', '/api/v1/blocks')
354
355 ###
356 # Reading data: Favourites
357 ###
358 def favourites(self):
359 """
360 Fetch the authenticated user's favourited statuses.
361
362 Returns a list of toot dicts.
363 """
364 return self.__api_request('GET', '/api/v1/favourites')
365
366 ###
367 # Reading data: Follow requests
368 ###
369 def follow_requests(self, max_id = None, since_id = None, limit = None):
370 """
371 Fetch the authenticated user's incoming follow requests.
372
373 Returns a list of user dicts.
374 """
375 params = self.__generate_params(locals())
376 return self.__api_request('GET', '/api/v1/follow_requests', params)
377
378 ###
323 # Writing data: Statuses 379 # Writing data: Statuses
324 ### 380 ###
325 def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = ''): 381 def status_post(self, status, in_reply_to_id = None, media_ids = None, sensitive = False, visibility = '', spoiler_text = None):
326 """ 382 """
327 Post a status. Can optionally be in reply to another status and contain 383 Post a status. Can optionally be in reply to another status and contain
328 up to four pieces of media (Uploaded via media_post()). media_ids can 384 up to four pieces of media (Uploaded via media_post()). media_ids can
@@ -342,6 +398,10 @@ class Mastodon:
342 If not passed in, visibility defaults to match the current account's 398 If not passed in, visibility defaults to match the current account's
343 privacy setting (private if the account is locked, public otherwise). 399 privacy setting (private if the account is locked, public otherwise).
344 400
401 The spoiler_text parameter is a string to be shown as a warning before
402 the text of the status. If no text is passed in, no warning will be
403 displayed.
404
345 Returns a toot dict with the new status. 405 Returns a toot dict with the new status.
346 """ 406 """
347 params_initial = locals() 407 params_initial = locals()
@@ -409,7 +469,8 @@ class Mastodon:
409 return self.__api_request('POST', '/api/v1/statuses/' + str(id) + "/favourite") 469 return self.__api_request('POST', '/api/v1/statuses/' + str(id) + "/favourite")
410 470
411 def status_unfavourite(self, id): 471 def status_unfavourite(self, id):
412 """Favourite a status. 472 """
473 Un-favourite a status.
413 474
414 Returns a toot dict with the un-favourited status. 475 Returns a toot dict with the un-favourited status.
415 """ 476 """
@@ -450,6 +511,41 @@ class Mastodon:
450 """ 511 """
451 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unblock") 512 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unblock")
452 513
514 def account_mute(self, id):
515 """
516 Mute a user.
517
518 Returns a relationship dict containing the updated relationship to the user.
519 """
520 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/mute")
521
522 def account_unmute(self, id):
523 """
524 Unmute a user.
525
526 Returns a relationship dict containing the updated relationship to the user.
527 """
528 return self.__api_request('POST', '/api/v1/accounts/' + str(id) + "/unmute")
529
530 ###
531 # Writing data: Follow requests
532 ###
533 def follow_request_authorize(self, id):
534 """
535 Accept an incoming follow request.
536
537 Returns a user dict of the authorized account.
538 """
539 return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/authorize")
540
541 def follow_request_reject(self, id):
542 """
543 Reject an incoming follow request.
544
545 Returns a user dict of the rejected account.
546 """
547 return self.__api_request('POST', '/api/v1/follow_requests/' + str(id) + "/reject")
548
453 ### 549 ###
454 # Writing data: Media 550 # Writing data: Media
455 ### 551 ###
Powered by cgit v1.2.3 (git 2.41.0)