mirror of
https://github.com/stoatchat/python-client-sdk.git
synced 2026-07-21 01:55:23 -04:00
fix error with optional data
This commit is contained in:
@@ -10,10 +10,8 @@ Relation = Literal["Blocked", "BlockedOther", "Friend", "Incoming", "None", "Out
|
||||
class UserBot(TypedDict):
|
||||
owner: str
|
||||
|
||||
class _OptionalStatus(TypedDict, total=False):
|
||||
class Status(TypedDict, total=False):
|
||||
text: str
|
||||
|
||||
class Status(_OptionalStatus):
|
||||
presence: Literal["Busy", "Idle", "Invisible", "Online"]
|
||||
|
||||
class UserRelation(TypedDict):
|
||||
|
||||
+6
-2
@@ -15,7 +15,7 @@ class Relation(NamedTuple):
|
||||
|
||||
class Status(NamedTuple):
|
||||
text: Optional[str]
|
||||
presence: PresenceType
|
||||
presence: Optional[PresenceType]
|
||||
|
||||
class User:
|
||||
"""Represents a user
|
||||
@@ -66,4 +66,8 @@ class User:
|
||||
self.relationship = RelationshipType(relationship) if relationship else None
|
||||
|
||||
status = data.get("status")
|
||||
self.status = Status(status.get("text"), PresenceType(status["presence"])) if status else None
|
||||
if status:
|
||||
presence = status.get("presence")
|
||||
self.status = Status(status.get("text"), PresenceType(presence) if presence else None) if status else None
|
||||
else:
|
||||
self.status = None
|
||||
|
||||
Reference in New Issue
Block a user