Exemplo n.º 1
0
    def create_update(self, json_obj):
        update_id = self._get_simple_field(json_obj, 'update_id')
        message = self.get_message(json_obj)
        edited_message = self.get_edited_message(json_obj)
        channel_post = self.get_channel_post(json_obj)
        edited_channel_post = self.get_edited_channel_post(json_obj)
        inline_query = self.get_inline_query(json_obj)
        chosen_inline_result = self.get_chosen_inline_result(json_obj)
        callback_query = self.get_callback_query(json_obj)

        update = Update(
            update_id=update_id
        )

        if message:
            update.message = message

        if edited_message:
            update.edited_message = edited_message

        if channel_post:
            update.channel_post = channel_post

        if edited_channel_post:
            update.edited_channel_post = edited_channel_post

        if inline_query:
            update.inline_query = inline_query

        if chosen_inline_result:
            update.chosen_inline_result = chosen_inline_result

        if callback_query:
            update.callback_query = callback_query

        return update