aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-04-28 13:47:43 +0200
committerLorenz Diener <[email protected]>2019-04-28 13:47:43 +0200
commit06df1c281eb0825ec9f646960f4d9426eba7e081 (patch)
tree6f6d8607650773da3bb52bf89a01816342321e41 /mastodon
parent8e0d8a5c4e1e3f7ff6a23fe936388ca9fbdba990 (diff)
downloadmastodon.py-06df1c281eb0825ec9f646960f4d9426eba7e081.tar.gz
Add conversation fetching
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py39
-rw-r--r--mastodon/__init__.py3
2 files changed, 35 insertions, 7 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py
index 1104028..6897bc6 100644
--- a/mastodon/Mastodon.py
+++ b/mastodon/Mastodon.py
@@ -127,7 +127,6 @@ class Mastodon:
127 'read:lists', 127 'read:lists',
128 'read:mutes', 128 'read:mutes',
129 'read:notifications', 129 'read:notifications',
130 'read:reports',
131 'read:search', 130 'read:search',
132 'read:statuses' 131 'read:statuses'
133 ], 132 ],
@@ -179,6 +178,7 @@ class Mastodon:
179 __DICT_VERSION_PUSH = "2.4.0" 178 __DICT_VERSION_PUSH = "2.4.0"
180 __DICT_VERSION_PUSH_NOTIF = "2.4.0" 179 __DICT_VERSION_PUSH_NOTIF = "2.4.0"
181 __DICT_VERSION_FILTER = "2.4.3" 180 __DICT_VERSION_FILTER = "2.4.3"
181 __DICT_VERSION_CONVERSATION = bigger_version(bigger_version("2.6.0", __DICT_VERSION_ACCOUNT), __DICT_VERSION_STATUS)
182 182
183 ### 183 ###
184 # Registering apps 184 # Registering apps
@@ -649,6 +649,25 @@ class Mastodon:
649 return self.timeline('list/{0}'.format(id), max_id=max_id, 649 return self.timeline('list/{0}'.format(id), max_id=max_id,
650 min_id=min_id, since_id=since_id, limit=limit) 650 min_id=min_id, since_id=since_id, limit=limit)
651 651
652 @api_version("2.6.0", "2.6.0", __DICT_VERSION_CONVERSATION)
653 def conversations(self, max_id=None, min_id=None, since_id=None, limit=None):
654 """
655 Fetches a users conversations.
656
657 Returns a list of `conversation dicts`_.
658 """
659 if max_id != None:
660 max_id = self.__unpack_id(max_id)
661
662 if min_id != None:
663 min_id = self.__unpack_id(min_id)
664
665 if since_id != None:
666 since_id = self.__unpack_id(since_id)
667
668 params = self.__generate_params(locals())
669 return self.__api_request('GET', "/api/v1/conversations/", params)
670
652 ### 671 ###
653 # Reading data: Statuses 672 # Reading data: Statuses
654 ### 673 ###
@@ -1782,22 +1801,30 @@ class Mastodon:
1782 ### 1801 ###
1783 # Writing data: Reports 1802 # Writing data: Reports
1784 ### 1803 ###
1785 @api_version("1.1.0", "1.1.0", __DICT_VERSION_REPORT) 1804 @api_version("1.1.0", "2.5.0", __DICT_VERSION_REPORT)
1786 def report(self, account_id, status_ids, comment): 1805 def report(self, account_id, status_ids = None, comment = None, forward = False):
1787 """ 1806 """
1788 Report statuses to the instances administrators. 1807 Report statuses to the instances administrators.
1789 1808
1790 Accepts a list of toot IDs associated with the report, and a comment. 1809 Accepts a list of toot IDs associated with the report, and a comment.
1810
1811 Set forward to True to forward a report of a remote user to that users
1812 instance as well as sending it to the instance local administrators.
1791 1813
1792 Returns a `report dict`_. 1814 Returns a `report dict`_.
1793 """ 1815 """
1794 account_id = self.__unpack_id(account_id) 1816 account_id = self.__unpack_id(account_id)
1795 1817
1796 if not isinstance(status_ids, list): 1818 if not status_ids is None:
1797 status_ids = [status_ids] 1819 if not isinstance(status_ids, list):
1820 status_ids = [status_ids]
1798 status_ids = list(map(lambda x: self.__unpack_id(x), status_ids)) 1821 status_ids = list(map(lambda x: self.__unpack_id(x), status_ids))
1799 1822
1800 params = self.__generate_params(locals()) 1823 params_initial = locals()
1824 if forward == False:
1825 del params_initial['forward']
1826
1827 params = self.__generate_params(params_initial)
1801 return self.__api_request('POST', '/api/v1/reports/', params) 1828 return self.__api_request('POST', '/api/v1/reports/', params)
1802 1829
1803 ### 1830 ###
diff --git a/mastodon/__init__.py b/mastodon/__init__.py
index 21de9ae..1b2103f 100644
--- a/mastodon/__init__.py
+++ b/mastodon/__init__.py
@@ -1,4 +1,5 @@
1from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError 1from mastodon.Mastodon import Mastodon, AttribAccessDict, MastodonError, MastodonVersionError, MastodonIllegalArgumentError, MastodonIOError, MastodonFileNotFoundError, MastodonNetworkError, MastodonAPIError, MastodonNotFoundError, MastodonUnauthorizedError, MastodonRatelimitError, MastodonMalformedEventError
2from mastodon.streaming import StreamListener, CallbackStreamListener 2from mastodon.streaming import StreamListener, CallbackStreamListener
3 3
4__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError'] 4__all__ = ['Mastodon', 'AttribAccessDict', 'StreamListener', 'CallbackStreamListener', 'MastodonError', 'MastodonVersionError', 'MastodonIllegalArgumentError', 'MastodonIOError', 'MastodonFileNotFoundError', 'MastodonNetworkError', 'MastodonAPIError', 'MastodonNotFoundError', 'MastodonUnauthorizedError', 'MastodonRatelimitError', 'MastodonMalformedEventError',
5'MastodonServerError']
Powered by cgit v1.2.3 (git 2.41.0)