aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py353
1 files changed, 184 insertions, 169 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 09b0eae..e1a7a83 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -69,12 +69,27 @@ except:
69 69
70def parse_version_string(version_string): 70def parse_version_string(version_string):
71 """Parses a semver version string, stripping off "rc" stuff if present.""" 71 """Parses a semver version string, stripping off "rc" stuff if present."""
72 return tuple(int(x) for x in re.findall(r"\d+", version_string))[:3] 72 string_parts = version_string.split(".")
73 version_parts = [
74 int(re.match("([0-9]*)", string_parts[0]).group(0)),
75 int(re.match("([0-9]*)", string_parts[1]).group(0)),
76 int(re.match("([0-9]*)", string_parts[2]).group(0))
77 ]
78 return version_parts
73 79
74 80
75def max_version(*version_strings): 81def bigger_version(version_string_a, version_string_b):
76 """Returns the maximum version of all provided version strings.""" 82 """Returns the bigger version of two version strings."""
77 return max(version_strings, key=parse_version_string) 83 major_a, minor_a, patch_a = parse_version_string(version_string_a)
84 major_b, minor_b, patch_b = parse_version_string(version_string_b)
85
86 if major_a > major_b:
87 return version_string_a
88 elif major_a == major_b and minor_a > minor_b:
89 return version_string_a
90 elif major_a == major_b and minor_a == minor_b and patch_a > patch_b:
91 return version_string_a
92 return version_string_b
78 93
79 94
80def api_version(created_ver, last_changed_ver, return_value_ver): 95def api_version(created_ver, last_changed_ver, return_value_ver):
@@ -85,7 +100,8 @@ def api_version(created_ver, last_changed_ver, return_value_ver):
85 if self.version_check_mode == "created": 100 if self.version_check_mode == "created":
86 version = created_ver 101 version = created_ver
87 else: 102 else:
88 version = max_version(last_changed_ver, return_value_ver) 103 version = bigger_version(
104 last_changed_ver, return_value_ver)
89 major, minor, patch = parse_version_string(version) 105 major, minor, patch = parse_version_string(version)
90 if major > self.mastodon_major: 106 if major > self.mastodon_major:
91 raise MastodonVersionError( 107 raise MastodonVersionError(
@@ -220,33 +236,32 @@ class Mastodon:
220 __DICT_VERSION_MEDIA = "3.2.0" 236 __DICT_VERSION_MEDIA = "3.2.0"
221 __DICT_VERSION_ACCOUNT = "3.3.0" 237 __DICT_VERSION_ACCOUNT = "3.3.0"
222 __DICT_VERSION_POLL = "2.8.0" 238 __DICT_VERSION_POLL = "2.8.0"
223 __DICT_VERSION_STATUS = max_version("3.1.0", __DICT_VERSION_MEDIA, __DICT_VERSION_ACCOUNT, 239 __DICT_VERSION_STATUS = bigger_version(bigger_version(bigger_version(bigger_version(bigger_version(
224 __DICT_VERSION_APPLICATION, __DICT_VERSION_MENTION, __DICT_VERSION_POLL) 240 "3.1.0", __DICT_VERSION_MEDIA), __DICT_VERSION_ACCOUNT), __DICT_VERSION_APPLICATION), __DICT_VERSION_MENTION), __DICT_VERSION_POLL)
225 __DICT_VERSION_INSTANCE = max_version("3.4.0", __DICT_VERSION_ACCOUNT) 241 __DICT_VERSION_INSTANCE = bigger_version("3.4.0", __DICT_VERSION_ACCOUNT)
226 __DICT_VERSION_HASHTAG = "2.3.4" 242 __DICT_VERSION_HASHTAG = "2.3.4"
227 __DICT_VERSION_EMOJI = "3.0.0" 243 __DICT_VERSION_EMOJI = "3.0.0"
228 __DICT_VERSION_RELATIONSHIP = "3.3.0" 244 __DICT_VERSION_RELATIONSHIP = "3.3.0"
229 __DICT_VERSION_NOTIFICATION = max_version("3.5.0", __DICT_VERSION_ACCOUNT, __DICT_VERSION_STATUS) 245 __DICT_VERSION_NOTIFICATION = bigger_version(bigger_version("3.5.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS)
230 __DICT_VERSION_CONTEXT = max_version("1.0.0", __DICT_VERSION_STATUS) 246 __DICT_VERSION_CONTEXT = bigger_version("1.0.0", __DICT_VERSION_STATUS)
231 __DICT_VERSION_LIST = "2.1.0" 247 __DICT_VERSION_LIST = "2.1.0"
232 __DICT_VERSION_CARD = "3.2.0" 248 __DICT_VERSION_CARD = "3.2.0"
233 __DICT_VERSION_SEARCHRESULT = max_version("1.0.0", __DICT_VERSION_ACCOUNT, 249 __DICT_VERSION_SEARCHRESULT = bigger_version(bigger_version(bigger_version("1.0.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS), __DICT_VERSION_HASHTAG)
234 __DICT_VERSION_STATUS, __DICT_VERSION_HASHTAG)
235 __DICT_VERSION_ACTIVITY = "2.1.2" 250 __DICT_VERSION_ACTIVITY = "2.1.2"
236 __DICT_VERSION_REPORT = "2.9.1" 251 __DICT_VERSION_REPORT = "2.9.1"
237 __DICT_VERSION_PUSH = "2.4.0" 252 __DICT_VERSION_PUSH = "2.4.0"
238 __DICT_VERSION_PUSH_NOTIF = "2.4.0" 253 __DICT_VERSION_PUSH_NOTIF = "2.4.0"
239 __DICT_VERSION_FILTER = "2.4.3" 254 __DICT_VERSION_FILTER = "2.4.3"
240 __DICT_VERSION_CONVERSATION = max_version("2.6.0", __DICT_VERSION_ACCOUNT, __DICT_VERSION_STATUS) 255 __DICT_VERSION_CONVERSATION = bigger_version(bigger_version("2.6.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS)
241 __DICT_VERSION_SCHEDULED_STATUS = max_version("2.7.0", __DICT_VERSION_STATUS) 256 __DICT_VERSION_SCHEDULED_STATUS = bigger_version("2.7.0", __DICT_VERSION_STATUS)
242 __DICT_VERSION_PREFERENCES = "2.8.0" 257 __DICT_VERSION_PREFERENCES = "2.8.0"
243 __DICT_VERSION_ADMIN_ACCOUNT = max_version("4.0.0", __DICT_VERSION_ACCOUNT) 258 __DICT_VERSION_ADMIN_ACCOUNT = bigger_version("4.0.0", __DICT_VERSION_ACCOUNT)
244 __DICT_VERSION_FEATURED_TAG = "3.0.0" 259 __DICT_VERSION_FEATURED_TAG = "3.0.0"
245 __DICT_VERSION_MARKER = "3.0.0" 260 __DICT_VERSION_MARKER = "3.0.0"
246 __DICT_VERSION_REACTION = "3.1.0" 261 __DICT_VERSION_REACTION = "3.1.0"
247 __DICT_VERSION_ANNOUNCEMENT = max_version("3.1.0", __DICT_VERSION_REACTION) 262 __DICT_VERSION_ANNOUNCEMENT = bigger_version("3.1.0", __DICT_VERSION_REACTION)
248 __DICT_VERSION_STATUS_EDIT = "3.5.0" 263 __DICT_VERSION_STATUS_EDIT = "3.5.0"
249 __DICT_VERSION_FAMILIAR_FOLLOWERS = max_version("3.5.0", __DICT_VERSION_ACCOUNT) 264 __DICT_VERSION_FAMILIAR_FOLLOWERS = bigger_version("3.5.0", __DICT_VERSION_ACCOUNT)
250 __DICT_VERSION_ADMIN_DOMAIN_BLOCK = "4.0.0" 265 __DICT_VERSION_ADMIN_DOMAIN_BLOCK = "4.0.0"
251 __DICT_VERSION_ADMIN_MEASURE = "3.5.0" 266 __DICT_VERSION_ADMIN_MEASURE = "3.5.0"
252 __DICT_VERSION_ADMIN_DIMENSION = "3.5.0" 267 __DICT_VERSION_ADMIN_DIMENSION = "3.5.0"
@@ -329,7 +344,7 @@ class Mastodon:
329 that do not require authentication. If a file is given as `client_id`, client ID, secret and 344 that do not require authentication. If a file is given as `client_id`, client ID, secret and
330 base url are read from that file. 345 base url are read from that file.
331 346
332 You can also specify an `access_token`, directly or as a file (as written by `log_in()`_). If 347 You can also specify an `access_token`, directly or as a file (as written by :ref:`log_in() <log_in()>`). If
333 a file is given, Mastodon.py also tries to load the base URL from this file, if present. A 348 a file is given, Mastodon.py also tries to load the base URL from this file, if present. A
334 client id and secret are not required in this case. 349 client id and secret are not required in this case.
335 350
@@ -369,7 +384,7 @@ class Mastodon:
369 384
370 `lang` can be used to change the locale Mastodon will use to generate responses. Valid parameters are all ISO 639-1 (two letter) 385 `lang` can be used to change the locale Mastodon will use to generate responses. Valid parameters are all ISO 639-1 (two letter)
371 or for a language that has none, 639-3 (three letter) language codes. This affects some error messages (those related to validation) and 386 or for a language that has none, 639-3 (three letter) language codes. This affects some error messages (those related to validation) and
372 trends. You can change the language using :ref:`set_language()`_. 387 trends. You can change the language using :ref:`set_language()`.
373 388
374 If no other `User-Agent` is specified, "mastodonpy" will be used. 389 If no other `User-Agent` is specified, "mastodonpy" will be used.
375 """ 390 """
@@ -560,9 +575,9 @@ class Mastodon:
560 Returns the URL that a client needs to request an OAuth grant from the server. 575 Returns the URL that a client needs to request an OAuth grant from the server.
561 576
562 To log in with OAuth, send your user to this URL. The user will then log in and 577 To log in with OAuth, send your user to this URL. The user will then log in and
563 get a code which you can pass to `log_in()`_. 578 get a code which you can pass to :ref:`log_in() <log_in()>`.
564 579
565 `scopes` are as in `log_in()`_, redirect_uris is where the user should be redirected to 580 `scopes` are as in :ref:`log_in() <log_in()>`, redirect_uris is where the user should be redirected to
566 after authentication. Note that `redirect_uris` must be one of the URLs given during 581 after authentication. Note that `redirect_uris` must be one of the URLs given during
567 app registration. When using urn:ietf:wg:oauth:2.0:oob, the code is simply displayed, 582 app registration. When using urn:ietf:wg:oauth:2.0:oob, the code is simply displayed,
568 otherwise it is added to the given URL as the "code" request parameter. 583 otherwise it is added to the given URL as the "code" request parameter.
@@ -610,7 +625,7 @@ class Mastodon:
610 `MastodonAPIError` if all of the requested scopes were not granted. 625 `MastodonAPIError` if all of the requested scopes were not granted.
611 626
612 For OAuth 2, obtain a code via having your user go to the URL returned by 627 For OAuth 2, obtain a code via having your user go to the URL returned by
613 `auth_request_url()`_ and pass it as the code parameter. In this case, 628 :ref:`auth_request_url() <auth_request_url()>` and pass it as the code parameter. In this case,
614 make sure to also pass the same redirect_uri parameter as you used when 629 make sure to also pass the same redirect_uri parameter as you used when
615 generating the auth request URL. 630 generating the auth request URL.
616 631
@@ -800,7 +815,7 @@ class Mastodon:
800 815
801 Does not require authentication unless locked down by the administrator. 816 Does not require authentication unless locked down by the administrator.
802 817
803 Returns an `instance dict`_. 818 Returns an :ref:`instance dict <instance dict>`.
804 """ 819 """
805 return self.__instance() 820 return self.__instance()
806 821
@@ -819,7 +834,7 @@ class Mastodon:
819 834
820 Activity is returned for 12 weeks going back from the current week. 835 Activity is returned for 12 weeks going back from the current week.
821 836
822 Returns a list of `activity dicts`_. 837 Returns a list of :ref:`activity dicts <activity dicts>`.
823 """ 838 """
824 return self.__api_request('GET', '/api/v1/instance/activity') 839 return self.__api_request('GET', '/api/v1/instance/activity')
825 840
@@ -875,7 +890,7 @@ class Mastodon:
875 """ 890 """
876 Retrieve instance rules. 891 Retrieve instance rules.
877 892
878 Returns a list of `id` + `text` dicts, same as the `rules` field in the `instance dicts`_. 893 Returns a list of `id` + `text` dicts, same as the `rules` field in the :ref:`instance dicts <instance dicts>`.
879 """ 894 """
880 return self.__api_request('GET', '/api/v1/instance/rules') 895 return self.__api_request('GET', '/api/v1/instance/rules')
881 896
@@ -895,7 +910,7 @@ class Mastodon:
895 910
896 May or may not require authentication depending on server settings and what is specifically requested. 911 May or may not require authentication depending on server settings and what is specifically requested.
897 912
898 Returns a list of `status dicts`_. 913 Returns a list of :ref:`status dicts <status dicts>`.
899 """ 914 """
900 if max_id is not None: 915 if max_id is not None:
901 max_id = self.__unpack_id(max_id, dateconv=True) 916 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -930,7 +945,7 @@ class Mastodon:
930 """ 945 """
931 Convenience method: Fetches the logged-in user's home timeline (i.e. followed users and self). Params as in `timeline()`. 946 Convenience method: Fetches the logged-in user's home timeline (i.e. followed users and self). Params as in `timeline()`.
932 947
933 Returns a list of `status dicts`_. 948 Returns a list of :ref:`status dicts <status dicts>`.
934 """ 949 """
935 return self.timeline('home', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote) 950 return self.timeline('home', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
936 951
@@ -939,7 +954,7 @@ class Mastodon:
939 """ 954 """
940 Convenience method: Fetches the local / instance-wide timeline, not including replies. Params as in `timeline()`. 955 Convenience method: Fetches the local / instance-wide timeline, not including replies. Params as in `timeline()`.
941 956
942 Returns a list of `status dicts`_. 957 Returns a list of :ref:`status dicts <status dicts>`.
943 """ 958 """
944 return self.timeline('local', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media) 959 return self.timeline('local', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media)
945 960
@@ -948,7 +963,7 @@ class Mastodon:
948 """ 963 """
949 Convenience method: Fetches the public / visible-network / federated timeline, not including replies. Params as in `timeline()`. 964 Convenience method: Fetches the public / visible-network / federated timeline, not including replies. Params as in `timeline()`.
950 965
951 Returns a list of `status dicts`_. 966 Returns a list of :ref:`status dicts <status dicts>`.
952 """ 967 """
953 return self.timeline('public', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote) 968 return self.timeline('public', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
954 969
@@ -958,7 +973,7 @@ class Mastodon:
958 Convenience method: Fetch a timeline of toots with a given hashtag. The hashtag parameter 973 Convenience method: Fetch a timeline of toots with a given hashtag. The hashtag parameter
959 should not contain the leading #. Params as in `timeline()`. 974 should not contain the leading #. Params as in `timeline()`.
960 975
961 Returns a list of `status dicts`_. 976 Returns a list of :ref:`status dicts <status dicts>`.
962 """ 977 """
963 if hashtag.startswith("#"): 978 if hashtag.startswith("#"):
964 raise MastodonIllegalArgumentError( 979 raise MastodonIllegalArgumentError(
@@ -970,7 +985,7 @@ class Mastodon:
970 """ 985 """
971 Convenience method: Fetches a timeline containing all the toots by users in a given list. Params as in `timeline()`. 986 Convenience method: Fetches a timeline containing all the toots by users in a given list. Params as in `timeline()`.
972 987
973 Returns a list of `status dicts`_. 988 Returns a list of :ref:`status dicts <status dicts>`.
974 """ 989 """
975 id = self.__unpack_id(id) 990 id = self.__unpack_id(id)
976 return self.timeline('list/{0}'.format(id), max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote) 991 return self.timeline('list/{0}'.format(id), max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)
@@ -980,7 +995,7 @@ class Mastodon:
980 """ 995 """
981 Fetches a user's conversations. 996 Fetches a user's conversations.
982 997
983 Returns a list of `conversation dicts`_. 998 Returns a list of :ref:`conversation dicts <conversation dicts>`.
984 """ 999 """
985 if max_id is not None: 1000 if max_id is not None:
986 max_id = self.__unpack_id(max_id, dateconv=True) 1001 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1004,7 +1019,7 @@ class Mastodon:
1004 1019
1005 Does not require authentication for publicly visible statuses. 1020 Does not require authentication for publicly visible statuses.
1006 1021
1007 Returns a `status dict`_. 1022 Returns a :ref:`status dict <status dict>`.
1008 """ 1023 """
1009 id = self.__unpack_id(id) 1024 id = self.__unpack_id(id)
1010 url = '/api/v1/statuses/{0}'.format(str(id)) 1025 url = '/api/v1/statuses/{0}'.format(str(id))
@@ -1023,7 +1038,7 @@ class Mastodon:
1023 instead. Mastodon.py will try to mimic the old behaviour, but this 1038 instead. Mastodon.py will try to mimic the old behaviour, but this
1024 is somewhat inefficient and not guaranteed to be the case forever. 1039 is somewhat inefficient and not guaranteed to be the case forever.
1025 1040
1026 Returns a `card dict`_. 1041 Returns a :ref:`card dict <card dict>`.
1027 """ 1042 """
1028 if self.verify_minimum_version("3.0.0", cached=True): 1043 if self.verify_minimum_version("3.0.0", cached=True):
1029 return self.status(id).card 1044 return self.status(id).card
@@ -1039,7 +1054,7 @@ class Mastodon:
1039 1054
1040 Does not require authentication for publicly visible statuses. 1055 Does not require authentication for publicly visible statuses.
1041 1056
1042 Returns a `context dict`_. 1057 Returns a :ref:`context dict <context dict>`.
1043 """ 1058 """
1044 id = self.__unpack_id(id) 1059 id = self.__unpack_id(id)
1045 url = '/api/v1/statuses/{0}/context'.format(str(id)) 1060 url = '/api/v1/statuses/{0}/context'.format(str(id))
@@ -1052,7 +1067,7 @@ class Mastodon:
1052 1067
1053 Does not require authentication for publicly visible statuses. 1068 Does not require authentication for publicly visible statuses.
1054 1069
1055 Returns a list of `account dicts`_. 1070 Returns a list of :ref:`account dicts <account dicts>`.
1056 """ 1071 """
1057 id = self.__unpack_id(id) 1072 id = self.__unpack_id(id)
1058 url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id)) 1073 url = '/api/v1/statuses/{0}/reblogged_by'.format(str(id))
@@ -1065,7 +1080,7 @@ class Mastodon:
1065 1080
1066 Does not require authentication for publicly visible statuses. 1081 Does not require authentication for publicly visible statuses.
1067 1082
1068 Returns a list of `account dicts`_. 1083 Returns a list of :ref:`account dicts <account dicts>`.
1069 """ 1084 """
1070 id = self.__unpack_id(id) 1085 id = self.__unpack_id(id)
1071 url = '/api/v1/statuses/{0}/favourited_by'.format(str(id)) 1086 url = '/api/v1/statuses/{0}/favourited_by'.format(str(id))
@@ -1079,7 +1094,7 @@ class Mastodon:
1079 """ 1094 """
1080 Fetch a list of scheduled statuses 1095 Fetch a list of scheduled statuses
1081 1096
1082 Returns a list of `scheduled status dicts`_. 1097 Returns a list of :ref:`scheduled status dicts <scheduled status dicts>`.
1083 """ 1098 """
1084 return self.__api_request('GET', '/api/v1/scheduled_statuses') 1099 return self.__api_request('GET', '/api/v1/scheduled_statuses')
1085 1100
@@ -1088,7 +1103,7 @@ class Mastodon:
1088 """ 1103 """
1089 Fetch information about the scheduled status with the given id. 1104 Fetch information about the scheduled status with the given id.
1090 1105
1091 Returns a `scheduled status dict`_. 1106 Returns a :ref:`scheduled status dict <scheduled status dict>`.
1092 """ 1107 """
1093 id = self.__unpack_id(id) 1108 id = self.__unpack_id(id)
1094 url = '/api/v1/scheduled_statuses/{0}'.format(str(id)) 1109 url = '/api/v1/scheduled_statuses/{0}'.format(str(id))
@@ -1102,7 +1117,7 @@ class Mastodon:
1102 """ 1117 """
1103 Fetch information about the poll with the given id 1118 Fetch information about the poll with the given id
1104 1119
1105 Returns a `poll dict`_. 1120 Returns a :ref:`poll dict <poll dict>`.
1106 """ 1121 """
1107 id = self.__unpack_id(id) 1122 id = self.__unpack_id(id)
1108 url = '/api/v1/polls/{0}'.format(str(id)) 1123 url = '/api/v1/polls/{0}'.format(str(id))
@@ -1125,7 +1140,7 @@ class Mastodon:
1125 * `mention` - A user mentioned the logged in user 1140 * `mention` - A user mentioned the logged in user
1126 * `poll` - A poll the logged in user created or voted in has ended 1141 * `poll` - A poll the logged in user created or voted in has ended
1127 * `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited 1142 * `update` - A status the logged in user has reblogged (and only those, as of 4.0.0) has been edited
1128 * `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see `account_follow()`_) 1143 * `status` - A user that the logged in user has enabned notifications for has enabled `notify` (see :ref:`account_follow() <account_follow()>`)
1129 * `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up 1144 * `admin.sign_up` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new user has signed up
1130 * `admin.report` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received 1145 * `admin.report` - For accounts with appropriate permissions (TODO: document which those are when adding the permission API): A new report has been received
1131 Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the 1146 Parameters `exclude_types` and `types` are array of these types, specifying them will in- or exclude the
@@ -1135,7 +1150,7 @@ class Mastodon:
1135 1150
1136 Can be passed an `id` to fetch a single notification. 1151 Can be passed an `id` to fetch a single notification.
1137 1152
1138 Returns a list of `notification dicts`_. 1153 Returns a list of :ref:`notification dicts <notification dicts>`.
1139 """ 1154 """
1140 if mentions_only is not None: 1155 if mentions_only is not None:
1141 if exclude_types is None and types is None: 1156 if exclude_types is None and types is None:
@@ -1178,7 +1193,7 @@ class Mastodon:
1178 1193
1179 Does not require authentication for publicly visible accounts. 1194 Does not require authentication for publicly visible accounts.
1180 1195
1181 Returns a `account dict`_. 1196 Returns a :ref:`account dict <account dict>`.
1182 """ 1197 """
1183 id = self.__unpack_id(id) 1198 id = self.__unpack_id(id)
1184 url = '/api/v1/accounts/{0}'.format(str(id)) 1199 url = '/api/v1/accounts/{0}'.format(str(id))
@@ -1189,7 +1204,7 @@ class Mastodon:
1189 """ 1204 """
1190 Fetch logged-in user's account information. 1205 Fetch logged-in user's account information.
1191 1206
1192 Returns a `account dict`_ (Starting from 2.1.0, with an additional "source" field). 1207 Returns a :ref:`account dict <account dict>` (Starting from 2.1.0, with an additional "source" field).
1193 """ 1208 """
1194 return self.__api_request('GET', '/api/v1/accounts/verify_credentials') 1209 return self.__api_request('GET', '/api/v1/accounts/verify_credentials')
1195 1210
@@ -1205,7 +1220,7 @@ class Mastodon:
1205 @api_version("1.0.0", "2.8.0", __DICT_VERSION_STATUS) 1220 @api_version("1.0.0", "2.8.0", __DICT_VERSION_STATUS)
1206 def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, exclude_reblogs=False, tagged=None, max_id=None, min_id=None, since_id=None, limit=None): 1221 def account_statuses(self, id, only_media=False, pinned=False, exclude_replies=False, exclude_reblogs=False, tagged=None, max_id=None, min_id=None, since_id=None, limit=None):
1207 """ 1222 """
1208 Fetch statuses by user `id`. Same options as `timeline()`_ are permitted. 1223 Fetch statuses by user `id`. Same options as :ref:`timeline() <timeline()>` are permitted.
1209 Returned toots are from the perspective of the logged-in user, i.e. 1224 Returned toots are from the perspective of the logged-in user, i.e.
1210 all statuses visible to the logged-in user (including DMs) are 1225 all statuses visible to the logged-in user (including DMs) are
1211 included. 1226 included.
@@ -1220,7 +1235,7 @@ class Mastodon:
1220 Does not require authentication for Mastodon versions after 2.7.0 (returns 1235 Does not require authentication for Mastodon versions after 2.7.0 (returns
1221 publicly visible statuses in that case), for publicly visible accounts. 1236 publicly visible statuses in that case), for publicly visible accounts.
1222 1237
1223 Returns a list of `status dicts`_. 1238 Returns a list of :ref:`status dicts <status dicts>`.
1224 """ 1239 """
1225 id = self.__unpack_id(id) 1240 id = self.__unpack_id(id)
1226 if max_id is not None: 1241 if max_id is not None:
@@ -1250,7 +1265,7 @@ class Mastodon:
1250 """ 1265 """
1251 Fetch users the given user is following. 1266 Fetch users the given user is following.
1252 1267
1253 Returns a list of `account dicts`_. 1268 Returns a list of :ref:`account dicts <account dicts>`.
1254 """ 1269 """
1255 id = self.__unpack_id(id) 1270 id = self.__unpack_id(id)
1256 if max_id is not None: 1271 if max_id is not None:
@@ -1271,7 +1286,7 @@ class Mastodon:
1271 """ 1286 """
1272 Fetch users the given user is followed by. 1287 Fetch users the given user is followed by.
1273 1288
1274 Returns a list of `account dicts`_. 1289 Returns a list of :ref:`account dicts <account dicts>`.
1275 """ 1290 """
1276 id = self.__unpack_id(id) 1291 id = self.__unpack_id(id)
1277 if max_id is not None: 1292 if max_id is not None:
@@ -1293,7 +1308,7 @@ class Mastodon:
1293 Fetch relationship (following, followed_by, blocking, follow requested) of 1308 Fetch relationship (following, followed_by, blocking, follow requested) of
1294 the logged in user to a given account. `id` can be a list. 1309 the logged in user to a given account. `id` can be a list.
1295 1310
1296 Returns a list of `relationship dicts`_. 1311 Returns a list of :ref:`relationship dicts <relationship dicts>`.
1297 """ 1312 """
1298 id = self.__unpack_id(id) 1313 id = self.__unpack_id(id)
1299 params = self.__generate_params(locals()) 1314 params = self.__generate_params(locals())
@@ -1307,7 +1322,7 @@ class Mastodon:
1307 in the username@domain format and not yet in the database. Set `following` to 1322 in the username@domain format and not yet in the database. Set `following` to
1308 True to limit the search to users the logged-in user follows. 1323 True to limit the search to users the logged-in user follows.
1309 1324
1310 Returns a list of `account dicts`_. 1325 Returns a list of :ref:`account dicts <account dicts>`.
1311 """ 1326 """
1312 params = self.__generate_params(locals()) 1327 params = self.__generate_params(locals())
1313 1328
@@ -1322,7 +1337,7 @@ class Mastodon:
1322 Get all of the logged-in user's lists which the specified user is 1337 Get all of the logged-in user's lists which the specified user is
1323 a member of. 1338 a member of.
1324 1339
1325 Returns a list of `list dicts`_. 1340 Returns a list of :ref:`list dicts <list dicts>`.
1326 """ 1341 """
1327 id = self.__unpack_id(id) 1342 id = self.__unpack_id(id)
1328 params = self.__generate_params(locals(), ['id']) 1343 params = self.__generate_params(locals(), ['id'])
@@ -1337,7 +1352,7 @@ class Mastodon:
1337 and not do any webfinger requests. Use `account_search` if you need to resolve users 1352 and not do any webfinger requests. Use `account_search` if you need to resolve users
1338 through webfinger from remote. 1353 through webfinger from remote.
1339 1354
1340 Returns an `account dict`_. 1355 Returns an :ref:`account dict <account dict>`.
1341 """ 1356 """
1342 return self.__api_request('GET', '/api/v1/accounts/lookup', self.__generate_params(locals())) 1357 return self.__api_request('GET', '/api/v1/accounts/lookup', self.__generate_params(locals()))
1343 1358
@@ -1347,7 +1362,7 @@ class Mastodon:
1347 Find followers for the account given by id (can be a list) that also follow the 1362 Find followers for the account given by id (can be a list) that also follow the
1348 logged in account. 1363 logged in account.
1349 1364
1350 Returns a list of `familiar follower dicts`_ 1365 Returns a list of :ref:`familiar follower dicts <familiar follower dicts>`
1351 """ 1366 """
1352 if not isinstance(id, list): 1367 if not isinstance(id, list):
1353 id = [id] 1368 id = [id]
@@ -1362,9 +1377,9 @@ class Mastodon:
1362 def featured_tags(self): 1377 def featured_tags(self):
1363 """ 1378 """
1364 Return the hashtags the logged-in user has set to be featured on 1379 Return the hashtags the logged-in user has set to be featured on
1365 their profile as a list of `featured tag dicts`_. 1380 their profile as a list of :ref:`featured tag dicts <featured tag dicts>`.
1366 1381
1367 Returns a list of `featured tag dicts`_. 1382 Returns a list of :ref:`featured tag dicts <featured tag dicts>`.
1368 """ 1383 """
1369 return self.__api_request('GET', '/api/v1/featured_tags') 1384 return self.__api_request('GET', '/api/v1/featured_tags')
1370 1385
@@ -1373,7 +1388,7 @@ class Mastodon:
1373 """ 1388 """
1374 Returns the logged-in user's 10 most commonly-used hashtags. 1389 Returns the logged-in user's 10 most commonly-used hashtags.
1375 1390
1376 Returns a list of `hashtag dicts`_. 1391 Returns a list of :ref:`hashtag dicts <hashtag dicts>`.
1377 """ 1392 """
1378 return self.__api_request('GET', '/api/v1/featured_tags/suggestions') 1393 return self.__api_request('GET', '/api/v1/featured_tags/suggestions')
1379 1394
@@ -1385,7 +1400,7 @@ class Mastodon:
1385 """ 1400 """
1386 Fetch all of the logged-in user's filters. 1401 Fetch all of the logged-in user's filters.
1387 1402
1388 Returns a list of `filter dicts`_. Not paginated. 1403 Returns a list of :ref:`filter dicts <filter dicts>`. Not paginated.
1389 """ 1404 """
1390 return self.__api_request('GET', '/api/v1/filters') 1405 return self.__api_request('GET', '/api/v1/filters')
1391 1406
@@ -1394,7 +1409,7 @@ class Mastodon:
1394 """ 1409 """
1395 Fetches information about the filter with the specified `id`. 1410 Fetches information about the filter with the specified `id`.
1396 1411
1397 Returns a `filter dict`_. 1412 Returns a :ref:`filter dict <filter dict>`.
1398 """ 1413 """
1399 id = self.__unpack_id(id) 1414 id = self.__unpack_id(id)
1400 url = '/api/v1/filters/{0}'.format(str(id)) 1415 url = '/api/v1/filters/{0}'.format(str(id))
@@ -1443,7 +1458,7 @@ class Mastodon:
1443 """ 1458 """
1444 Fetch follow suggestions for the logged-in user. 1459 Fetch follow suggestions for the logged-in user.
1445 1460
1446 Returns a list of `account dicts`_. 1461 Returns a list of :ref:`account dicts <account dicts>`.
1447 1462
1448 """ 1463 """
1449 return self.__api_request('GET', '/api/v1/suggestions') 1464 return self.__api_request('GET', '/api/v1/suggestions')
@@ -1465,7 +1480,7 @@ class Mastodon:
1465 1480
1466 `local` True to return only local accounts. 1481 `local` True to return only local accounts.
1467 1482
1468 Returns a list of `account dicts`_. 1483 Returns a list of :ref:`account dicts <account dicts>`.
1469 1484
1470 """ 1485 """
1471 params = self.__generate_params(locals()) 1486 params = self.__generate_params(locals())
@@ -1479,7 +1494,7 @@ class Mastodon:
1479 """ 1494 """
1480 Fetch list of users endorsed by the logged-in user. 1495 Fetch list of users endorsed by the logged-in user.
1481 1496
1482 Returns a list of `account dicts`_. 1497 Returns a list of :ref:`account dicts <account dicts>`.
1483 1498
1484 """ 1499 """
1485 return self.__api_request('GET', '/api/v1/endorsements') 1500 return self.__api_request('GET', '/api/v1/endorsements')
@@ -1522,7 +1537,7 @@ class Mastodon:
1522 if you try to use them on versions before that. Note that the cached version 1537 if you try to use them on versions before that. Note that the cached version
1523 number will be used for this to avoid uneccesary requests. 1538 number will be used for this to avoid uneccesary requests.
1524 1539
1525 Returns a `search result dict`_, with tags as `hashtag dicts`_. 1540 Returns a :ref:`search result dict <search result dict>`, with tags as `hashtag dicts`_.
1526 """ 1541 """
1527 if self.verify_minimum_version("2.4.1", cached=True): 1542 if self.verify_minimum_version("2.4.1", cached=True):
1528 return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id, exclude_unreviewed=exclude_unreviewed) 1543 return self.search_v2(q, resolve=resolve, result_type=result_type, account_id=account_id, offset=offset, min_id=min_id, max_id=max_id, exclude_unreviewed=exclude_unreviewed)
@@ -1535,9 +1550,9 @@ class Mastodon:
1535 def search_v1(self, q, resolve=False): 1550 def search_v1(self, q, resolve=False):
1536 """ 1551 """
1537 Identical to `search_v2()`, except in that it does not return 1552 Identical to `search_v2()`, except in that it does not return
1538 tags as `hashtag dicts`_. 1553 tags as :ref:`hashtag dicts <hashtag dicts>`.
1539 1554
1540 Returns a `search result dict`_. 1555 Returns a :ref:`search result dict <search result dict>`.
1541 """ 1556 """
1542 params = self.__generate_params(locals()) 1557 params = self.__generate_params(locals())
1543 if not resolve: 1558 if not resolve:
@@ -1548,11 +1563,11 @@ class Mastodon:
1548 def search_v2(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None, exclude_unreviewed=True): 1563 def search_v2(self, q, resolve=True, result_type=None, account_id=None, offset=None, min_id=None, max_id=None, exclude_unreviewed=True):
1549 """ 1564 """
1550 Identical to `search_v1()`, except in that it returns tags as 1565 Identical to `search_v1()`, except in that it returns tags as
1551 `hashtag dicts`_, has more parameters, and resolves by default. 1566 :ref:`hashtag dicts <hashtag dicts>`, has more parameters, and resolves by default.
1552 1567
1553 For more details documentation, please see `search()` 1568 For more details documentation, please see `search()`
1554 1569
1555 Returns a `search result dict`_. 1570 Returns a :ref:`search result dict <search result dict>`.
1556 """ 1571 """
1557 self.__ensure_search_params_acceptable( 1572 self.__ensure_search_params_acceptable(
1558 account_id, offset, min_id, max_id) 1573 account_id, offset, min_id, max_id)
@@ -1576,7 +1591,7 @@ class Mastodon:
1576 @api_version("2.4.3", "3.5.0", __DICT_VERSION_HASHTAG) 1591 @api_version("2.4.3", "3.5.0", __DICT_VERSION_HASHTAG)
1577 def trends(self, limit=None): 1592 def trends(self, limit=None):
1578 """ 1593 """
1579 Alias for `trending_tags()`_ 1594 Alias for :ref:`trending_tags() <trending_tags()>`
1580 """ 1595 """
1581 return self.trending_tags(limit=limit) 1596 return self.trending_tags(limit=limit)
1582 1597
@@ -1595,7 +1610,7 @@ class Mastodon:
1595 1610
1596 Pass `lang` to override the global locale parameter, which may affect trend ordering. 1611 Pass `lang` to override the global locale parameter, which may affect trend ordering.
1597 1612
1598 Returns a list of `hashtag dicts`_, sorted by the instance's trending algorithm, 1613 Returns a list of :ref:`hashtag dicts <hashtag dicts>`, sorted by the instance's trending algorithm,
1599 descending. 1614 descending.
1600 """ 1615 """
1601 params = self.__generate_params(locals()) 1616 params = self.__generate_params(locals())
@@ -1615,7 +1630,7 @@ class Mastodon:
1615 1630
1616 Pass `lang` to override the global locale parameter, which may affect trend ordering. 1631 Pass `lang` to override the global locale parameter, which may affect trend ordering.
1617 1632
1618 Returns a list of `status dicts`_, sorted by the instances's trending algorithm, 1633 Returns a list of :ref:`status dicts <status dicts>`, sorted by the instances's trending algorithm,
1619 descending. 1634 descending.
1620 """ 1635 """
1621 params = self.__generate_params(locals()) 1636 params = self.__generate_params(locals())
@@ -1629,7 +1644,7 @@ class Mastodon:
1629 Specify `limit` to limit how many results are returned (the maximum number 1644 Specify `limit` to limit how many results are returned (the maximum number
1630 of results is 10, the endpoint is not paginated). 1645 of results is 10, the endpoint is not paginated).
1631 1646
1632 Returns a list of `card dicts`_, sorted by the instances's trending algorithm, 1647 Returns a list of :ref:`card dicts <card dicts>`, sorted by the instances's trending algorithm,
1633 descending. 1648 descending.
1634 """ 1649 """
1635 params = self.__generate_params(locals()) 1650 params = self.__generate_params(locals())
@@ -1643,7 +1658,7 @@ class Mastodon:
1643 """ 1658 """
1644 Fetch a list of all the Lists by the logged-in user. 1659 Fetch a list of all the Lists by the logged-in user.
1645 1660
1646 Returns a list of `list dicts`_. 1661 Returns a list of :ref:`list dicts <list dicts>`.
1647 """ 1662 """
1648 return self.__api_request('GET', '/api/v1/lists') 1663 return self.__api_request('GET', '/api/v1/lists')
1649 1664
@@ -1652,7 +1667,7 @@ class Mastodon:
1652 """ 1667 """
1653 Fetch info about a specific list. 1668 Fetch info about a specific list.
1654 1669
1655 Returns a `list dict`_. 1670 Returns a :ref:`list dict <list dict>`.
1656 """ 1671 """
1657 id = self.__unpack_id(id) 1672 id = self.__unpack_id(id)
1658 return self.__api_request('GET', '/api/v1/lists/{0}'.format(id)) 1673 return self.__api_request('GET', '/api/v1/lists/{0}'.format(id))
@@ -1662,7 +1677,7 @@ class Mastodon:
1662 """ 1677 """
1663 Get the accounts that are on the given list. 1678 Get the accounts that are on the given list.
1664 1679
1665 Returns a list of `account dicts`_. 1680 Returns a list of :ref:`account dicts <account dicts>`.
1666 """ 1681 """
1667 id = self.__unpack_id(id) 1682 id = self.__unpack_id(id)
1668 1683
@@ -1686,7 +1701,7 @@ class Mastodon:
1686 """ 1701 """
1687 Fetch a list of users muted by the logged-in user. 1702 Fetch a list of users muted by the logged-in user.
1688 1703
1689 Returns a list of `account dicts`_. 1704 Returns a list of :ref:`account dicts <account dicts>`.
1690 """ 1705 """
1691 if max_id is not None: 1706 if max_id is not None:
1692 max_id = self.__unpack_id(max_id, dateconv=True) 1707 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1705,7 +1720,7 @@ class Mastodon:
1705 """ 1720 """
1706 Fetch a list of users blocked by the logged-in user. 1721 Fetch a list of users blocked by the logged-in user.
1707 1722
1708 Returns a list of `account dicts`_. 1723 Returns a list of :ref:`account dicts <account dicts>`.
1709 """ 1724 """
1710 if max_id is not None: 1725 if max_id is not None:
1711 max_id = self.__unpack_id(max_id, dateconv=True) 1726 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1727,7 +1742,7 @@ class Mastodon:
1727 """ 1742 """
1728 Fetch a list of reports made by the logged-in user. 1743 Fetch a list of reports made by the logged-in user.
1729 1744
1730 Returns a list of `report dicts`_. 1745 Returns a list of :ref:`report dicts <report dicts>`.
1731 1746
1732 Warning: This method has now finally been removed, and will not 1747 Warning: This method has now finally been removed, and will not
1733 work on Mastodon versions 2.5.0 and above. 1748 work on Mastodon versions 2.5.0 and above.
@@ -1744,7 +1759,7 @@ class Mastodon:
1744 """ 1759 """
1745 Fetch the logged-in user's favourited statuses. 1760 Fetch the logged-in user's favourited statuses.
1746 1761
1747 Returns a list of `status dicts`_. 1762 Returns a list of :ref:`status dicts <status dicts>`.
1748 """ 1763 """
1749 if max_id is not None: 1764 if max_id is not None:
1750 max_id = self.__unpack_id(max_id, dateconv=True) 1765 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1766,7 +1781,7 @@ class Mastodon:
1766 """ 1781 """
1767 Fetch the logged-in user's incoming follow requests. 1782 Fetch the logged-in user's incoming follow requests.
1768 1783
1769 Returns a list of `account dicts`_. 1784 Returns a list of :ref:`account dicts <account dicts>`.
1770 """ 1785 """
1771 if max_id is not None: 1786 if max_id is not None:
1772 max_id = self.__unpack_id(max_id, dateconv=True) 1787 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1812,7 +1827,7 @@ class Mastodon:
1812 1827
1813 Does not require authentication unless locked down by the administrator. 1828 Does not require authentication unless locked down by the administrator.
1814 1829
1815 Returns a list of `emoji dicts`_. 1830 Returns a list of :ref:`emoji dicts <emoji dicts>`.
1816 """ 1831 """
1817 return self.__api_request('GET', '/api/v1/custom_emojis') 1832 return self.__api_request('GET', '/api/v1/custom_emojis')
1818 1833
@@ -1824,7 +1839,7 @@ class Mastodon:
1824 """ 1839 """
1825 Fetch information about the current application. 1840 Fetch information about the current application.
1826 1841
1827 Returns an `application dict`_. 1842 Returns an :ref:`application dict <application dict>`.
1828 """ 1843 """
1829 return self.__api_request('GET', '/api/v1/apps/verify_credentials') 1844 return self.__api_request('GET', '/api/v1/apps/verify_credentials')
1830 1845
@@ -1836,7 +1851,7 @@ class Mastodon:
1836 """ 1851 """
1837 Fetch the current push subscription the logged-in user has for this app. 1852 Fetch the current push subscription the logged-in user has for this app.
1838 1853
1839 Returns a `push subscription dict`_. 1854 Returns a :ref:`push subscription dict <push subscription dict>`.
1840 """ 1855 """
1841 return self.__api_request('GET', '/api/v1/push/subscription') 1856 return self.__api_request('GET', '/api/v1/push/subscription')
1842 1857
@@ -1849,7 +1864,7 @@ class Mastodon:
1849 Fetch the user's preferences, which can be used to set some default options. 1864 Fetch the user's preferences, which can be used to set some default options.
1850 As of 2.8.0, apps can only fetch, not update preferences. 1865 As of 2.8.0, apps can only fetch, not update preferences.
1851 1866
1852 Returns a `preference dict`_. 1867 Returns a :ref:`preference dict <preference dict>`.
1853 """ 1868 """
1854 return self.__api_request('GET', '/api/v1/preferences') 1869 return self.__api_request('GET', '/api/v1/preferences')
1855 1870
@@ -1863,7 +1878,7 @@ class Mastodon:
1863 """ 1878 """
1864 Fetch currently active announcements. 1879 Fetch currently active announcements.
1865 1880
1866 Returns a list of `announcement dicts`_. 1881 Returns a list of :ref:`announcement dicts <announcement dicts>`.
1867 """ 1882 """
1868 return self.__api_request('GET', '/api/v1/announcements') 1883 return self.__api_request('GET', '/api/v1/announcements')
1869 1884
@@ -1874,11 +1889,11 @@ class Mastodon:
1874 def markers_get(self, timeline=["home"]): 1889 def markers_get(self, timeline=["home"]):
1875 """ 1890 """
1876 Get the last-read-location markers for the specified timelines. Valid timelines 1891 Get the last-read-location markers for the specified timelines. Valid timelines
1877 are the same as in `timeline()`_ 1892 are the same as in :ref:`timeline() <timeline()>`
1878 1893
1879 Note that despite the singular name, `timeline` can be a list. 1894 Note that despite the singular name, `timeline` can be a list.
1880 1895
1881 Returns a dict of `read marker dicts`_, keyed by timeline name. 1896 Returns a dict of :ref:`read marker dicts <read marker dicts>`, keyed by timeline name.
1882 """ 1897 """
1883 if not isinstance(timeline, (list, tuple)): 1898 if not isinstance(timeline, (list, tuple)):
1884 timeline = [timeline] 1899 timeline = [timeline]
@@ -1894,7 +1909,7 @@ class Mastodon:
1894 """ 1909 """
1895 Get a list of statuses bookmarked by the logged-in user. 1910 Get a list of statuses bookmarked by the logged-in user.
1896 1911
1897 Returns a list of `status dicts`_. 1912 Returns a list of :ref:`status dicts <status dicts>`.
1898 """ 1913 """
1899 if max_id is not None: 1914 if max_id is not None:
1900 max_id = self.__unpack_id(max_id, dateconv=True) 1915 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -1998,8 +2013,8 @@ class Mastodon:
1998 2013
1999 `media_ids` should be a list. (If it's not, the function will turn it 2014 `media_ids` should be a list. (If it's not, the function will turn it
2000 into one.) It can contain up to four pieces of media (uploaded via 2015 into one.) It can contain up to four pieces of media (uploaded via
2001 `media_post()`_). `media_ids` can also be the `media dicts`_ returned 2016 :ref:`media_post() <media_post()>`). `media_ids` can also be the `media dicts`_ returned
2002 by `media_post()`_ - they are unpacked automatically. 2017 by :ref:`media_post() <media_post()>` - they are unpacked automatically.
2003 2018
2004 The `sensitive` boolean decides whether or not media attached to the post 2019 The `sensitive` boolean decides whether or not media attached to the post
2005 should be marked as sensitive, which hides it by default on the Mastodon 2020 should be marked as sensitive, which hides it by default on the Mastodon
@@ -2031,10 +2046,10 @@ class Mastodon:
2031 2046
2032 Pass a datetime as `scheduled_at` to schedule the toot for a specific time 2047 Pass a datetime as `scheduled_at` to schedule the toot for a specific time
2033 (the time must be at least 5 minutes into the future). If this is passed, 2048 (the time must be at least 5 minutes into the future). If this is passed,
2034 status_post returns a `scheduled status dict`_ instead. 2049 status_post returns a :ref:`scheduled status dict <scheduled status dict>` instead.
2035 2050
2036 Pass `poll` to attach a poll to the status. An appropriate object can be 2051 Pass `poll` to attach a poll to the status. An appropriate object can be
2037 constructed using `make_poll()`_ . Note that as of Mastodon version 2052 constructed using :ref:`make_poll() <make_poll()>` . Note that as of Mastodon version
2038 2.8.2, you can only have either media or a poll attached, not both at 2053 2.8.2, you can only have either media or a poll attached, not both at
2039 the same time. 2054 the same time.
2040 2055
@@ -2046,7 +2061,7 @@ class Mastodon:
2046 **Specific to "fedibird" feature set:**: The `quote_id` parameter is 2061 **Specific to "fedibird" feature set:**: The `quote_id` parameter is
2047 a non-standard extension that specifies the id of a quoted status. 2062 a non-standard extension that specifies the id of a quoted status.
2048 2063
2049 Returns a `status dict`_ with the new status. 2064 Returns a :ref:`status dict <status dict>` with the new status.
2050 """ 2065 """
2051 return self.__status_internal( 2066 return self.__status_internal(
2052 status, 2067 status,
@@ -2067,18 +2082,18 @@ class Mastodon:
2067 @api_version("1.0.0", "2.8.0", __DICT_VERSION_STATUS) 2082 @api_version("1.0.0", "2.8.0", __DICT_VERSION_STATUS)
2068 def toot(self, status): 2083 def toot(self, status):
2069 """ 2084 """
2070 Synonym for `status_post()`_ that only takes the status text as input. 2085 Synonym for :ref:`status_post() <status_post()>` that only takes the status text as input.
2071 2086
2072 Usage in production code is not recommended. 2087 Usage in production code is not recommended.
2073 2088
2074 Returns a `status dict`_ with the new status. 2089 Returns a :ref:`status dict <status dict>` with the new status.
2075 """ 2090 """
2076 return self.status_post(status) 2091 return self.status_post(status)
2077 2092
2078 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS) 2093 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS)
2079 def status_update(self, id, status = None, spoiler_text = None, sensitive = None, media_ids = None, poll = None): 2094 def status_update(self, id, status = None, spoiler_text = None, sensitive = None, media_ids = None, poll = None):
2080 """ 2095 """
2081 Edit a status. The meanings of the fields are largely the same as in `status_post()`_, 2096 Edit a status. The meanings of the fields are largely the same as in :ref:`status_post() <status_post()>`,
2082 though not every field can be edited. 2097 though not every field can be edited.
2083 2098
2084 Note that editing a poll will reset the votes. 2099 Note that editing a poll will reset the votes.
@@ -2095,7 +2110,7 @@ class Mastodon:
2095 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS_EDIT) 2110 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS_EDIT)
2096 def status_history(self, id): 2111 def status_history(self, id):
2097 """ 2112 """
2098 Returns the edit history of a status as a list of `status edit dicts`_, starting 2113 Returns the edit history of a status as a list of :ref:`status edit dicts <status edit dicts>`, starting
2099 from the original form. Note that this means that a status that has been edited 2114 from the original form. Note that this means that a status that has been edited
2100 once will have *two* entries in this list, a status that has been edited twice 2115 once will have *two* entries in this list, a status that has been edited twice
2101 will have three, and so on. 2116 will have three, and so on.
@@ -2108,7 +2123,7 @@ class Mastodon:
2108 Returns the source of a status for editing. 2123 Returns the source of a status for editing.
2109 2124
2110 Return value is a dictionary containing exactly the parameters you could pass to 2125 Return value is a dictionary containing exactly the parameters you could pass to
2111 `status_update()`_ to change nothing about the status, except `status` is `text` 2126 :ref:`status_update() <status_update()>` to change nothing about the status, except `status` is `text`
2112 instead. 2127 instead.
2113 """ 2128 """
2114 id = self.__unpack_id(id) 2129 id = self.__unpack_id(id)
@@ -2192,10 +2207,10 @@ class Mastodon:
2192 """ 2207 """
2193 Reblog / boost a status. 2208 Reblog / boost a status.
2194 2209
2195 The visibility parameter functions the same as in `status_post()`_ and 2210 The visibility parameter functions the same as in :ref:`status_post() <status_post()>` and
2196 allows you to reduce the visibility of a reblogged status. 2211 allows you to reduce the visibility of a reblogged status.
2197 2212
2198 Returns a `status dict`_ with a new status that wraps around the reblogged one. 2213 Returns a :ref:`status dict <status dict>` with a new status that wraps around the reblogged one.
2199 """ 2214 """
2200 params = self.__generate_params(locals(), ['id']) 2215 params = self.__generate_params(locals(), ['id'])
2201 valid_visibilities = ['private', 'public', 'unlisted', 'direct'] 2216 valid_visibilities = ['private', 'public', 'unlisted', 'direct']
@@ -2214,7 +2229,7 @@ class Mastodon:
2214 """ 2229 """
2215 Un-reblog a status. 2230 Un-reblog a status.
2216 2231
2217 Returns a `status dict`_ with the status that used to be reblogged. 2232 Returns a :ref:`status dict <status dict>` with the status that used to be reblogged.
2218 """ 2233 """
2219 id = self.__unpack_id(id) 2234 id = self.__unpack_id(id)
2220 url = '/api/v1/statuses/{0}/unreblog'.format(str(id)) 2235 url = '/api/v1/statuses/{0}/unreblog'.format(str(id))
@@ -2225,7 +2240,7 @@ class Mastodon:
2225 """ 2240 """
2226 Favourite a status. 2241 Favourite a status.
2227 2242
2228 Returns a `status dict`_ with the favourited status. 2243 Returns a :ref:`status dict <status dict>` with the favourited status.
2229 """ 2244 """
2230 id = self.__unpack_id(id) 2245 id = self.__unpack_id(id)
2231 url = '/api/v1/statuses/{0}/favourite'.format(str(id)) 2246 url = '/api/v1/statuses/{0}/favourite'.format(str(id))
@@ -2236,7 +2251,7 @@ class Mastodon:
2236 """ 2251 """
2237 Un-favourite a status. 2252 Un-favourite a status.
2238 2253
2239 Returns a `status dict`_ with the un-favourited status. 2254 Returns a :ref:`status dict <status dict>` with the un-favourited status.
2240 """ 2255 """
2241 id = self.__unpack_id(id) 2256 id = self.__unpack_id(id)
2242 url = '/api/v1/statuses/{0}/unfavourite'.format(str(id)) 2257 url = '/api/v1/statuses/{0}/unfavourite'.format(str(id))
@@ -2247,7 +2262,7 @@ class Mastodon:
2247 """ 2262 """
2248 Mute notifications for a status. 2263 Mute notifications for a status.
2249 2264
2250 Returns a `status dict`_ with the now muted status 2265 Returns a :ref:`status dict <status dict>` with the now muted status
2251 """ 2266 """
2252 id = self.__unpack_id(id) 2267 id = self.__unpack_id(id)
2253 url = '/api/v1/statuses/{0}/mute'.format(str(id)) 2268 url = '/api/v1/statuses/{0}/mute'.format(str(id))
@@ -2258,7 +2273,7 @@ class Mastodon:
2258 """ 2273 """
2259 Unmute notifications for a status. 2274 Unmute notifications for a status.
2260 2275
2261 Returns a `status dict`_ with the status that used to be muted. 2276 Returns a :ref:`status dict <status dict>` with the status that used to be muted.
2262 """ 2277 """
2263 id = self.__unpack_id(id) 2278 id = self.__unpack_id(id)
2264 url = '/api/v1/statuses/{0}/unmute'.format(str(id)) 2279 url = '/api/v1/statuses/{0}/unmute'.format(str(id))
@@ -2269,7 +2284,7 @@ class Mastodon:
2269 """ 2284 """
2270 Pin a status for the logged-in user. 2285 Pin a status for the logged-in user.
2271 2286
2272 Returns a `status dict`_ with the now pinned status 2287 Returns a :ref:`status dict <status dict>` with the now pinned status
2273 """ 2288 """
2274 id = self.__unpack_id(id) 2289 id = self.__unpack_id(id)
2275 url = '/api/v1/statuses/{0}/pin'.format(str(id)) 2290 url = '/api/v1/statuses/{0}/pin'.format(str(id))
@@ -2280,7 +2295,7 @@ class Mastodon:
2280 """ 2295 """
2281 Unpin a pinned status for the logged-in user. 2296 Unpin a pinned status for the logged-in user.
2282 2297
2283 Returns a `status dict`_ with the status that used to be pinned. 2298 Returns a :ref:`status dict <status dict>` with the status that used to be pinned.
2284 """ 2299 """
2285 id = self.__unpack_id(id) 2300 id = self.__unpack_id(id)
2286 url = '/api/v1/statuses/{0}/unpin'.format(str(id)) 2301 url = '/api/v1/statuses/{0}/unpin'.format(str(id))
@@ -2291,7 +2306,7 @@ class Mastodon:
2291 """ 2306 """
2292 Bookmark a status as the logged-in user. 2307 Bookmark a status as the logged-in user.
2293 2308
2294 Returns a `status dict`_ with the now bookmarked status 2309 Returns a :ref:`status dict <status dict>` with the now bookmarked status
2295 """ 2310 """
2296 id = self.__unpack_id(id) 2311 id = self.__unpack_id(id)
2297 url = '/api/v1/statuses/{0}/bookmark'.format(str(id)) 2312 url = '/api/v1/statuses/{0}/bookmark'.format(str(id))
@@ -2302,7 +2317,7 @@ class Mastodon:
2302 """ 2317 """
2303 Unbookmark a bookmarked status for the logged-in user. 2318 Unbookmark a bookmarked status for the logged-in user.
2304 2319
2305 Returns a `status dict`_ with the status that used to be bookmarked. 2320 Returns a :ref:`status dict <status dict>` with the status that used to be bookmarked.
2306 """ 2321 """
2307 id = self.__unpack_id(id) 2322 id = self.__unpack_id(id)
2308 url = '/api/v1/statuses/{0}/unbookmark'.format(str(id)) 2323 url = '/api/v1/statuses/{0}/unbookmark'.format(str(id))
@@ -2318,7 +2333,7 @@ class Mastodon:
2318 2333
2319 New time must be at least 5 minutes into the future. 2334 New time must be at least 5 minutes into the future.
2320 2335
2321 Returns a `scheduled status dict`_ 2336 Returns a :ref:`scheduled status dict <scheduled status dict>`
2322 """ 2337 """
2323 scheduled_at = self.__consistent_isoformat_utc(scheduled_at) 2338 scheduled_at = self.__consistent_isoformat_utc(scheduled_at)
2324 id = self.__unpack_id(id) 2339 id = self.__unpack_id(id)
@@ -2352,7 +2367,7 @@ class Mastodon:
2352 single-option polls, or only once per option in case of multi-option 2367 single-option polls, or only once per option in case of multi-option
2353 polls. 2368 polls.
2354 2369
2355 Returns the updated `poll dict`_ 2370 Returns the updated :ref:`poll dict <poll dict>`
2356 """ 2371 """
2357 id = self.__unpack_id(id) 2372 id = self.__unpack_id(id)
2358 if not isinstance(choices, list): 2373 if not isinstance(choices, list):
@@ -2395,7 +2410,7 @@ class Mastodon:
2395 """ 2410 """
2396 Marks a single conversation as read. 2411 Marks a single conversation as read.
2397 2412
2398 Returns the updated `conversation dict`_. 2413 Returns the updated :ref:`conversation dict <conversation dict>`.
2399 """ 2414 """
2400 id = self.__unpack_id(id) 2415 id = self.__unpack_id(id)
2401 url = '/api/v1/conversations/{0}/read'.format(str(id)) 2416 url = '/api/v1/conversations/{0}/read'.format(str(id))
@@ -2412,7 +2427,7 @@ class Mastodon:
2412 Set `reblogs` to False to hide boosts by the followed user. 2427 Set `reblogs` to False to hide boosts by the followed user.
2413 Set `notify` to True to get a notification every time the followed user posts. 2428 Set `notify` to True to get a notification every time the followed user posts.
2414 2429
2415 Returns a `relationship dict`_ containing the updated relationship to the user. 2430 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2416 """ 2431 """
2417 id = self.__unpack_id(id) 2432 id = self.__unpack_id(id)
2418 params = self.__generate_params(locals(), ["id"]) 2433 params = self.__generate_params(locals(), ["id"])
@@ -2428,7 +2443,7 @@ class Mastodon:
2428 """ 2443 """
2429 Follow a remote user by uri (username@domain). 2444 Follow a remote user by uri (username@domain).
2430 2445
2431 Returns a `account dict`_. 2446 Returns a :ref:`account dict <account dict>`.
2432 """ 2447 """
2433 params = self.__generate_params(locals()) 2448 params = self.__generate_params(locals())
2434 return self.__api_request('POST', '/api/v1/follows', params) 2449 return self.__api_request('POST', '/api/v1/follows', params)
@@ -2438,7 +2453,7 @@ class Mastodon:
2438 """ 2453 """
2439 Unfollow a user. 2454 Unfollow a user.
2440 2455
2441 Returns a `relationship dict`_ containing the updated relationship to the user. 2456 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2442 """ 2457 """
2443 id = self.__unpack_id(id) 2458 id = self.__unpack_id(id)
2444 return self.__api_request('POST', '/api/v1/accounts/{0}/unfollow'.format(str(id))) 2459 return self.__api_request('POST', '/api/v1/accounts/{0}/unfollow'.format(str(id)))
@@ -2449,7 +2464,7 @@ class Mastodon:
2449 Remove a user from the logged in users followers (i.e. make them unfollow the logged in 2464 Remove a user from the logged in users followers (i.e. make them unfollow the logged in
2450 user / "softblock" them). 2465 user / "softblock" them).
2451 2466
2452 Returns a `relationship dict`_ reflecting the updated following status. 2467 Returns a :ref:`relationship dict <relationship dict>` reflecting the updated following status.
2453 """ 2468 """
2454 id = self.__unpack_id(id) 2469 id = self.__unpack_id(id)
2455 return self.__api_request('POST', '/api/v1/accounts/{0}/remove_from_followers'.format(str(id))) 2470 return self.__api_request('POST', '/api/v1/accounts/{0}/remove_from_followers'.format(str(id)))
@@ -2460,7 +2475,7 @@ class Mastodon:
2460 """ 2475 """
2461 Block a user. 2476 Block a user.
2462 2477
2463 Returns a `relationship dict`_ containing the updated relationship to the user. 2478 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2464 """ 2479 """
2465 id = self.__unpack_id(id) 2480 id = self.__unpack_id(id)
2466 url = '/api/v1/accounts/{0}/block'.format(str(id)) 2481 url = '/api/v1/accounts/{0}/block'.format(str(id))
@@ -2471,7 +2486,7 @@ class Mastodon:
2471 """ 2486 """
2472 Unblock a user. 2487 Unblock a user.
2473 2488
2474 Returns a `relationship dict`_ containing the updated relationship to the user. 2489 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2475 """ 2490 """
2476 id = self.__unpack_id(id) 2491 id = self.__unpack_id(id)
2477 url = '/api/v1/accounts/{0}/unblock'.format(str(id)) 2492 url = '/api/v1/accounts/{0}/unblock'.format(str(id))
@@ -2486,7 +2501,7 @@ class Mastodon:
2486 muted from timelines. Pass a `duration` in seconds to have Mastodon automatically 2501 muted from timelines. Pass a `duration` in seconds to have Mastodon automatically
2487 lift the mute after that many seconds. 2502 lift the mute after that many seconds.
2488 2503
2489 Returns a `relationship dict`_ containing the updated relationship to the user. 2504 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2490 """ 2505 """
2491 id = self.__unpack_id(id) 2506 id = self.__unpack_id(id)
2492 params = self.__generate_params(locals(), ['id']) 2507 params = self.__generate_params(locals(), ['id'])
@@ -2498,7 +2513,7 @@ class Mastodon:
2498 """ 2513 """
2499 Unmute a user. 2514 Unmute a user.
2500 2515
2501 Returns a `relationship dict`_ containing the updated relationship to the user. 2516 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2502 """ 2517 """
2503 id = self.__unpack_id(id) 2518 id = self.__unpack_id(id)
2504 url = '/api/v1/accounts/{0}/unmute'.format(str(id)) 2519 url = '/api/v1/accounts/{0}/unmute'.format(str(id))
@@ -2564,7 +2579,7 @@ class Mastodon:
2564 """ 2579 """
2565 Pin / endorse a user. 2580 Pin / endorse a user.
2566 2581
2567 Returns a `relationship dict`_ containing the updated relationship to the user. 2582 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2568 """ 2583 """
2569 id = self.__unpack_id(id) 2584 id = self.__unpack_id(id)
2570 url = '/api/v1/accounts/{0}/pin'.format(str(id)) 2585 url = '/api/v1/accounts/{0}/pin'.format(str(id))
@@ -2575,7 +2590,7 @@ class Mastodon:
2575 """ 2590 """
2576 Unpin / un-endorse a user. 2591 Unpin / un-endorse a user.
2577 2592
2578 Returns a `relationship dict`_ containing the updated relationship to the user. 2593 Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
2579 """ 2594 """
2580 id = self.__unpack_id(id) 2595 id = self.__unpack_id(id)
2581 url = '/api/v1/accounts/{0}/unpin'.format(str(id)) 2596 url = '/api/v1/accounts/{0}/unpin'.format(str(id))
@@ -2586,7 +2601,7 @@ class Mastodon:
2586 """ 2601 """
2587 Set a note (visible to the logged in user only) for the given account. 2602 Set a note (visible to the logged in user only) for the given account.
2588 2603
2589 Returns a `status dict`_ with the `note` updated. 2604 Returns a :ref:`status dict <status dict>` with the `note` updated.
2590 """ 2605 """
2591 id = self.__unpack_id(id) 2606 id = self.__unpack_id(id)
2592 params = self.__generate_params(locals(), ["id"]) 2607 params = self.__generate_params(locals(), ["id"])
@@ -2597,7 +2612,7 @@ class Mastodon:
2597 """ 2612 """
2598 Get an account's featured hashtags. 2613 Get an account's featured hashtags.
2599 2614
2600 Returns a list of `hashtag dicts`_ (NOT `featured tag dicts`_). 2615 Returns a list of :ref:`hashtag dicts <hashtag dicts>` (NOT `featured tag dicts`_).
2601 """ 2616 """
2602 id = self.__unpack_id(id) 2617 id = self.__unpack_id(id)
2603 return self.__api_request('GET', '/api/v1/accounts/{0}/featured_tags'.format(str(id))) 2618 return self.__api_request('GET', '/api/v1/accounts/{0}/featured_tags'.format(str(id)))
@@ -2610,7 +2625,7 @@ class Mastodon:
2610 """ 2625 """
2611 Creates a new featured hashtag displayed on the logged-in user's profile. 2626 Creates a new featured hashtag displayed on the logged-in user's profile.
2612 2627
2613 Returns a `featured tag dict`_ with the newly featured tag. 2628 Returns a :ref:`featured tag dict <featured tag dict>` with the newly featured tag.
2614 """ 2629 """
2615 params = self.__generate_params(locals()) 2630 params = self.__generate_params(locals())
2616 return self.__api_request('POST', '/api/v1/featured_tags', params) 2631 return self.__api_request('POST', '/api/v1/featured_tags', params)
@@ -2643,7 +2658,7 @@ class Mastodon:
2643 Set `expires_in` to specify for how many seconds the filter should be 2658 Set `expires_in` to specify for how many seconds the filter should be
2644 kept around. 2659 kept around.
2645 2660
2646 Returns the `filter dict`_ of the newly created filter. 2661 Returns the :ref:`filter dict <filter dict>` of the newly created filter.
2647 """ 2662 """
2648 params = self.__generate_params(locals()) 2663 params = self.__generate_params(locals())
2649 2664
@@ -2659,7 +2674,7 @@ class Mastodon:
2659 Updates the filter with the given `id`. Parameters are the same 2674 Updates the filter with the given `id`. Parameters are the same
2660 as in `filter_create()`. 2675 as in `filter_create()`.
2661 2676
2662 Returns the `filter dict`_ of the updated filter. 2677 Returns the :ref:`filter dict <filter dict>` of the updated filter.
2663 """ 2678 """
2664 id = self.__unpack_id(id) 2679 id = self.__unpack_id(id)
2665 params = self.__generate_params(locals(), ['id']) 2680 params = self.__generate_params(locals(), ['id'])
@@ -2695,7 +2710,7 @@ class Mastodon:
2695 """ 2710 """
2696 Create a new list with the given `title`. 2711 Create a new list with the given `title`.
2697 2712
2698 Returns the `list dict`_ of the created list. 2713 Returns the :ref:`list dict <list dict>` of the created list.
2699 """ 2714 """
2700 params = self.__generate_params(locals()) 2715 params = self.__generate_params(locals())
2701 return self.__api_request('POST', '/api/v1/lists', params) 2716 return self.__api_request('POST', '/api/v1/lists', params)
@@ -2705,7 +2720,7 @@ class Mastodon:
2705 """ 2720 """
2706 Update info about a list, where "info" is really the lists `title`. 2721 Update info about a list, where "info" is really the lists `title`.
2707 2722
2708 Returns the `list dict`_ of the modified list. 2723 Returns the :ref:`list dict <list dict>` of the modified list.
2709 """ 2724 """
2710 id = self.__unpack_id(id) 2725 id = self.__unpack_id(id)
2711 params = self.__generate_params(locals(), ['id']) 2726 params = self.__generate_params(locals(), ['id'])
@@ -2761,12 +2776,12 @@ class Mastodon:
2761 2776
2762 Starting with Mastodon 3.5.0, you can also pass a `category` (one out of 2777 Starting with Mastodon 3.5.0, you can also pass a `category` (one out of
2763 "spam", "violation" or "other") and `rule_ids` (a list of rule IDs corresponding 2778 "spam", "violation" or "other") and `rule_ids` (a list of rule IDs corresponding
2764 to the rules returned by the `instance()`_ API). 2779 to the rules returned by the :ref:`instance() <instance()>` API).
2765 2780
2766 Set `forward` to True to forward a report of a remote user to that users 2781 Set `forward` to True to forward a report of a remote user to that users
2767 instance as well as sending it to the instance local administrators. 2782 instance as well as sending it to the instance local administrators.
2768 2783
2769 Returns a `report dict`_. 2784 Returns a :ref:`report dict <report dict>`.
2770 """ 2785 """
2771 if category is not None and not category in ["spam", "violation", "other"]: 2786 if category is not None and not category in ["spam", "violation", "other"]:
2772 raise MastodonIllegalArgumentError("Invalid report category (must be spam, violation or other)") 2787 raise MastodonIllegalArgumentError("Invalid report category (must be spam, violation or other)")
@@ -2793,7 +2808,7 @@ class Mastodon:
2793 """ 2808 """
2794 Accept an incoming follow request. 2809 Accept an incoming follow request.
2795 2810
2796 Returns the updated `relationship dict`_ for the requesting account. 2811 Returns the updated :ref:`relationship dict <relationship dict>` for the requesting account.
2797 """ 2812 """
2798 id = self.__unpack_id(id) 2813 id = self.__unpack_id(id)
2799 url = '/api/v1/follow_requests/{0}/authorize'.format(str(id)) 2814 url = '/api/v1/follow_requests/{0}/authorize'.format(str(id))
@@ -2804,7 +2819,7 @@ class Mastodon:
2804 """ 2819 """
2805 Reject an incoming follow request. 2820 Reject an incoming follow request.
2806 2821
2807 Returns the updated `relationship dict`_ for the requesting account. 2822 Returns the updated :ref:`relationship dict <relationship dict>` for the requesting account.
2808 """ 2823 """
2809 id = self.__unpack_id(id) 2824 id = self.__unpack_id(id)
2810 url = '/api/v1/follow_requests/{0}/reject'.format(str(id)) 2825 url = '/api/v1/follow_requests/{0}/reject'.format(str(id))
@@ -2833,7 +2848,7 @@ class Mastodon:
2833 Starting with Mastodon 3.2.0, `thumbnail` can be specified in the same way as `media_file` 2848 Starting with Mastodon 3.2.0, `thumbnail` can be specified in the same way as `media_file`
2834 to upload a custom thumbnail image for audio and video files. 2849 to upload a custom thumbnail image for audio and video files.
2835 2850
2836 Returns a `media dict`_. This contains the id that can be used in 2851 Returns a :ref:`media dict <media dict>`. This contains the id that can be used in
2837 status_post to attach the media file to a toot. 2852 status_post to attach the media file to a toot.
2838 2853
2839 When using the v2 API (post Mastodon version 3.1.4), the `url` in the 2854 When using the v2 API (post Mastodon version 3.1.4), the `url` in the
@@ -2883,9 +2898,9 @@ class Mastodon:
2883 def media_update(self, id, description=None, focus=None, thumbnail=None, thumbnail_mime_type=None): 2898 def media_update(self, id, description=None, focus=None, thumbnail=None, thumbnail_mime_type=None):
2884 """ 2899 """
2885 Update the metadata of the media file with the given `id`. `description` and 2900 Update the metadata of the media file with the given `id`. `description` and
2886 `focus` and `thumbnail` are as in `media_post()`_ . 2901 `focus` and `thumbnail` are as in :ref:`media_post() <media_post()>` .
2887 2902
2888 Returns the updated `media dict`_. 2903 Returns the updated :ref:`media dict <media dict>`.
2889 """ 2904 """
2890 id = self.__unpack_id(id) 2905 id = self.__unpack_id(id)
2891 2906
@@ -2943,7 +2958,7 @@ class Mastodon:
2943 2958
2944 Note that if you give an invalid timeline name, this will silently do nothing. 2959 Note that if you give an invalid timeline name, this will silently do nothing.
2945 2960
2946 Returns a dict with the updated `read marker dicts`_, keyed by timeline name. 2961 Returns a dict with the updated :ref:`read marker dicts <read marker dicts>`, keyed by timeline name.
2947 """ 2962 """
2948 if not isinstance(timelines, (list, tuple)): 2963 if not isinstance(timelines, (list, tuple)):
2949 timelines = [timelines] 2964 timelines = [timelines]
@@ -2977,14 +2992,14 @@ class Mastodon:
2977 requires https for this URL. `encrypt_params` is a dict with key parameters that allow 2992 requires https for this URL. `encrypt_params` is a dict with key parameters that allow
2978 the server to encrypt data for you: A public key `pubkey` and a shared secret `auth`. 2993 the server to encrypt data for you: A public key `pubkey` and a shared secret `auth`.
2979 You can generate this as well as the corresponding private key using the 2994 You can generate this as well as the corresponding private key using the
2980 `push_subscription_generate_keys()`_ function. 2995 :ref:`push_subscription_generate_keys() <push_subscription_generate_keys()>` function.
2981 2996
2982 `policy` controls what sources will generate webpush events. Valid values are 2997 `policy` controls what sources will generate webpush events. Valid values are
2983 `all`, `none`, `follower` and `followed`. 2998 `all`, `none`, `follower` and `followed`.
2984 2999
2985 The rest of the parameters controls what kind of events you wish to subscribe to. 3000 The rest of the parameters controls what kind of events you wish to subscribe to.
2986 3001
2987 Returns a `push subscription dict`_. 3002 Returns a :ref:`push subscription dict <push subscription dict>`.
2988 """ 3003 """
2989 if not policy in ['all', 'none', 'follower', 'followed']: 3004 if not policy in ['all', 'none', 'follower', 'followed']:
2990 raise MastodonIllegalArgumentError("Valid values for policy are 'all', 'none', 'follower' or 'followed'.") 3005 raise MastodonIllegalArgumentError("Valid values for policy are 'all', 'none', 'follower' or 'followed'.")
@@ -3035,7 +3050,7 @@ class Mastodon:
3035 """ 3050 """
3036 Modifies what kind of events the app wishes to subscribe to. 3051 Modifies what kind of events the app wishes to subscribe to.
3037 3052
3038 Returns the updated `push subscription dict`_. 3053 Returns the updated :ref:`push subscription dict <push subscription dict>`.
3039 """ 3054 """
3040 params = {} 3055 params = {}
3041 3056
@@ -3131,7 +3146,7 @@ class Mastodon:
3131 * Set `invited_by` to an account id to get only accounts invited by this user. 3146 * Set `invited_by` to an account id to get only accounts invited by this user.
3132 * Set `role_ids` to a list of role IDs to get only accounts with those roles. 3147 * Set `role_ids` to a list of role IDs to get only accounts with those roles.
3133 3148
3134 Returns a list of `admin account dicts`_. 3149 Returns a list of :ref:`admin account dicts <admin account dicts>`.
3135 """ 3150 """
3136 if max_id is not None: 3151 if max_id is not None:
3137 max_id = self.__unpack_id(max_id, dateconv=True) 3152 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -3205,7 +3220,7 @@ class Mastodon:
3205 3220
3206 Deprecated in Mastodon version 3.5.0. 3221 Deprecated in Mastodon version 3.5.0.
3207 3222
3208 Returns a list of `admin account dicts`_. 3223 Returns a list of :ref:`admin account dicts <admin account dicts>`.
3209 """ 3224 """
3210 if max_id is not None: 3225 if max_id is not None:
3211 max_id = self.__unpack_id(max_id, dateconv=True) 3226 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -3240,7 +3255,7 @@ class Mastodon:
3240 @api_version("2.9.1", "2.9.1", __DICT_VERSION_ADMIN_ACCOUNT) 3255 @api_version("2.9.1", "2.9.1", __DICT_VERSION_ADMIN_ACCOUNT)
3241 def admin_account(self, id): 3256 def admin_account(self, id):
3242 """ 3257 """
3243 Fetches a single `admin account dict`_ for the user with the given id. 3258 Fetches a single :ref:`admin account dict <admin account dict>` for the user with the given id.
3244 3259
3245 Returns that dict. 3260 Returns that dict.
3246 """ 3261 """
@@ -3252,7 +3267,7 @@ class Mastodon:
3252 """ 3267 """
3253 Reenables login for a local account for which login has been disabled. 3268 Reenables login for a local account for which login has been disabled.
3254 3269
3255 Returns the updated `admin account dict`_. 3270 Returns the updated :ref:`admin account dict <admin account dict>`.
3256 """ 3271 """
3257 id = self.__unpack_id(id) 3272 id = self.__unpack_id(id)
3258 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/enable'.format(id)) 3273 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/enable'.format(id))
@@ -3262,7 +3277,7 @@ class Mastodon:
3262 """ 3277 """
3263 Approves a pending account. 3278 Approves a pending account.
3264 3279
3265 Returns the updated `admin account dict`_. 3280 Returns the updated :ref:`admin account dict <admin account dict>`.
3266 """ 3281 """
3267 id = self.__unpack_id(id) 3282 id = self.__unpack_id(id)
3268 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/approve'.format(id)) 3283 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/approve'.format(id))
@@ -3272,7 +3287,7 @@ class Mastodon:
3272 """ 3287 """
3273 Rejects and deletes a pending account. 3288 Rejects and deletes a pending account.
3274 3289
3275 Returns the updated `admin account dict`_ for the account that is now gone. 3290 Returns the updated :ref:`admin account dict <admin account dict>` for the account that is now gone.
3276 """ 3291 """
3277 id = self.__unpack_id(id) 3292 id = self.__unpack_id(id)
3278 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/reject'.format(id)) 3293 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/reject'.format(id))
@@ -3282,7 +3297,7 @@ class Mastodon:
3282 """ 3297 """
3283 Unsilences an account. 3298 Unsilences an account.
3284 3299
3285 Returns the updated `admin account dict`_. 3300 Returns the updated :ref:`admin account dict <admin account dict>`.
3286 """ 3301 """
3287 id = self.__unpack_id(id) 3302 id = self.__unpack_id(id)
3288 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsilence'.format(id)) 3303 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsilence'.format(id))
@@ -3292,7 +3307,7 @@ class Mastodon:
3292 """ 3307 """
3293 Unsuspends an account. 3308 Unsuspends an account.
3294 3309
3295 Returns the updated `admin account dict`_. 3310 Returns the updated :ref:`admin account dict <admin account dict>`.
3296 """ 3311 """
3297 id = self.__unpack_id(id) 3312 id = self.__unpack_id(id)
3298 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsuspend'.format(id)) 3313 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsuspend'.format(id))
@@ -3302,7 +3317,7 @@ class Mastodon:
3302 """ 3317 """
3303 Delete a local user account. 3318 Delete a local user account.
3304 3319
3305 The deleted accounts `admin account dict`_. 3320 The deleted accounts :ref:`admin account dict <admin account dict>`.
3306 """ 3321 """
3307 id = self.__unpack_id(id) 3322 id = self.__unpack_id(id)
3308 return self.__api_request('DELETE', '/api/v1/admin/accounts/{0}'.format(id)) 3323 return self.__api_request('DELETE', '/api/v1/admin/accounts/{0}'.format(id))
@@ -3312,7 +3327,7 @@ class Mastodon:
3312 """ 3327 """
3313 Unmark an account as force-sensitive. 3328 Unmark an account as force-sensitive.
3314 3329
3315 Returns the updated `admin account dict`_. 3330 Returns the updated :ref:`admin account dict <admin account dict>`.
3316 """ 3331 """
3317 id = self.__unpack_id(id) 3332 id = self.__unpack_id(id)
3318 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsensitive'.format(id)) 3333 return self.__api_request('POST', '/api/v1/admin/accounts/{0}/unsensitive'.format(id))
@@ -3362,7 +3377,7 @@ class Mastodon:
3362 Set `resolved` to True to search for resolved reports. `account_id` and `target_account_id` 3377 Set `resolved` to True to search for resolved reports. `account_id` and `target_account_id`
3363 can be used to get reports filed by or about a specific user. 3378 can be used to get reports filed by or about a specific user.
3364 3379
3365 Returns a list of `report dicts`_. 3380 Returns a list of :ref:`report dicts <report dicts>`.
3366 """ 3381 """
3367 if max_id is not None: 3382 if max_id is not None:
3368 max_id = self.__unpack_id(max_id, dateconv=True) 3383 max_id = self.__unpack_id(max_id, dateconv=True)
@@ -3390,7 +3405,7 @@ class Mastodon:
3390 """ 3405 """
3391 Fetches the report with the given id. 3406 Fetches the report with the given id.
3392 3407
3393 Returns a `report dict`_. 3408 Returns a :ref:`report dict <report dict>`.
3394 """ 3409 """
3395 id = self.__unpack_id(id) 3410 id = self.__unpack_id(id)
3396 return self.__api_request('GET', '/api/v1/admin/reports/{0}'.format(id)) 3411 return self.__api_request('GET', '/api/v1/admin/reports/{0}'.format(id))
@@ -3400,7 +3415,7 @@ class Mastodon:
3400 """ 3415 """
3401 Assigns the given report to the logged-in user. 3416 Assigns the given report to the logged-in user.
3402 3417
3403 Returns the updated `report dict`_. 3418 Returns the updated :ref:`report dict <report dict>`.
3404 """ 3419 """
3405 id = self.__unpack_id(id) 3420 id = self.__unpack_id(id)
3406 return self.__api_request('POST', '/api/v1/admin/reports/{0}/assign_to_self'.format(id)) 3421 return self.__api_request('POST', '/api/v1/admin/reports/{0}/assign_to_self'.format(id))
@@ -3410,7 +3425,7 @@ class Mastodon:
3410 """ 3425 """
3411 Unassigns the given report from the logged-in user. 3426 Unassigns the given report from the logged-in user.
3412 3427
3413 Returns the updated `report dict`_. 3428 Returns the updated :ref:`report dict <report dict>`.
3414 """ 3429 """
3415 id = self.__unpack_id(id) 3430 id = self.__unpack_id(id)
3416 return self.__api_request('POST', '/api/v1/admin/reports/{0}/unassign'.format(id)) 3431 return self.__api_request('POST', '/api/v1/admin/reports/{0}/unassign'.format(id))
@@ -3420,7 +3435,7 @@ class Mastodon:
3420 """ 3435 """
3421 Reopens a closed report. 3436 Reopens a closed report.
3422 3437
3423 Returns the updated `report dict`_. 3438 Returns the updated :ref:`report dict <report dict>`.
3424 """ 3439 """
3425 id = self.__unpack_id(id) 3440 id = self.__unpack_id(id)
3426 return self.__api_request('POST', '/api/v1/admin/reports/{0}/reopen'.format(id)) 3441 return self.__api_request('POST', '/api/v1/admin/reports/{0}/reopen'.format(id))
@@ -3430,7 +3445,7 @@ class Mastodon:
3430 """ 3445 """
3431 Marks a report as resolved (without taking any action). 3446 Marks a report as resolved (without taking any action).
3432 3447
3433 Returns the updated `report dict`_. 3448 Returns the updated :ref:`report dict <report dict>`.
3434 """ 3449 """
3435 id = self.__unpack_id(id) 3450 id = self.__unpack_id(id)
3436 return self.__api_request('POST', '/api/v1/admin/reports/{0}/resolve'.format(id)) 3451 return self.__api_request('POST', '/api/v1/admin/reports/{0}/resolve'.format(id))
@@ -3438,9 +3453,9 @@ class Mastodon:
3438 @api_version("3.5.0", "3.5.0", __DICT_VERSION_HASHTAG) 3453 @api_version("3.5.0", "3.5.0", __DICT_VERSION_HASHTAG)
3439 def admin_trending_tags(self, limit=None): 3454 def admin_trending_tags(self, limit=None):
3440 """ 3455 """
3441 Admin version of `trending_tags()`_. Includes unapproved tags. 3456 Admin version of :ref:`trending_tags() <trending_tags()>`. Includes unapproved tags.
3442 3457
3443 Returns a list of `hashtag dicts`_, sorted by the instance's trending algorithm, 3458 Returns a list of :ref:`hashtag dicts <hashtag dicts>`, sorted by the instance's trending algorithm,
3444 descending. 3459 descending.
3445 """ 3460 """
3446 params = self.__generate_params(locals()) 3461 params = self.__generate_params(locals())
@@ -3449,9 +3464,9 @@ class Mastodon:
3449 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS) 3464 @api_version("3.5.0", "3.5.0", __DICT_VERSION_STATUS)
3450 def admin_trending_statuses(self): 3465 def admin_trending_statuses(self):
3451 """ 3466 """
3452 Admin version of `trending_statuses()`_. Includes unapproved tags. 3467 Admin version of :ref:`trending_statuses() <trending_statuses()>`. Includes unapproved tags.
3453 3468
3454 Returns a list of `status dicts`_, sorted by the instance's trending algorithm, 3469 Returns a list of :ref:`status dicts <status dicts>`, sorted by the instance's trending algorithm,
3455 descending. 3470 descending.
3456 """ 3471 """
3457 params = self.__generate_params(locals()) 3472 params = self.__generate_params(locals())
@@ -3460,9 +3475,9 @@ class Mastodon:
3460 @api_version("3.5.0", "3.5.0", __DICT_VERSION_CARD) 3475 @api_version("3.5.0", "3.5.0", __DICT_VERSION_CARD)
3461 def admin_trending_links(self): 3476 def admin_trending_links(self):
3462 """ 3477 """
3463 Admin version of `trending_links()`_. Includes unapproved tags. 3478 Admin version of :ref:`trending_links() <trending_links()>`. Includes unapproved tags.
3464 3479
3465 Returns a list of `card dicts`_, sorted by the instance's trending algorithm, 3480 Returns a list of :ref:`card dicts <card dicts>`, sorted by the instance's trending algorithm,
3466 descending. 3481 descending.
3467 """ 3482 """
3468 params = self.__generate_params(locals()) 3483 params = self.__generate_params(locals())
@@ -3475,7 +3490,7 @@ class Mastodon:
3475 3490
3476 Provide an `id` to fetch a specific domain block based on its database id. 3491 Provide an `id` to fetch a specific domain block based on its database id.
3477 3492
3478 Returns a list of `admin domain block dicts`_, raises a `MastodonAPIError` if the specified block does not exist. 3493 Returns a list of :ref:`admin domain block dicts <admin domain block dicts>`, raises a `MastodonAPIError` if the specified block does not exist.
3479 """ 3494 """
3480 if id is not None: 3495 if id is not None:
3481 id = self.__unpack_id(id) 3496 id = self.__unpack_id(id)
@@ -3502,7 +3517,7 @@ class Mastodon:
3502 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings. 3517 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings.
3503 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs. 3518 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs.
3504 3519
3505 Returns the new domain block as an `admin domain block dict`_. 3520 Returns the new domain block as an :ref:`admin domain block dict <admin domain block dict>`.
3506 """ 3521 """
3507 if domain is None: 3522 if domain is None:
3508 raise AttributeError("Must provide a domain to block a domain") 3523 raise AttributeError("Must provide a domain to block a domain")
@@ -3527,7 +3542,7 @@ class Mastodon:
3527 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings. 3542 `public_comment` sets a publicly available comment for this domain, which will be available to local users and may be available to everyone depending on your settings.
3528 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs. 3543 `obfuscate` censors some part of the domain name. Useful if the domain name contains unwanted words like slurs.
3529 3544
3530 Returns the modified domain block as an `admin domain block dict`_, raises a `MastodonAPIError` if the specified block does not exist. 3545 Returns the modified domain block as an :ref:`admin domain block dict <admin domain block dict>`, raises a `MastodonAPIError` if the specified block does not exist.
3531 """ 3546 """
3532 if id is None: 3547 if id is None:
3533 raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.") 3548 raise AttributeError("Must provide an id to modify the existing moderation actions on a given domain.")
@@ -3578,7 +3593,7 @@ class Mastodon:
3578 There is currently no way to get tag IDs implemented in Mastodon.py, because the Mastodon public API does not implement one. This will be fixed in a future 3593 There is currently no way to get tag IDs implemented in Mastodon.py, because the Mastodon public API does not implement one. This will be fixed in a future
3579 release. 3594 release.
3580 3595
3581 Returns a list of `admin measure dicts`_. 3596 Returns a list of :ref:`admin measure dicts <admin measure dicts>`.
3582 """ 3597 """
3583 params_init = locals() 3598 params_init = locals()
3584 keys = [] 3599 keys = []
@@ -3628,7 +3643,7 @@ class Mastodon:
3628 There is currently no way to get tag IDs implemented in Mastodon.py, because the Mastodon public API does not implement one. This will be fixed in a future 3643 There is currently no way to get tag IDs implemented in Mastodon.py, because the Mastodon public API does not implement one. This will be fixed in a future
3629 release. 3644 release.
3630 3645
3631 Returns a list of `admin dimension dicts`_. 3646 Returns a list of :ref:`admin dimension dicts <admin dimension dicts>`.
3632 """ 3647 """
3633 params_init = locals() 3648 params_init = locals()
3634 keys = [] 3649 keys = []
@@ -3662,7 +3677,7 @@ class Mastodon:
3662 """ 3677 """
3663 Gets user retention statistics (at `frequency` - "day" or "month" - granularity) between `start_at` and `end_at`. 3678 Gets user retention statistics (at `frequency` - "day" or "month" - granularity) between `start_at` and `end_at`.
3664 3679
3665 Returns a list of `admin retention dicts`_ 3680 Returns a list of :ref:`admin retention dicts <admin retention dicts>`
3666 """ 3681 """
3667 if not frequency in ["day", "month"]: 3682 if not frequency in ["day", "month"]:
3668 raise MastodonIllegalArgumentError("Frequency must be day or month") 3683 raise MastodonIllegalArgumentError("Frequency must be day or month")
@@ -3694,7 +3709,7 @@ class Mastodon:
3694 crypto_ver = cryptography.__version__ 3709 crypto_ver = cryptography.__version__
3695 if len(crypto_ver) < 5: 3710 if len(crypto_ver) < 5:
3696 crypto_ver += ".0" 3711 crypto_ver += ".0"
3697 if parse_version_string(crypto_ver) == (2, 5, 0): 3712 if bigger_version(crypto_ver, "2.5.0") == crypto_ver:
3698 push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint) 3713 push_key_pub = push_key_pair.public_key().public_bytes(serialization.Encoding.X962, serialization.PublicFormat.UncompressedPoint)
3699 else: 3714 else:
3700 push_key_pub = push_key_pair.public_key().public_numbers().encode_point() 3715 push_key_pub = push_key_pair.public_key().public_numbers().encode_point()
@@ -3716,10 +3731,10 @@ class Mastodon:
3716 def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header): 3731 def push_subscription_decrypt_push(self, data, decrypt_params, encryption_header, crypto_key_header):
3717 """ 3732 """
3718 Decrypts `data` received in a webpush request. Requires the private key dict 3733 Decrypts `data` received in a webpush request. Requires the private key dict
3719 from `push_subscription_generate_keys()`_ (`decrypt_params`) as well as the 3734 from :ref:`push_subscription_generate_keys() <push_subscription_generate_keys()>` (`decrypt_params`) as well as the
3720 Encryption and server Crypto-Key headers from the received webpush 3735 Encryption and server Crypto-Key headers from the received webpush
3721 3736
3722 Returns the decoded webpush as a `push notification dict`_. 3737 Returns the decoded webpush as a :ref:`push notification dict <push notification dict>`.
3723 """ 3738 """
3724 if (not IMPL_HAS_ECE) or (not IMPL_HAS_CRYPTO): 3739 if (not IMPL_HAS_ECE) or (not IMPL_HAS_CRYPTO):
3725 raise NotImplementedError( 3740 raise NotImplementedError(
Powered by cgit v1.2.3 (git 2.41.0)