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

Get conversation participants #745

Draft
wants to merge 2 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
34 changes: 33 additions & 1 deletion farcaster/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, Iterator, Optional
from typing import Any, Dict, Iterator, List, Optional

import base64
import logging
Expand Down Expand Up @@ -323,6 +323,38 @@ def get_cast_recasters(
users=users, cursor=getattr(response_model.next, "cursor", None)
)

def get_conversation_participants(self, conversation_id: str) -> List[ApiUser]:
"""Get partcipants of a specific conversation

Args:
conversation_id (str): conversation id

Returns:
List[ApiUser]: Conversation content and metadata

Raises:
Exception: If the conversation with the given id is not found.
"""
conversation_search_limit: int = 100
response = self._get(
"direct-cast-conversation-list",
params={
"limit": conversation_search_limit,
"category": "default",
"filter": "group",
},
)

# Filter to get the conversation that matches hash
for conversation in response["result"]["conversations"]:
if conversation["conversationId"] == conversation_id:
return [
ApiUser(**participant)
for participant in conversation["participants"]
]

raise Exception(f"Unable to find conversation with id : {hash}")

def get_cast(
self,
hash: str,
Expand Down
Loading