From d8f7366d1f19e6dbf67507534ee844dae44dda73 Mon Sep 17 00:00:00 2001 From: Joe Lau Date: Wed, 28 Jun 2017 13:13:27 -0700 Subject: [PATCH] Add extensible_attachment field to Message for fb share objects --- fbchat/graphql.py | 3 ++- fbchat/models.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 680b07f..d8dd74b 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -75,7 +75,8 @@ def graphql_to_message(message): text=message.get('message').get('text'), mentions=[Mention(m.get('entity', {}).get('id'), offset=m.get('offset'), length=m.get('length')) for m in message.get('message').get('ranges', [])], sticker=message.get('sticker'), - attachments=message.get('blob_attachments') + attachments=message.get('blob_attachments'), + extensible_attachment=message.get('extensible_attachment') ) def graphql_to_user(user): diff --git a/fbchat/models.py b/fbchat/models.py index b1fbbf0..1697c28 100644 --- a/fbchat/models.py +++ b/fbchat/models.py @@ -125,8 +125,10 @@ class Message(object): sticker = str #: A list of attachments attachments = list + #: An extensible attachment, e.g. share object + extensible_attachment = dict - def __init__(self, uid, author=None, timestamp=None, is_read=None, reactions=[], text=None, mentions=[], sticker=None, attachments=[]): + def __init__(self, uid, author=None, timestamp=None, is_read=None, reactions=[], text=None, mentions=[], sticker=None, attachments=[], extensible_attachment={}): """Represents a Facebook message""" self.uid = uid self.author = author @@ -137,6 +139,7 @@ class Message(object): self.mentions = mentions self.sticker = sticker self.attachments = attachments + self.extensible_attachment = extensible_attachment class Mention(object):