Fix ThreadABC.fetch_messages ordering, and clean up a few docstrings
This commit is contained in:
@@ -206,7 +206,7 @@ class Client:
|
|||||||
) -> Iterable[Tuple[_threads.ThreadABC, int]]:
|
) -> Iterable[Tuple[_threads.ThreadABC, int]]:
|
||||||
"""Search for messages in all threads.
|
"""Search for messages in all threads.
|
||||||
|
|
||||||
Intended to be used alongside `ThreadABC.search_messages`
|
Intended to be used alongside `ThreadABC.search_messages`.
|
||||||
|
|
||||||
Warning! If someone send a message to a thread that matches the query, while
|
Warning! If someone send a message to a thread that matches the query, while
|
||||||
we're searching, some snippets will get returned twice, and some will be lost.
|
we're searching, some snippets will get returned twice, and some will be lost.
|
||||||
@@ -215,8 +215,7 @@ class Client:
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
query: Text to search for
|
query: Text to search for
|
||||||
limit: Max. number of threads to retrieve. If ``None``, all threads will be
|
limit: Max. number of items to retrieve. If ``None``, all will be retrieved
|
||||||
retrieved
|
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
Search for messages, and print the amount of snippets in each thread.
|
Search for messages, and print the amount of snippets in each thread.
|
||||||
@@ -372,6 +371,8 @@ class Client:
|
|||||||
) -> Iterable[_threads.ThreadABC]:
|
) -> Iterable[_threads.ThreadABC]:
|
||||||
"""Fetch the client's thread list.
|
"""Fetch the client's thread list.
|
||||||
|
|
||||||
|
The returned threads are ordered by last active first.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
limit: Max. number of threads to retrieve. If ``None``, all threads will be
|
limit: Max. number of threads to retrieve. If ``None``, all threads will be
|
||||||
retrieved.
|
retrieved.
|
||||||
|
@@ -316,7 +316,7 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
This is fundamentally unfixable, it's just how the endpoint is implemented.
|
This is fundamentally unfixable, it's just how the endpoint is implemented.
|
||||||
|
|
||||||
The returned message snippets are ordered by last sent.
|
The returned message snippets are ordered by last sent first.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
query: Text to search for
|
query: Text to search for
|
||||||
@@ -368,7 +368,7 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
|||||||
def fetch_messages(self, limit: Optional[int]) -> Iterable["_models.Message"]:
|
def fetch_messages(self, limit: Optional[int]) -> Iterable["_models.Message"]:
|
||||||
"""Fetch messages in a thread.
|
"""Fetch messages in a thread.
|
||||||
|
|
||||||
The returned messages are ordered by most recent first.
|
The returned messages are ordered by last sent first.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
limit: Max. number of threads to retrieve. If ``None``, all threads will be
|
limit: Max. number of threads to retrieve. If ``None``, all threads will be
|
||||||
@@ -390,9 +390,10 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
|||||||
before = None
|
before = None
|
||||||
for limit in _util.get_limits(limit, MAX_BATCH_LIMIT):
|
for limit in _util.get_limits(limit, MAX_BATCH_LIMIT):
|
||||||
messages = self._fetch_messages(limit, before)
|
messages = self._fetch_messages(limit, before)
|
||||||
|
messages.reverse()
|
||||||
|
|
||||||
if before:
|
if before:
|
||||||
# Strip the first thread
|
# Strip the first messages
|
||||||
yield from messages[1:]
|
yield from messages[1:]
|
||||||
else:
|
else:
|
||||||
yield from messages
|
yield from messages
|
||||||
@@ -413,8 +414,6 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
|||||||
|
|
||||||
result = j[self.id]["message_shared_media"]
|
result = j[self.id]["message_shared_media"]
|
||||||
|
|
||||||
print(len(result["edges"]))
|
|
||||||
|
|
||||||
rtn = []
|
rtn = []
|
||||||
for edge in result["edges"]:
|
for edge in result["edges"]:
|
||||||
node = edge["node"]
|
node = edge["node"]
|
||||||
@@ -433,6 +432,8 @@ class ThreadABC(metaclass=abc.ABCMeta):
|
|||||||
def fetch_images(self, limit: Optional[int]) -> Iterable["_models.Attachment"]:
|
def fetch_images(self, limit: Optional[int]) -> Iterable["_models.Attachment"]:
|
||||||
"""Fetch images/videos posted in the thread.
|
"""Fetch images/videos posted in the thread.
|
||||||
|
|
||||||
|
The returned images are ordered by last sent first.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
limit: Max. number of images to retrieve. If ``None``, all images will be
|
limit: Max. number of images to retrieve. If ``None``, all images will be
|
||||||
retrieved.
|
retrieved.
|
||||||
|
Reference in New Issue
Block a user