See :meth:`telegram.TelegramObject.de_json`.
(cls, data: JSONDict, bot: "Bot | None" = None)
| 1612 | |
| 1613 | @classmethod |
| 1614 | def de_json(cls, data: JSONDict, bot: "Bot | None" = None) -> "Message": |
| 1615 | """See :meth:`telegram.TelegramObject.de_json`.""" |
| 1616 | data = cls._parse_data(data) |
| 1617 | |
| 1618 | # Get the local timezone from the bot if it has defaults |
| 1619 | loc_tzinfo = extract_tzinfo_from_defaults(bot) |
| 1620 | |
| 1621 | data["from_user"] = de_json_optional(data.pop("from", None), User, bot) |
| 1622 | data["sender_chat"] = de_json_optional(data.get("sender_chat"), Chat, bot) |
| 1623 | data["entities"] = de_list_optional(data.get("entities"), MessageEntity, bot) |
| 1624 | data["caption_entities"] = de_list_optional( |
| 1625 | data.get("caption_entities"), MessageEntity, bot |
| 1626 | ) |
| 1627 | data["reply_to_message"] = de_json_optional(data.get("reply_to_message"), Message, bot) |
| 1628 | data["edit_date"] = from_timestamp(data.get("edit_date"), tzinfo=loc_tzinfo) |
| 1629 | data["audio"] = de_json_optional(data.get("audio"), Audio, bot) |
| 1630 | data["document"] = de_json_optional(data.get("document"), Document, bot) |
| 1631 | data["animation"] = de_json_optional(data.get("animation"), Animation, bot) |
| 1632 | data["game"] = de_json_optional(data.get("game"), Game, bot) |
| 1633 | data["photo"] = de_list_optional(data.get("photo"), PhotoSize, bot) |
| 1634 | data["sticker"] = de_json_optional(data.get("sticker"), Sticker, bot) |
| 1635 | data["story"] = de_json_optional(data.get("story"), Story, bot) |
| 1636 | data["video"] = de_json_optional(data.get("video"), Video, bot) |
| 1637 | data["voice"] = de_json_optional(data.get("voice"), Voice, bot) |
| 1638 | data["video_note"] = de_json_optional(data.get("video_note"), VideoNote, bot) |
| 1639 | data["contact"] = de_json_optional(data.get("contact"), Contact, bot) |
| 1640 | data["location"] = de_json_optional(data.get("location"), Location, bot) |
| 1641 | data["venue"] = de_json_optional(data.get("venue"), Venue, bot) |
| 1642 | data["new_chat_members"] = de_list_optional(data.get("new_chat_members"), User, bot) |
| 1643 | data["left_chat_member"] = de_json_optional(data.get("left_chat_member"), User, bot) |
| 1644 | data["new_chat_photo"] = de_list_optional(data.get("new_chat_photo"), PhotoSize, bot) |
| 1645 | data["message_auto_delete_timer_changed"] = de_json_optional( |
| 1646 | data.get("message_auto_delete_timer_changed"), MessageAutoDeleteTimerChanged, bot |
| 1647 | ) |
| 1648 | data["pinned_message"] = de_json_optional( |
| 1649 | data.get("pinned_message"), MaybeInaccessibleMessage, bot |
| 1650 | ) |
| 1651 | data["invoice"] = de_json_optional(data.get("invoice"), Invoice, bot) |
| 1652 | data["successful_payment"] = de_json_optional( |
| 1653 | data.get("successful_payment"), SuccessfulPayment, bot |
| 1654 | ) |
| 1655 | data["passport_data"] = de_json_optional(data.get("passport_data"), PassportData, bot) |
| 1656 | data["poll"] = de_json_optional(data.get("poll"), Poll, bot) |
| 1657 | data["dice"] = de_json_optional(data.get("dice"), Dice, bot) |
| 1658 | data["via_bot"] = de_json_optional(data.get("via_bot"), User, bot) |
| 1659 | data["proximity_alert_triggered"] = de_json_optional( |
| 1660 | data.get("proximity_alert_triggered"), ProximityAlertTriggered, bot |
| 1661 | ) |
| 1662 | data["reply_markup"] = de_json_optional( |
| 1663 | data.get("reply_markup"), InlineKeyboardMarkup, bot |
| 1664 | ) |
| 1665 | data["video_chat_scheduled"] = de_json_optional( |
| 1666 | data.get("video_chat_scheduled"), VideoChatScheduled, bot |
| 1667 | ) |
| 1668 | data["video_chat_started"] = de_json_optional( |
| 1669 | data.get("video_chat_started"), VideoChatStarted, bot |
| 1670 | ) |
| 1671 | data["video_chat_ended"] = de_json_optional( |
no test coverage detected