Make .author and .created_at on MessageData required
This commit is contained in:
@@ -174,16 +174,16 @@ class MessageData(Message):
|
|||||||
Inherits `Message`.
|
Inherits `Message`.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
#: ID of the sender
|
||||||
|
author = attr.ib()
|
||||||
|
#: Datetime of when the message was sent
|
||||||
|
created_at = attr.ib()
|
||||||
#: The actual message
|
#: The actual message
|
||||||
text = attr.ib(None)
|
text = attr.ib(None)
|
||||||
#: A list of `Mention` objects
|
#: A list of `Mention` objects
|
||||||
mentions = attr.ib(factory=list)
|
mentions = attr.ib(factory=list)
|
||||||
#: A `EmojiSize`. Size of a sent emoji
|
#: A `EmojiSize`. Size of a sent emoji
|
||||||
emoji_size = attr.ib(None)
|
emoji_size = attr.ib(None)
|
||||||
#: ID of the sender
|
|
||||||
author = attr.ib(None)
|
|
||||||
#: Datetime of when the message was sent
|
|
||||||
created_at = attr.ib(None)
|
|
||||||
#: Whether the message is read
|
#: Whether the message is read
|
||||||
is_read = attr.ib(None)
|
is_read = attr.ib(None)
|
||||||
#: A list of people IDs who read the message, works only with `Client.fetch_thread_messages`
|
#: A list of people IDs who read the message, works only with `Client.fetch_thread_messages`
|
||||||
@@ -250,13 +250,13 @@ class MessageData(Message):
|
|||||||
return cls(
|
return cls(
|
||||||
thread=thread,
|
thread=thread,
|
||||||
id=str(data["message_id"]),
|
id=str(data["message_id"]),
|
||||||
|
author=str(data["message_sender"]["id"]),
|
||||||
|
created_at=created_at,
|
||||||
text=data["message"].get("text"),
|
text=data["message"].get("text"),
|
||||||
mentions=[
|
mentions=[
|
||||||
Mention._from_range(m) for m in data["message"].get("ranges") or ()
|
Mention._from_range(m) for m in data["message"].get("ranges") or ()
|
||||||
],
|
],
|
||||||
emoji_size=EmojiSize._from_tags(tags),
|
emoji_size=EmojiSize._from_tags(tags),
|
||||||
author=str(data["message_sender"]["id"]),
|
|
||||||
created_at=created_at,
|
|
||||||
is_read=not data["unread"] if data.get("unread") is not None else None,
|
is_read=not data["unread"] if data.get("unread") is not None else None,
|
||||||
read_by=[
|
read_by=[
|
||||||
receipt["actor"]["id"]
|
receipt["actor"]["id"]
|
||||||
@@ -306,14 +306,14 @@ class MessageData(Message):
|
|||||||
return cls(
|
return cls(
|
||||||
thread=thread,
|
thread=thread,
|
||||||
id=metadata.get("messageId"),
|
id=metadata.get("messageId"),
|
||||||
|
author=str(metadata["actorFbId"]),
|
||||||
|
created_at=_util.millis_to_datetime(metadata["timestamp"]),
|
||||||
text=data.get("body"),
|
text=data.get("body"),
|
||||||
mentions=[
|
mentions=[
|
||||||
Mention._from_prng(m)
|
Mention._from_prng(m)
|
||||||
for m in _util.parse_json(data.get("data", {}).get("prng", "[]"))
|
for m in _util.parse_json(data.get("data", {}).get("prng", "[]"))
|
||||||
],
|
],
|
||||||
emoji_size=EmojiSize._from_tags(tags),
|
emoji_size=EmojiSize._from_tags(tags),
|
||||||
author=str(metadata.get("actorFbId")),
|
|
||||||
created_at=_util.millis_to_datetime(metadata.get("timestamp")),
|
|
||||||
sticker=sticker,
|
sticker=sticker,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
quick_replies=cls._parse_quick_replies(data.get("platform_xmd_encoded")),
|
quick_replies=cls._parse_quick_replies(data.get("platform_xmd_encoded")),
|
||||||
@@ -373,11 +373,11 @@ class MessageData(Message):
|
|||||||
return cls(
|
return cls(
|
||||||
thread=thread,
|
thread=thread,
|
||||||
id=mid,
|
id=mid,
|
||||||
|
author=author,
|
||||||
|
created_at=created_at,
|
||||||
text=data.get("body"),
|
text=data.get("body"),
|
||||||
mentions=mentions,
|
mentions=mentions,
|
||||||
emoji_size=EmojiSize._from_tags(tags),
|
emoji_size=EmojiSize._from_tags(tags),
|
||||||
author=author,
|
|
||||||
created_at=created_at,
|
|
||||||
sticker=sticker,
|
sticker=sticker,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
unsent=unsent,
|
unsent=unsent,
|
||||||
|
Reference in New Issue
Block a user