diff --git a/fbchat/_client.py b/fbchat/_client.py index 2c246b1..df406e7 100644 --- a/fbchat/_client.py +++ b/fbchat/_client.py @@ -3010,7 +3010,7 @@ class Client(object): for l in i["messageLiveLocations"]: mid = l["messageId"] author_id = str(l["senderId"]) - location = graphql_to_live_location(l) + location = LiveLocationAttachment._from_pull(l) self.onLiveLocation( mid=mid, location=location, diff --git a/fbchat/_graphql.py b/fbchat/_graphql.py index 3e9e656..ceffba0 100644 --- a/fbchat/_graphql.py +++ b/fbchat/_graphql.py @@ -202,21 +202,6 @@ def graphql_to_subattachment(a): ) -def graphql_to_live_location(a): - return LiveLocationAttachment( - uid=a["id"], - latitude=a["coordinate"]["latitude"] / (10 ** 8) - if not a.get("stopReason") - else None, - longitude=a["coordinate"]["longitude"] / (10 ** 8) - if not a.get("stopReason") - else None, - name=a.get("locationTitle"), - expiration_time=a["expirationTime"], - is_expired=bool(a.get("stopReason")), - ) - - def graphql_to_plan(a): if a.get("event_members"): rtn = Plan( diff --git a/fbchat/_location.py b/fbchat/_location.py index 5361bb5..af9b56d 100644 --- a/fbchat/_location.py +++ b/fbchat/_location.py @@ -46,3 +46,18 @@ class LiveLocationAttachment(LocationAttachment): super(LiveLocationAttachment, self).__init__(**kwargs) self.expiration_time = expiration_time self.is_expired = is_expired + + @classmethod + def _from_pull(cls, data): + return cls( + uid=data["id"], + latitude=data["coordinate"]["latitude"] / (10 ** 8) + if not data.get("stopReason") + else None, + longitude=data["coordinate"]["longitude"] / (10 ** 8) + if not data.get("stopReason") + else None, + name=data.get("locationTitle"), + expiration_time=data["expirationTime"], + is_expired=bool(data.get("stopReason")), + ) diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 0d99a87..173a215 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -12,7 +12,6 @@ from ._graphql import ( graphql_to_attachment, graphql_to_extensible_attachment, graphql_to_subattachment, - graphql_to_live_location, graphql_to_plan, graphql_to_quick_reply, graphql_to_message,