Skip to content

Commit

Permalink
Merge pull request Neurotech-HQ#49 from taylorgibb/patch-1
Browse files Browse the repository at this point in the history
Add support for documents
  • Loading branch information
Kalebu authored Jan 4, 2023
2 parents 6b1071f + 3c124e2 commit 9350370
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions heyoo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,26 @@ def get_image(self, data) -> (Dict | None):
if "messages" in data:
if "image" in data["messages"][0]:
return data["messages"][0]["image"]

def get_document(self, data) -> (Dict | None):
""" "
Extracts the document of the sender from the data received from the webhook.
Args:
data[dict]: The data received from the webhook
Returns:
dict: The document_id of an image sent by the sender
Example:
>>> from whatsapp import WhatsApp
>>> whatsapp = WhatsApp(token, phone_number_id)
>>> document_id = whatsapp.get_document(data)
"""
data = self.preprocess(data)
if "messages" in data:
if "document" in data["messages"][0]:
return data["messages"][0]["document"]


def get_audio(self, data) -> (Dict | None):
"""
Expand Down

0 comments on commit 9350370

Please sign in to comment.