From d6ad31250740aeac06568fcfeb497e978c1323a1 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 13 Nov 2023 11:21:23 +0100 Subject: [PATCH 1/3] Added api for collecting Posts --- spond/spond.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/spond/spond.py b/spond/spond.py index b95f3a9..7ab8dd3 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -381,3 +381,29 @@ async def update_event(self, uid, updates: dict): ) as r: self.events_update = await r.json() return self.events + +async def get_post(self, uid, prevuid, date) -> dict: + """ + Get a group by unique ID. + Subject to authenticated user's access. + + Parameters + ---------- + uid : str + UID of the group. + prevuid : str + Different UID used on the webpage, optional to use when calling this function. + date : str + Date from when to read posts from + + Returns + ------- + Details about all last 1K posts in the group. | max=1000 + """ + if not self.token: + await self.login() + url = f"{self.api_url}posts?type=PLAIN&includeComments=true&includeReadStatus=true&includeSeenCount=true&max=1000&groupId={uid}&prevId={prevuid}&maxTimestamp={date}T00:00:00.211Z" + async with self.clientsession.get(url, headers=self.auth_headers) as r: + self.groups = await r.json() + return self.groups + raise IndexError From dcc082920e26f232a0ce817821ef04a864586ad8 Mon Sep 17 00:00:00 2001 From: VasquezTech <126467710+VasquezTech@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:24:36 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 00191ea..4ea31d9 100644 --- a/README.md +++ b/README.md @@ -57,6 +57,10 @@ Get all your messages. Send a message with content `text`. Either specify an existing `chat_id`, or both `user` and `group_uid` for a new chat. +### get_posts() + +Get details of the last 1K posts. + ## Example scripts The following scripts are included as examples. Some of the scripts might require additional packages to be installed (csv, ical etc). From 42cae13e6cdf793c73f05619467e3ba785b5957c Mon Sep 17 00:00:00 2001 From: VasquezTech <126467710+VasquezTech@users.noreply.github.com> Date: Mon, 13 Nov 2023 11:34:48 +0100 Subject: [PATCH 3/3] Update spond.py Fixed wrong explanation for the use of `{date }` --- spond/spond.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spond/spond.py b/spond/spond.py index 7ab8dd3..dfb8c51 100644 --- a/spond/spond.py +++ b/spond/spond.py @@ -394,7 +394,7 @@ async def get_post(self, uid, prevuid, date) -> dict: prevuid : str Different UID used on the webpage, optional to use when calling this function. date : str - Date from when to read posts from + Last date to read posts from. Returns -------