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). diff --git a/spond/spond.py b/spond/spond.py index b95f3a9..dfb8c51 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 + Last date 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