diff options
author | Lorenz Diener <[email protected]> | 2016-11-25 15:39:53 +0100 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2016-11-25 15:39:53 +0100 |
commit | 2729ca19319edcc7a0d8df3e211010ccf857b211 (patch) | |
tree | 62246a87aa1286933c9d82b217445a9634bb4fcc /mastodon | |
parent | 2a63df2b63d6339e8b6cf75182271caa745ddf5b (diff) | |
download | mastodon.py-2729ca19319edcc7a0d8df3e211010ccf857b211.tar.gz |
More "timeline" functions, "notifications"
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 44 |
1 files changed, 41 insertions, 3 deletions
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: | |||
122 | ### | 122 | ### |
123 | # Reading data: Timelines | 123 | # Reading data: Timelines |
124 | ## | 124 | ## |
125 | def timeline(self, timeline = 'home', max_id = None, since_id = None, limit = None): | 125 | def timeline(self, timeline = "home", max_id = None, since_id = None, limit = None): |
126 | """ | 126 | """ |
127 | Returns statuses, most recent ones first. Timeline can be home, mentions, public | 127 | Returns statuses, most recent ones first. Timeline can be home, mentions, public |
128 | or tag/:hashtag | 128 | or tag/hashtag. See the following functions documentation for what those do. |
129 | |||
130 | The default timeline is the "home" timeline. | ||
129 | """ | 131 | """ |
130 | params = self.__generate_params(locals(), ['timeline']) | 132 | params = self.__generate_params(locals(), ['timeline']) |
131 | return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) | 133 | return self.__api_request('GET', '/api/v1/timelines/' + timeline, params) |
132 | 134 | ||
135 | def timeline_home(self, max_id = None, since_id = None, limit = None): | ||
136 | """ | ||
137 | Returns the authenticated users home timeline (i.e. followed users and self). | ||
138 | """ | ||
139 | return self.timeline('home', max_id = max_id, since_id = since_id, limit = limit) | ||
140 | |||
141 | def timeline_mentions(self, max_id = None, since_id = None, limit = None): | ||
142 | """ | ||
143 | Returns the authenticated users mentions. | ||
144 | """ | ||
145 | return self.timeline('mentions', max_id = max_id, since_id = since_id, limit = limit) | ||
146 | |||
147 | def timeline_public(self, max_id = None, since_id = None, limit = None): | ||
148 | """ | ||
149 | Returns the public / visible-network timeline. | ||
150 | """ | ||
151 | return self.timeline('public', max_id = max_id, since_id = since_id, limit = limit) | ||
152 | |||
153 | def timeline_hashtag(self, hashtag, max_id = None, since_id = None, limit = None): | ||
154 | """ | ||
155 | Returns all toots with a given hashtag. | ||
156 | """ | ||
157 | return self.timeline('tag/' + str(hashtag), max_id = max_id, since_id = since_id, limit = limit) | ||
158 | |||
133 | ### | 159 | ### |
134 | # Reading data: Statuses | 160 | # Reading data: Statuses |
135 | ### | 161 | ### |
@@ -158,6 +184,16 @@ class Mastodon: | |||
158 | return self.__api_request('GET', '/api/v1/statuses/' + str(id) + '/favourited_by') | 184 | return self.__api_request('GET', '/api/v1/statuses/' + str(id) + '/favourited_by') |
159 | 185 | ||
160 | ### | 186 | ### |
187 | # Reading data: Notifications | ||
188 | ### | ||
189 | def notifications(self): | ||
190 | """ | ||
191 | Returns notifications (mentions, favourites, reblogs, follows) for the authenticated | ||
192 | user. | ||
193 | """ | ||
194 | return self.__api_request('GET', '/api/v1/notifications') | ||
195 | |||
196 | ### | ||
161 | # Reading data: Accounts | 197 | # Reading data: Accounts |
162 | ### | 198 | ### |
163 | def account(self, id): | 199 | def account(self, id): |
@@ -312,7 +348,9 @@ class Mastodon: | |||
312 | type has to be specified manually, otherwise, it is | 348 | type has to be specified manually, otherwise, it is |
313 | determined from the file name. | 349 | determined from the file name. |
314 | 350 | ||
315 | Returns the ID of the media that can then be used in status_post(). | 351 | Returns the uploaded media metadata object. Importantly, this contains |
352 | the ID that can then be used in status_post() to attach the media to | ||
353 | a toot. | ||
316 | 354 | ||
317 | Throws a ValueError if the mime type of the passed data or file can | 355 | Throws a ValueError if the mime type of the passed data or file can |
318 | not be determined properly. | 356 | not be determined properly. |