Пример #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
Пример #3
0
    def test_de_json(self, json_dict, bot):
        input_venue_message_content_json = InputVenueMessageContent.de_json(
            json_dict, bot)

        assert input_venue_message_content_json.longitude == self.longitude
        assert input_venue_message_content_json.latitude == self.latitude
        assert input_venue_message_content_json.title == self.title
        assert input_venue_message_content_json.address == self.address
        assert input_venue_message_content_json.foursquare_id == self.foursquare_id