Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for collecting spond posts #96

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
26 changes: 26 additions & 0 deletions spond/spond.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would someone actually use prevuid - can you give an example? If it's optional, it should be coded as such.

date : str
Copy link
Collaborator

@elliot-100 elliot-100 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be an optional datetime, like in get_events(), not a string.

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
Loading