AudioAttachment

This commit is contained in:
Steve Nian
2018-01-30 17:33:29 +08:00
parent 90203afdd0
commit a94fa5fbe3
2 changed files with 20 additions and 4 deletions

View File

@@ -109,6 +109,12 @@ def graphql_to_attachment(a):
large_image=a.get('large_image'), large_image=a.get('large_image'),
uid=a.get('legacy_attachment_id') 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': elif _type == 'MessageFile':
return FileAttachment( return FileAttachment(
url=a.get('url'), url=a.get('url'),

View File

@@ -267,10 +267,20 @@ class FileAttachment(Attachment):
self.name = name self.name = name
self.is_malicious = is_malicious self.is_malicious = is_malicious
class AudioAttachment(FileAttachment): class AudioAttachment(Attachment):
def __init__(self, **kwargs): # Name of the file
"""Represents an audio file that has been sent as a Facebook attachment - *Currently Incomplete!*""" filename = None
super(StickerAttachment, self).__init__(**kwargs) # 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): class ImageAttachment(Attachment):
#: The extension of the original image (eg. 'png') #: The extension of the original image (eg. 'png')