diff --git a/fbchat/graphql.py b/fbchat/graphql.py index 8bc69bd..1f8acd4 100644 --- a/fbchat/graphql.py +++ b/fbchat/graphql.py @@ -109,6 +109,12 @@ def graphql_to_attachment(a): large_image=a.get('large_image'), uid=a.get('legacy_attachment_id') ) + elif _type == 'MessageAudio': + return AudioAttachment( + filename=a.get('filename'), + playable_url=a.get('playable_url'), + duration=a.get('playable_duration_in_ms') + ) elif _type == 'MessageFile': return FileAttachment( url=a.get('url'), diff --git a/fbchat/models.py b/fbchat/models.py index 9ca32b0..eedb0d9 100644 --- a/fbchat/models.py +++ b/fbchat/models.py @@ -267,10 +267,20 @@ class FileAttachment(Attachment): self.name = name self.is_malicious = is_malicious -class AudioAttachment(FileAttachment): - def __init__(self, **kwargs): - """Represents an audio file that has been sent as a Facebook attachment - *Currently Incomplete!*""" - super(StickerAttachment, self).__init__(**kwargs) +class AudioAttachment(Attachment): + # Name of the file + filename = None + # playable_url + playable_url = None + # duration + duration = None + + def __init__(self, filename=None, playable_url=None, duration=None, **kwargs): + """Represents an audio file that has been sent as a Facebook attachment""" + super(AudioAttachment, self).__init__(**kwargs) + self.filename = filename + self.playable_url = playable_url + self.duration = duration class ImageAttachment(Attachment): #: The extension of the original image (eg. 'png')