Make LiveLocationAttachment.expires_at a datetime object

Renamed from .expiration_time
This commit is contained in:
Mads Marquart
2019-09-08 13:03:46 +02:00
parent 61842b199f
commit 2e53963398

View File

@@ -59,14 +59,14 @@ class LiveLocationAttachment(LocationAttachment):
#: Name of the location
name = attr.ib(None)
#: Timestamp when live location expires
expiration_time = attr.ib(None)
#: Datetime when live location expires
expires_at = attr.ib(None)
#: True if live location is expired
is_expired = attr.ib(None)
def __init__(self, name=None, expiration_time=None, is_expired=None, **kwargs):
def __init__(self, name=None, expires_at=None, is_expired=None, **kwargs):
super(LiveLocationAttachment, self).__init__(**kwargs)
self.expiration_time = expiration_time
self.expires_at = expires_at
self.is_expired = is_expired
@classmethod
@@ -80,7 +80,7 @@ class LiveLocationAttachment(LocationAttachment):
if not data.get("stopReason")
else None,
name=data.get("locationTitle"),
expiration_time=data["expirationTime"],
expires_at=_util.millis_to_datetime(data["expirationTime"]),
is_expired=bool(data.get("stopReason")),
)
@@ -96,7 +96,7 @@ class LiveLocationAttachment(LocationAttachment):
if target.get("coordinate")
else None,
name=data["title_with_entities"]["text"],
expiration_time=target.get("expiration_time"),
expires_at=_util.millis_to_datetime(target.get("expiration_time")),
is_expired=target.get("is_expired"),
)
media = data.get("media")