Skip to content

Commit

Permalink
Merge pull request #158 from progeroffline/getting-group-name
Browse files Browse the repository at this point in the history
Change getting group name method
  • Loading branch information
d60 authored Jul 25, 2024
2 parents 1d76bba + c879aa7 commit 1e43554
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions twikit/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,15 @@ def __init__(self, client: Client, group_id: str, data: dict) -> None:
self._client = client
self.id = group_id

entries = data['conversation_timeline']['entries']
name_update_log = next(
filter(lambda x: 'conversation_name_update' in x, entries),
None
)
conversation_timeline = data["conversation_timeline"]
self.name: str | None = (
name_update_log['conversation_name_update']['conversation_name']
if name_update_log else None
conversation_timeline["conversations"][group_id]["name"]
if len(conversation_timeline["conversations"].keys()) > 0
else None
)

members = data['conversation_timeline']['users'].values()
self.members: list[User] = [
User(client, build_user_data(i)) for i in members
]
members = conversation_timeline["users"].values()
self.members: list[User] = [User(client, build_user_data(i)) for i in members]

async def get_history(
self, max_id: str | None = None
Expand Down Expand Up @@ -261,4 +256,4 @@ async def remove_reaction(self, emoji: str) -> Response:
)

def __repr__(self) -> str:
return f'<GroupMessage id="{self.id}">'
return f'<GroupMessage id="{self.id}">'

0 comments on commit 1e43554

Please sign in to comment.