def from_array(array): """ Deserializes a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert (isinstance(array, dict)) from ..receivable.peer import User from ..receivable.media import Location data = {} data['result_id'] = str(array.get('result_id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = str(array.get('query')) data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None data['inline_message_id'] = str( array.get('inline_message_id')) if array.get( 'inline_message_id') is not None else None return ChosenInlineResult(**data)
def from_array(array): """ Deserialize a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = {} data['result_id'] = u(array.get('result_id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = u(array.get('query')) data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None data['inline_message_id'] = u( array.get('inline_message_id')) if array.get( 'inline_message_id') is not None else None data['_raw'] = array return ChosenInlineResult(**data)
def from_array(array): """ Deserializes a new Location from a given dictionary. :return: new Location instance. :rtype: Location """ if array is None or not array: return None # end if assert(isinstance(array, dict)) data = {} data['longitude'] = float(array.get('longitude')) data['latitude'] = float(array.get('latitude')) return Location(**data)
def validate_array(array): """ Builds a new array with valid values for the InlineQuery constructor. :return: new array with valid values :rtype: dict """ assert_type_or_raise(array, dict, parameter_name="array") from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = Result.validate_array(array) data['id'] = u(array.get('id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = u(array.get('query')) data['offset'] = u(array.get('offset')) data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None
def from_array(array): """ Deserializes a new Venue from a given dictionary. :return: new Venue instance. :rtype: Venue """ if array is None or not array: return None # end if assert(isinstance(array, dict)) from pytgbot.api_types.receivable.media import Location data = {} data['location'] = Location.from_array(array.get('location')) data['title'] = str(array.get('title')) data['address'] = str(array.get('address')) data['foursquare_id'] = str(array.get('foursquare_id')) if array.get('foursquare_id') is not None else None return Venue(**data)
def validate_array(array): """ Builds a new array with valid values for the ChosenInlineResult constructor. :return: new array with valid values :rtype: dict """ assert_type_or_raise(array, dict, parameter_name="array") from ..receivable.media import Location from ..receivable.peer import User data = UpdateType.validate_array(array) data['result_id'] = u(array.get('result_id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = u(array.get('query')) data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None data['inline_message_id'] = u( array.get('inline_message_id')) if array.get( 'inline_message_id') is not None else None return data
def from_array(array): """ Deserializes a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery """ if array is None or not array: return None # end if assert(isinstance(array, dict)) from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = {} data['id'] = str(array.get('id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = str(array.get('query')) data['offset'] = str(array.get('offset')) data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None return InlineQuery(**data)
def from_array(array): """ Deserializes a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert(isinstance(array, dict)) from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = {} data['result_id'] = str(array.get('result_id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = str(array.get('query')) data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None data['inline_message_id'] = str(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None return ChosenInlineResult(**data)
def from_array(array): """ Deserializes a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery """ if array is None or not array: return None # end if assert isinstance(array, dict) from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = {} data["id"] = str(array.get("id")) data["from_peer"] = User.from_array(array.get("from")) data["query"] = str(array.get("query")) data["offset"] = str(array.get("offset")) data["location"] = Location.from_array(array.get("location")) if array.get("location") is not None else None return InlineQuery(**data)
def from_array(array): """ Deserializes a new InlineQuery from a given dictionary. :return: new InlineQuery instance. :rtype: InlineQuery """ if array is None or not array: return None # end if assert (isinstance(array, dict)) from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.peer import User data = {} data['id'] = str(array.get('id')) data['from_peer'] = User.from_array(array.get('from')) data['query'] = str(array.get('query')) data['offset'] = str(array.get('offset')) data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None return InlineQuery(**data)
def from_array(array): """ Deserializes a new ChosenInlineResult from a given dictionary. :return: new ChosenInlineResult instance. :rtype: ChosenInlineResult """ if array is None or not array: return None # end if assert isinstance(array, dict) from ..receivable.peer import User from ..receivable.media import Location data = {} data["result_id"] = str(array.get("result_id")) data["from_peer"] = User.from_array(array.get("from")) data["query"] = str(array.get("query")) data["location"] = Location.from_array(array.get("location")) if array.get("location") is not None else None data["inline_message_id"] = ( str(array.get("inline_message_id")) if array.get("inline_message_id") is not None else None ) return ChosenInlineResult(**data)
def from_array(array): """ Deserializes a new Message from a given dictionary. :return: new Message instance. :rtype: Message """ if array is None or not array: return None # end if assert (isinstance(array, dict)) from pytgbot.api_types.receivable.media import Audio from pytgbot.api_types.receivable.media import Contact from pytgbot.api_types.receivable.media import Document from pytgbot.api_types.receivable.media import Game from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.media import MessageEntity from pytgbot.api_types.receivable.media import PhotoSize from pytgbot.api_types.receivable.media import Sticker from pytgbot.api_types.receivable.media import Venue from pytgbot.api_types.receivable.media import Video from pytgbot.api_types.receivable.media import Voice from pytgbot.api_types.receivable.peer import Chat from pytgbot.api_types.receivable.peer import User from pytgbot.api_types.receivable.updates import Message data = {} data['message_id'] = int(array.get('message_id')) data['date'] = int(array.get('date')) data['chat'] = Chat.from_array(array.get('chat')) data['from_peer'] = User.from_array( array.get('from')) if array.get('from') is not None else None data['forward_from'] = User.from_array(array.get( 'forward_from')) if array.get('forward_from') is not None else None data['forward_from_chat'] = Chat.from_array( array.get('forward_from_chat')) if array.get( 'forward_from_chat') is not None else None data['forward_from_message_id'] = int( array.get('forward_from_message_id')) if array.get( 'forward_from_message_id') is not None else None data['forward_date'] = int(array.get('forward_date')) if array.get( 'forward_date') is not None else None data['reply_to_message'] = Message.from_array( array.get('reply_to_message')) if array.get( 'reply_to_message') is not None else None data['edit_date'] = int(array.get('edit_date')) if array.get( 'edit_date') is not None else None data['text'] = str( array.get('text')) if array.get('text') is not None else None data['entities'] = MessageEntity.from_array_list( array.get('entities'), list_level=1) if array.get('entities') is not None else None data['audio'] = Audio.from_array( array.get('audio')) if array.get('audio') is not None else None data['document'] = Document.from_array(array.get( 'document')) if array.get('document') is not None else None data['game'] = Game.from_array( array.get('game')) if array.get('game') is not None else None data['photo'] = PhotoSize.from_array_list( array.get('photo'), list_level=1) if array.get('photo') is not None else None data['sticker'] = Sticker.from_array( array.get('sticker')) if array.get('sticker') is not None else None data['video'] = Video.from_array( array.get('video')) if array.get('video') is not None else None data['voice'] = Voice.from_array( array.get('voice')) if array.get('voice') is not None else None data['caption'] = str( array.get('caption')) if array.get('caption') is not None else None data['contact'] = Contact.from_array( array.get('contact')) if array.get('contact') is not None else None data['location'] = Location.from_array(array.get( 'location')) if array.get('location') is not None else None data['venue'] = Venue.from_array( array.get('venue')) if array.get('venue') is not None else None data['new_chat_member'] = User.from_array( array.get('new_chat_member')) if array.get( 'new_chat_member') is not None else None data['left_chat_member'] = User.from_array( array.get('left_chat_member')) if array.get( 'left_chat_member') is not None else None data['new_chat_title'] = str(array.get('new_chat_title')) if array.get( 'new_chat_title') is not None else None data['new_chat_photo'] = PhotoSize.from_array_list( array.get('new_chat_photo'), list_level=1) if array.get('new_chat_photo') is not None else None data['delete_chat_photo'] = bool( array.get('delete_chat_photo')) if array.get( 'delete_chat_photo') is not None else None data['group_chat_created'] = bool( array.get('group_chat_created')) if array.get( 'group_chat_created') is not None else None data['supergroup_chat_created'] = bool( array.get('supergroup_chat_created')) if array.get( 'supergroup_chat_created') is not None else None data['channel_chat_created'] = bool( array.get('channel_chat_created')) if array.get( 'channel_chat_created') is not None else None data['migrate_to_chat_id'] = int( array.get('migrate_to_chat_id')) if array.get( 'migrate_to_chat_id') is not None else None data['migrate_from_chat_id'] = int( array.get('migrate_from_chat_id')) if array.get( 'migrate_from_chat_id') is not None else None data['pinned_message'] = Message.from_array( array.get('pinned_message')) if array.get( 'pinned_message') is not None else None return Message(**data)
def from_array(array): """ Deserializes a new Message from a given dictionary. :return: new Message instance. :rtype: Message """ if array is None or not array: return None # end if assert(isinstance(array, dict)) from pytgbot.api_types.receivable.media import Audio from pytgbot.api_types.receivable.media import Contact from pytgbot.api_types.receivable.media import Document from pytgbot.api_types.receivable.media import Game from pytgbot.api_types.receivable.media import Location from pytgbot.api_types.receivable.media import MessageEntity from pytgbot.api_types.receivable.media import PhotoSize from pytgbot.api_types.receivable.media import Sticker from pytgbot.api_types.receivable.media import Venue from pytgbot.api_types.receivable.media import Video from pytgbot.api_types.receivable.media import Voice from pytgbot.api_types.receivable.peer import Chat from pytgbot.api_types.receivable.peer import User from pytgbot.api_types.receivable.updates import Message data = {} data['message_id'] = int(array.get('message_id')) data['date'] = int(array.get('date')) data['chat'] = Chat.from_array(array.get('chat')) data['from_peer'] = User.from_array(array.get('from')) if array.get('from') is not None else None data['forward_from'] = User.from_array(array.get('forward_from')) if array.get('forward_from') is not None else None data['forward_from_chat'] = Chat.from_array(array.get('forward_from_chat')) if array.get('forward_from_chat') is not None else None data['forward_from_message_id'] = int(array.get('forward_from_message_id')) if array.get('forward_from_message_id') is not None else None data['forward_date'] = int(array.get('forward_date')) if array.get('forward_date') is not None else None data['reply_to_message'] = Message.from_array(array.get('reply_to_message')) if array.get('reply_to_message') is not None else None data['edit_date'] = int(array.get('edit_date')) if array.get('edit_date') is not None else None data['text'] = str(array.get('text')) if array.get('text') is not None else None data['entities'] = MessageEntity.from_array_list(array.get('entities'), list_level=1) if array.get('entities') is not None else None data['audio'] = Audio.from_array(array.get('audio')) if array.get('audio') is not None else None data['document'] = Document.from_array(array.get('document')) if array.get('document') is not None else None data['game'] = Game.from_array(array.get('game')) if array.get('game') is not None else None data['photo'] = PhotoSize.from_array_list(array.get('photo'), list_level=1) if array.get('photo') is not None else None data['sticker'] = Sticker.from_array(array.get('sticker')) if array.get('sticker') is not None else None data['video'] = Video.from_array(array.get('video')) if array.get('video') is not None else None data['voice'] = Voice.from_array(array.get('voice')) if array.get('voice') is not None else None data['caption'] = str(array.get('caption')) if array.get('caption') is not None else None data['contact'] = Contact.from_array(array.get('contact')) if array.get('contact') is not None else None data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None data['venue'] = Venue.from_array(array.get('venue')) if array.get('venue') is not None else None data['new_chat_member'] = User.from_array(array.get('new_chat_member')) if array.get('new_chat_member') is not None else None data['left_chat_member'] = User.from_array(array.get('left_chat_member')) if array.get('left_chat_member') is not None else None data['new_chat_title'] = str(array.get('new_chat_title')) if array.get('new_chat_title') is not None else None data['new_chat_photo'] = PhotoSize.from_array_list(array.get('new_chat_photo'), list_level=1) if array.get('new_chat_photo') is not None else None data['delete_chat_photo'] = bool(array.get('delete_chat_photo')) if array.get('delete_chat_photo') is not None else None data['group_chat_created'] = bool(array.get('group_chat_created')) if array.get('group_chat_created') is not None else None data['supergroup_chat_created'] = bool(array.get('supergroup_chat_created')) if array.get('supergroup_chat_created') is not None else None data['channel_chat_created'] = bool(array.get('channel_chat_created')) if array.get('channel_chat_created') is not None else None data['migrate_to_chat_id'] = int(array.get('migrate_to_chat_id')) if array.get('migrate_to_chat_id') is not None else None data['migrate_from_chat_id'] = int(array.get('migrate_from_chat_id')) if array.get('migrate_from_chat_id') is not None else None data['pinned_message'] = Message.from_array(array.get('pinned_message')) if array.get('pinned_message') is not None else None return Message(**data)