Пример #1
0
    def de_json(data, bot):
        data = super(InputMessageContent, InputMessageContent).de_json(data, bot)

        if not data:
            return None

        try:
            from telegram import InputTextMessageContent
            return InputTextMessageContent.de_json(data, bot)
        except TypeError:
            pass

        try:
            from telegram import InputVenueMessageContent
            return InputVenueMessageContent.de_json(data, bot)
        except TypeError:
            pass

        try:
            from telegram import InputLocationMessageContent
            return InputLocationMessageContent.de_json(data, bot)
        except TypeError:
            pass

        try:
            from telegram import InputContactMessageContent
            return InputContactMessageContent.de_json(data, bot)
        except TypeError:
            pass

        return None
    def de_json(data):
        data = super(InputMessageContent, InputMessageContent).de_json(data)

        if not data:
            return None

        try:
            from telegram import InputTextMessageContent
            return InputTextMessageContent.de_json(data)
        except TypeError:
            pass

        try:
            from telegram import InputLocationMessageContent
            return InputLocationMessageContent.de_json(data)
        except TypeError:
            pass

        try:
            from telegram import InputVenueMessageContent
            return InputVenueMessageContent.de_json(data)
        except TypeError:
            pass

        try:
            from telegram import InputContactMessageContent
            return InputContactMessageContent.de_json(data)
        except TypeError:
            pass

        return None
    def test_de_json(self, json_dict, bot):
        input_contact_message_content_json = InputContactMessageContent.de_json(
            json_dict, bot)

        assert input_contact_message_content_json.first_name == self.first_name
        assert input_contact_message_content_json.phone_number == self.phone_number
        assert input_contact_message_content_json.last_name == self.last_name