Untitled
unknown
plain_text
8 months ago
533 B
5
Indexable
def extract_message_details(message):
"""Extracts key details from incoming messages."""
sender_id = message["from"]
message_type = message.get("type", "unknown")
timestamp = message.get("timestamp")
if message_type == "text":
return "text", sender_id, message["text"]["body"], None, timestamp
elif message_type in ["image", "video", "audio", "document"]:
return message_type, sender_id, None, message[message_type]["id"], timestamp
return "unknown", sender_id, None, None, timestampEditor is loading...
Leave a Comment