From 2729ca19319edcc7a0d8df3e211010ccf857b211 Mon Sep 17 00:00:00 2001 From: Lorenz Diener Date: Fri, 25 Nov 2016 15:39:53 +0100 Subject: More "timeline" functions, "notifications" --- mastodon/Mastodon.py | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'mastodon') diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index e3aac69..7bd6473 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -122,14 +122,40 @@ class Mastodon: ### # Reading data: Timelines ## - def timeline(self, timeline = 'home', max_id = None, since_id = None, limit = None): + def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None): """ Returns statuses, most recent ones first. Timeline can be home, mentions, public - or tag/:hashtag + or tag/hashtag. See the following functions documentation for what those do. + + The default timeline is the "home" timeline. """ params = self.__generate_params(locals(), ['timeline']) return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) + def timeline_home(self, max_id = None, since_id = None, limit = None): + """ + Returns the authenticated users home timeline (i.e. followed users and self). + """ + return self.timeline('home', max_id = max_id, since_id = since_id, limit = limit) + + def timeline_mentions(self, max_id = None, since_id = None, limit = None): + """ + Returns the authenticated users mentions. + """ + return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit) + + def timeline_public(self, max_id = None, since_id = None, limit = None): + """ + Returns the public / visible-network timeline. + """ + return self.timeline('public', max_id = max_id, since_id = since_id, limit = limit) + + def timeline_hashtag(self, hashtag, max_id = None, since_id = None, limit = None): + """ + Returns all toots with a given hashtag. + """ + return self.timeline('tag/' + str(hashtag), max_id = max_id, since_id = since_id, limit = limit) + ### # Reading data: Statuses ### @@ -157,6 +183,16 @@ class Mastodon: """ return self.__api_request('GET', '/api/v1/statuses/' + str(id) + '/favourited_by') + ### + # Reading data: Notifications + ### + def notifications(self): + """ + Returns notifications (mentions, favourites, reblogs, follows) for the authenticated + user. + """ + return self.__api_request('GET', '/api/v1/notifications') + ### # Reading data: Accounts ### @@ -312,7 +348,9 @@ class Mastodon: type has to be specified manually, otherwise, it is determined from the file name. - Returns the ID of the media that can then be used in status_post(). + Returns the uploaded media metadata object. Importantly, this contains + the ID that can then be used in status_post() to attach the media to + a toot. Throws a ValueError if the mime type of the passed data or file can not be determined properly. -- cgit v1.2.3