Instruction:
Can you create a Python 3 function that
uses this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned. Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. https://core.telegram.org/bots/api#answercallbackquery Parameters: :param callback_query_id: Unique identifier for the query to be answered :type callback_query_id: str|unicode Optional keyword parameters: :param text: Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters :type text: str|unicode :param show_alert: If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false. :type show_alert: bool :param url: URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button.Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter. :type url: str|unicode :param cache_time: The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0. :type cache_time: int Returns: :return: On success, True is returned :rtype: bool

Response:
def answer_callback_query(self, callback_query_id, text=None, show_alert=None, url=None, cache_time=None):
        """
        Use this method to send answers to callback queries sent from inline keyboards. The answer will be displayed to the user as a notification at the top of the chat screen or as an alert. On success, True is returned.

        Alternatively, the user can be redirected to the specified Game URL. For this option to work, you must first create a game for your bot via @Botfather and accept the terms. Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.

        https://core.telegram.org/bots/api#answercallbackquery

        Parameters:

        :param callback_query_id: Unique identifier for the query to be answered
        :type  callback_query_id: str|unicode

        Optional keyword parameters:

        :param text: Text of the notification. If not specified, nothing will be shown to the user, 0-200 characters
        :type  text: str|unicode

        :param show_alert: If true, an alert will be shown by the client instead of a notification at the top of the chat screen. Defaults to false.
        :type  show_alert: bool

        :param url: URL that will be opened by the user's client. If you have created a Game and accepted the conditions via @Botfather, specify the URL that opens your game – note that this will only work if the query comes from a callback_game button.Otherwise, you may use links like t.me/your_bot?start=XXXX that open your bot with a parameter.
        :type  url: str|unicode

        :param cache_time: The maximum amount of time in seconds that the result of the callback query may be cached client-side. Telegram apps will support caching starting in version 3.14. Defaults to 0.
        :type  cache_time: int

        Returns:

        :return: On success, True is returned
        :rtype:  bool
        """
        assert_type_or_raise(callback_query_id, unicode_type, parameter_name="callback_query_id")

        assert_type_or_raise(text, None, unicode_type, parameter_name="text")

        assert_type_or_raise(show_alert, None, bool, parameter_name="show_alert")

        assert_type_or_raise(url, None, unicode_type, parameter_name="url")

        assert_type_or_raise(cache_time, None, int, parameter_name="cache_time")

        result = self.do("answerCallbackQuery", callback_query_id=callback_query_id, text=text, show_alert=show_alert, url=url, cache_time=cache_time)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
Can you generate a brief explanation for the following Python 3 code
def edit_message_text(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None, disable_web_page_preview=None, reply_markup=None):
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup

        assert_type_or_raise(text, unicode_type, parameter_name="text")

        assert_type_or_raise(chat_id, None, (int, unicode_type), parameter_name="chat_id")

        assert_type_or_raise(message_id, None, int, parameter_name="message_id")

        assert_type_or_raise(inline_message_id, None, unicode_type, parameter_name="inline_message_id")

        assert_type_or_raise(parse_mode, None, unicode_type, parameter_name="parse_mode")

        assert_type_or_raise(disable_web_page_preview, None, bool, parameter_name="disable_web_page_preview")

        assert_type_or_raise(reply_markup, None, InlineKeyboardMarkup, parameter_name="reply_markup")

        result = self.do("editMessageText", text=text, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id, parse_mode=parse_mode, disable_web_page_preview=disable_web_page_preview, reply_markup=reply_markup)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.updates import Message
            try:
                return Message.from_array(result)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type Message", exc_info=True)
            # end try

            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: Use this method to edit text and game messages sent by the bot or via the bot.


Instruction:
Write a Python 3 function that can
use this method to get a sticker set. On success, a StickerSet object is returned. https://core.telegram.org/bots/api#getstickerset Parameters: :param name: Name of the sticker set :type name: str|unicode Returns: :return: On success, a StickerSet object is returned :rtype: pytgbot.api_types.receivable.stickers.StickerSet

Response:
def get_sticker_set(self, name):
        """
        Use this method to get a sticker set. On success, a StickerSet object is returned.

        https://core.telegram.org/bots/api#getstickerset

        Parameters:

        :param name: Name of the sticker set
        :type  name: str|unicode

        Returns:

        :return: On success, a StickerSet object is returned
        :rtype:  pytgbot.api_types.receivable.stickers.StickerSet
        """
        assert_type_or_raise(name, unicode_type, parameter_name="name")

        result = self.do("getStickerSet", name=name)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.stickers import StickerSet
            try:
                return StickerSet.from_array(result)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type StickerSet", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
How would you explain what the following Python 3 function does
def upload_sticker_file(self, user_id, png_sticker):
        from pytgbot.api_types.sendable.files import InputFile

        assert_type_or_raise(user_id, int, parameter_name="user_id")

        assert_type_or_raise(png_sticker, InputFile, parameter_name="png_sticker")

        result = self.do("uploadStickerFile", user_id=user_id, png_sticker=png_sticker)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.media import File
            try:
                return File.from_array(result)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type File", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: This method uploads a. png file with a sticker to the Telegram server.


Instruction:
Here you have a function in Python 3, explain what it does
def create_new_sticker_set(self, user_id, name, title, png_sticker, emojis, contains_masks=None, mask_position=None):
        from pytgbot.api_types.receivable.stickers import MaskPosition
        from pytgbot.api_types.sendable.files import InputFile

        assert_type_or_raise(user_id, int, parameter_name="user_id")

        assert_type_or_raise(name, unicode_type, parameter_name="name")

        assert_type_or_raise(title, unicode_type, parameter_name="title")

        assert_type_or_raise(png_sticker, (InputFile, unicode_type), parameter_name="png_sticker")

        assert_type_or_raise(emojis, unicode_type, parameter_name="emojis")

        assert_type_or_raise(contains_masks, None, bool, parameter_name="contains_masks")

        assert_type_or_raise(mask_position, None, MaskPosition, parameter_name="mask_position")

        result = self.do("createNewStickerSet", user_id=user_id, name=name, title=title, png_sticker=png_sticker, emojis=emojis, contains_masks=contains_masks, mask_position=mask_position)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: This method creates a new sticker set owned by a user.


Instruction:
Implement a Python 3 function for
using this method to move a sticker in a set created by the bot to a specific position . Returns True on success. https://core.telegram.org/bots/api#setstickerpositioninset Parameters: :param sticker: File identifier of the sticker :type sticker: str|unicode :param position: New sticker position in the set, zero-based :type position: int Returns: :return: Returns True on success :rtype: bool

Response:
def set_sticker_position_in_set(self, sticker, position):
        """
        Use this method to move a sticker in a set created by the bot to a specific position . Returns True on success.

        https://core.telegram.org/bots/api#setstickerpositioninset

        Parameters:

        :param sticker: File identifier of the sticker
        :type  sticker: str|unicode

        :param position: New sticker position in the set, zero-based
        :type  position: int

        Returns:

        :return: Returns True on success
        :rtype:  bool
        """
        assert_type_or_raise(sticker, unicode_type, parameter_name="sticker")

        assert_type_or_raise(position, int, parameter_name="position")

        result = self.do("setStickerPositionInSet", sticker=sticker, position=position)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
Can you generate a brief explanation for the following Python 3 code
def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None, switch_pm_text=None, switch_pm_parameter=None):
        from pytgbot.api_types.sendable.inline import InlineQueryResult

        assert_type_or_raise(inline_query_id, unicode_type, parameter_name="inline_query_id")

        assert_type_or_raise(results, list, parameter_name="results")

        assert_type_or_raise(cache_time, None, int, parameter_name="cache_time")

        assert_type_or_raise(is_personal, None, bool, parameter_name="is_personal")

        assert_type_or_raise(next_offset, None, unicode_type, parameter_name="next_offset")

        assert_type_or_raise(switch_pm_text, None, unicode_type, parameter_name="switch_pm_text")

        assert_type_or_raise(switch_pm_parameter, None, unicode_type, parameter_name="switch_pm_parameter")

        result = self.do("answerInlineQuery", inline_query_id=inline_query_id, results=results, cache_time=cache_time, is_personal=is_personal, next_offset=next_offset, switch_pm_text=switch_pm_text, switch_pm_parameter=switch_pm_parameter)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: This method sends answers to an inline query.


Instruction:
Can you implement a function in Python 3 that
uses this method to send invoices. On success, the sent Message is returned. https://core.telegram.org/bots/api#sendinvoice Parameters: :param chat_id: Unique identifier for the target private chat :type chat_id: int :param title: Product name, 1-32 characters :type title: str|unicode :param description: Product description, 1-255 characters :type description: str|unicode :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes. :type payload: str|unicode :param provider_token: Payments provider token, obtained via Botfather :type provider_token: str|unicode :param start_parameter: Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter :type start_parameter: str|unicode :param currency: Three-letter ISO 4217 currency code, see more on currencies :type currency: str|unicode :param prices: Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.) :type prices: list of pytgbot.api_types.sendable.payments.LabeledPrice Optional keyword parameters: :param provider_data: JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider. :type provider_data: str|unicode :param photo_url: URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for. :type photo_url: str|unicode :param photo_size: Photo size :type photo_size: int :param photo_width: Photo width :type photo_width: int :param photo_height: Photo height :type photo_height: int :param need_name: Pass True, if you require the user's full name to complete the order :type need_name: bool :param need_phone_number: Pass True, if you require the user's phone number to complete the order :type need_phone_number: bool :param need_email: Pass True, if you require the user's email address to complete the order :type need_email: bool :param need_shipping_address: Pass True, if you require the user's shipping address to complete the order :type need_shipping_address: bool :param send_phone_number_to_provider: Pass True, if user's phone number should be sent to provider :type send_phone_number_to_provider: bool :param send_email_to_provider: Pass True, if user's email address should be sent to provider :type send_email_to_provider: bool :param is_flexible: Pass True, if the final price depends on the shipping method :type is_flexible: bool :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :type disable_notification: bool :param reply_to_message_id: If the message is a reply, ID of the original message :type reply_to_message_id: int :param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button. :type reply_markup: pytgbot.api_types.sendable.reply_markup.InlineKeyboardMarkup Returns: :return: On success, the sent Message is returned :rtype: pytgbot.api_types.receivable.updates.Message

Response:
def send_invoice(self, chat_id, title, description, payload, provider_token, start_parameter, currency, prices, provider_data=None, photo_url=None, photo_size=None, photo_width=None, photo_height=None, need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None, send_phone_number_to_provider=None, send_email_to_provider=None, is_flexible=None, disable_notification=None, reply_to_message_id=None, reply_markup=None):
        """
        Use this method to send invoices. On success, the sent Message is returned.

        https://core.telegram.org/bots/api#sendinvoice

        Parameters:

        :param chat_id: Unique identifier for the target private chat
        :type  chat_id: int

        :param title: Product name, 1-32 characters
        :type  title: str|unicode

        :param description: Product description, 1-255 characters
        :type  description: str|unicode

        :param payload: Bot-defined invoice payload, 1-128 bytes. This will not be displayed to the user, use for your internal processes.
        :type  payload: str|unicode

        :param provider_token: Payments provider token, obtained via Botfather
        :type  provider_token: str|unicode

        :param start_parameter: Unique deep-linking parameter that can be used to generate this invoice when used as a start parameter
        :type  start_parameter: str|unicode

        :param currency: Three-letter ISO 4217 currency code, see more on currencies
        :type  currency: str|unicode

        :param prices: Price breakdown, a list of components (e.g. product price, tax, discount, delivery cost, delivery tax, bonus, etc.)
        :type  prices: list of pytgbot.api_types.sendable.payments.LabeledPrice

        Optional keyword parameters:

        :param provider_data: JSON-encoded data about the invoice, which will be shared with the payment provider. A detailed description of required fields should be provided by the payment provider.
        :type  provider_data: str|unicode

        :param photo_url: URL of the product photo for the invoice. Can be a photo of the goods or a marketing image for a service. People like it better when they see what they are paying for.
        :type  photo_url: str|unicode

        :param photo_size: Photo size
        :type  photo_size: int

        :param photo_width: Photo width
        :type  photo_width: int

        :param photo_height: Photo height
        :type  photo_height: int

        :param need_name: Pass True, if you require the user's full name to complete the order
        :type  need_name: bool

        :param need_phone_number: Pass True, if you require the user's phone number to complete the order
        :type  need_phone_number: bool

        :param need_email: Pass True, if you require the user's email address to complete the order
        :type  need_email: bool

        :param need_shipping_address: Pass True, if you require the user's shipping address to complete the order
        :type  need_shipping_address: bool

        :param send_phone_number_to_provider: Pass True, if user's phone number should be sent to provider
        :type  send_phone_number_to_provider: bool

        :param send_email_to_provider: Pass True, if user's email address should be sent to provider
        :type  send_email_to_provider: bool

        :param is_flexible: Pass True, if the final price depends on the shipping method
        :type  is_flexible: bool

        :param disable_notification: Sends the message silently. Users will receive a notification with no sound.
        :type  disable_notification: bool

        :param reply_to_message_id: If the message is a reply, ID of the original message
        :type  reply_to_message_id: int

        :param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button.
        :type  reply_markup: pytgbot.api_types.sendable.reply_markup.InlineKeyboardMarkup

        Returns:

        :return: On success, the sent Message is returned
        :rtype:  pytgbot.api_types.receivable.updates.Message
        """
        from pytgbot.api_types.sendable.payments import LabeledPrice
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup

        assert_type_or_raise(chat_id, int, parameter_name="chat_id")

        assert_type_or_raise(title, unicode_type, parameter_name="title")

        assert_type_or_raise(description, unicode_type, parameter_name="description")

        assert_type_or_raise(payload, unicode_type, parameter_name="payload")

        assert_type_or_raise(provider_token, unicode_type, parameter_name="provider_token")

        assert_type_or_raise(start_parameter, unicode_type, parameter_name="start_parameter")

        assert_type_or_raise(currency, unicode_type, parameter_name="currency")

        assert_type_or_raise(prices, list, parameter_name="prices")

        assert_type_or_raise(provider_data, None, unicode_type, parameter_name="provider_data")

        assert_type_or_raise(photo_url, None, unicode_type, parameter_name="photo_url")

        assert_type_or_raise(photo_size, None, int, parameter_name="photo_size")

        assert_type_or_raise(photo_width, None, int, parameter_name="photo_width")

        assert_type_or_raise(photo_height, None, int, parameter_name="photo_height")

        assert_type_or_raise(need_name, None, bool, parameter_name="need_name")

        assert_type_or_raise(need_phone_number, None, bool, parameter_name="need_phone_number")

        assert_type_or_raise(need_email, None, bool, parameter_name="need_email")

        assert_type_or_raise(need_shipping_address, None, bool, parameter_name="need_shipping_address")

        assert_type_or_raise(send_phone_number_to_provider, None, bool, parameter_name="send_phone_number_to_provider")

        assert_type_or_raise(send_email_to_provider, None, bool, parameter_name="send_email_to_provider")

        assert_type_or_raise(is_flexible, None, bool, parameter_name="is_flexible")

        assert_type_or_raise(disable_notification, None, bool, parameter_name="disable_notification")

        assert_type_or_raise(reply_to_message_id, None, int, parameter_name="reply_to_message_id")

        assert_type_or_raise(reply_markup, None, InlineKeyboardMarkup, parameter_name="reply_markup")

        result = self.do("sendInvoice", chat_id=chat_id, title=title, description=description, payload=payload, provider_token=provider_token, start_parameter=start_parameter, currency=currency, prices=prices, provider_data=provider_data, photo_url=photo_url, photo_size=photo_size, photo_width=photo_width, photo_height=photo_height, need_name=need_name, need_phone_number=need_phone_number, need_email=need_email, need_shipping_address=need_shipping_address, send_phone_number_to_provider=send_phone_number_to_provider, send_email_to_provider=send_email_to_provider, is_flexible=is_flexible, disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, reply_markup=reply_markup)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.updates import Message
            try:
                return Message.from_array(result)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type Message", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
Implement a function in Python 3 to
send an Answer to a shipping query.

Response:
def answer_shipping_query(self, shipping_query_id, ok, shipping_options=None, error_message=None):
        """
        If you sent an invoice requesting a shipping address and the parameter is_flexible was specified, the Bot API will send an Update with a shipping_query field to the bot. Use this method to reply to shipping queries. On success, True is returned.

        https://core.telegram.org/bots/api#answershippingquery

        Parameters:

        :param shipping_query_id: Unique identifier for the query to be answered
        :type  shipping_query_id: str|unicode

        :param ok: Specify True if delivery to the specified address is possible and False if there are any problems (for example, if delivery to the specified address is not possible)
        :type  ok: bool

        Optional keyword parameters:

        :param shipping_options: Required if ok is True. A JSON-serialized array of available shipping options.
        :type  shipping_options: list of pytgbot.api_types.sendable.payments.ShippingOption

        :param error_message: Required if ok is False. Error message in human readable form that explains why it is impossible to complete the order (e.g. "Sorry, delivery to your desired address is unavailable'). Telegram will display this message to the user.
        :type  error_message: str|unicode

        Returns:

        :return: On success, True is returned
        :rtype:  bool
        """
        from pytgbot.api_types.sendable.payments import ShippingOption

        assert_type_or_raise(shipping_query_id, unicode_type, parameter_name="shipping_query_id")

        assert_type_or_raise(ok, bool, parameter_name="ok")

        assert_type_or_raise(shipping_options, None, list, parameter_name="shipping_options")

        assert_type_or_raise(error_message, None, unicode_type, parameter_name="error_message")

        result = self.do("answerShippingQuery", shipping_query_id=shipping_query_id, ok=ok, shipping_options=shipping_options, error_message=error_message)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
Can you generate the documentation for the following Python 3 function
def answer_pre_checkout_query(self, pre_checkout_query_id, ok, error_message=None):
        assert_type_or_raise(pre_checkout_query_id, unicode_type, parameter_name="pre_checkout_query_id")

        assert_type_or_raise(ok, bool, parameter_name="ok")

        assert_type_or_raise(error_message, None, unicode_type, parameter_name="error_message")

        result = self.do("answerPreCheckoutQuery", pre_checkout_query_id=pre_checkout_query_id, ok=ok, error_message=error_message)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: This method sends an answer to a pre - checkout query.


Instruction:
How would you implement a function in Python 3 that
informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success. Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues. https://core.telegram.org/bots/api#setpassportdataerrors Parameters: :param user_id: User identifier :type user_id: int :param errors: A JSON-serialized array describing the errors :type errors: list of pytgbot.api_types.sendable.passport.PassportElementError Returns: :return: Returns True on success :rtype: bool

Response:
def set_passport_data_errors(self, user_id, errors):
        """
        Informs a user that some of the Telegram Passport elements they provided contains errors. The user will not be able to re-submit their Passport to you until the errors are fixed (the contents of the field for which you returned the error must change). Returns True on success.
        Use this if the data submitted by the user doesn't satisfy the standards your service requires for any reason. For example, if a birthday date seems invalid, a submitted document is blurry, a scan shows evidence of tampering, etc. Supply some details in the error message to make sure the user knows how to correct the issues.

        https://core.telegram.org/bots/api#setpassportdataerrors

        Parameters:

        :param user_id: User identifier
        :type  user_id: int

        :param errors: A JSON-serialized array describing the errors
        :type  errors: list of pytgbot.api_types.sendable.passport.PassportElementError

        Returns:

        :return: Returns True on success
        :rtype:  bool
        """
        from pytgbot.api_types.sendable.passport import PassportElementError

        assert_type_or_raise(user_id, int, parameter_name="user_id")

        assert_type_or_raise(errors, list, parameter_name="errors")

        result = self.do("setPassportDataErrors", user_id=user_id, errors=errors)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            try:
                return from_array_list(bool, result, list_level=0, is_builtin=True)
            except TgApiParseException:
                logger.debug("Failed parsing as primitive bool", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result


Instruction:
Here you have a function in Python 3, explain what it does
def send_game(self, chat_id, game_short_name, disable_notification=None, reply_to_message_id=None, reply_markup=None):
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup

        assert_type_or_raise(chat_id, int, parameter_name="chat_id")

        assert_type_or_raise(game_short_name, unicode_type, parameter_name="game_short_name")

        assert_type_or_raise(disable_notification, None, bool, parameter_name="disable_notification")

        assert_type_or_raise(reply_to_message_id, None, int, parameter_name="reply_to_message_id")

        assert_type_or_raise(reply_markup, None, InlineKeyboardMarkup, parameter_name="reply_markup")

        result = self.do("sendGame", chat_id=chat_id, game_short_name=game_short_name, disable_notification=disable_notification, reply_to_message_id=reply_to_message_id, reply_markup=reply_markup)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.updates import Message
            try:
                return Message.from_array(result)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type Message", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: Use this method to send a game.


Instruction:
Can you tell what is the following Python 3 function doing
def get_game_high_scores(self, user_id, chat_id=None, message_id=None, inline_message_id=None):
        assert_type_or_raise(user_id, int, parameter_name="user_id")

        assert_type_or_raise(chat_id, None, int, parameter_name="chat_id")

        assert_type_or_raise(message_id, None, int, parameter_name="message_id")

        assert_type_or_raise(inline_message_id, None, unicode_type, parameter_name="inline_message_id")

        result = self.do("getGameHighScores", user_id=user_id, chat_id=chat_id, message_id=message_id, inline_message_id=inline_message_id)
        if self.return_python_objects:
            logger.debug("Trying to parse {data}".format(data=repr(result)))
            from pytgbot.api_types.receivable.game import GameHighScore
            try:
                return GameHighScore.from_array_list(result, list_level=1)
            except TgApiParseException:
                logger.debug("Failed parsing as api_type GameHighScore", exc_info=True)
            # end try
            # no valid parsing so far
            raise TgApiParseException("Could not parse result.")  # See debug log for details!
        # end if return_python_objects
        return result

Response: Method to get the high scores for a user in a chat.


Instruction:
Make a summary of the following Python 3 code
def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query):
        import requests

        url, params = self._prepare_request(command, query)
        r = requests.post(url, params=params, files=files, stream=use_long_polling,
                          verify=True,  # No self signed certificates. Telegram should be trustworthy anyway...
                          timeout=request_timeout)
        return self._postprocess_request(r)

Response: Send a request to the api.


Instruction:
Implement a Python 3 function for
creating a url to download the file.

Response:
def get_download_url(self, file):
        """
        Creates a url to download the file.

        Note: Contains the secret API key, so you should not share this url!

        :param file: The File you want to get the url to download.
        :type  file: pytgbot.api_types.receivable.media.File

        :return: url
        :rtype: str
        """
        from .api_types.receivable.media import File
        assert isinstance(file, File)
        return file.get_download_url(self.api_key)


Instruction:
Make a summary of the following Python 3 code
def _load_info(self):
        myself = self.get_me()
        if self.return_python_objects:
            self._id = myself.id
            self._username = myself.username
        else:
            self._id = myself["result"]["id"]
            self._username = myself["result"]["username"]

Response: This function loads the id and username of the bot.


Instruction:
Can you generate the documentation for the following Python 3 function
def get_request_data(self, var_name, full_data=False):
        if full_data:
            data = self.to_array()
            data['media'], file = self.get_inputfile_data(self.media, var_name, suffix='_media')
            return data, file
        # end if
        return self.get_inputfile_data(self.media, var_name, suffix='_media')

Response: Get the data for a given variable.


Instruction:
Here you have a function in Python 3, explain what it does
def get_request_data(self, var_name, full_data=False):
        if not full_data:
            raise ArithmeticError('we have a thumbnail, please use `full_data=True`.')
        # end if
        file = {}
        data, file_to_add = super(InputMediaWithThumb, self).get_request_data(var_name, full_data=True)
        if file_to_add:
            file.update(file_to_add)
        # end if
        data['thumb'], file_to_add = self.get_inputfile_data(self.thumb, var_name, suffix='_thumb')
        if data['thumb'] is None:
            del data['thumb']  # having `'thumb': null` in the json produces errors.
        # end if
        if file_to_add:
            file.update(file_to_add)
        # end if
        return data, (file or None)

Response: Get the data for a given variable name.


Instruction:
Explain what the following Python 3 code does
def to_array(self):
        from .files import InputFile
        array = super(InputMediaVideo, self).to_array()
        # 'type' given by superclass
        # 'media' given by superclass
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = None  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if
        # 'caption' given by superclass
        # 'parse_mode' given by superclass
        if self.width is not None:
            array['width'] = int(self.width)  # type int
        if self.height is not None:
            array['height'] = int(self.height)  # type int
        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.supports_streaming is not None:
            array['supports_streaming'] = bool(self.supports_streaming)  # type bool
        return array

Response: Serializes this InputMediaVideo to a dictionary.


Instruction:
How would you implement a function in Python 3 that
serializes this InputMediaAnimation to a dictionary.

Response:
def to_array(self):
        """
        Serializes this InputMediaAnimation to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(InputMediaAnimation, self).to_array()
        # 'type' given by superclass
        # 'media' given by superclass
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = None  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if
        # 'caption' given by superclass
        # 'parse_mode' given by superclass
        if self.width is not None:
            array['width'] = int(self.width)  # type int
        if self.height is not None:
            array['height'] = int(self.height)  # type int
        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        return array


Instruction:
Can you write a function in Python 3 where it
serializes this InputMediaAudio to a dictionary.

Response:
def to_array(self):
        """
        Serializes this InputMediaAudio to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(InputMediaAudio, self).to_array()
        # 'type' given by superclass
        # 'media' given by superclass
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = None  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if
        # 'caption' given by superclass
        # 'parse_mode' given by superclass
        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.performer is not None:
            array['performer'] = u(self.performer)  # py2: type unicode, py3: type str
        if self.title is not None:
            array['title'] = u(self.title)  # py2: type unicode, py3: type str
        return array


Instruction:
How would you explain what the following Python 3 function does
def to_array(self):
        array = super(InputMediaDocument, self).to_array()
        # 'type' given by superclass
        # 'media' given by superclass
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = None  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if
        # 'caption' given by superclass
        # 'parse_mode' given by superclass
        return array

Response: Serializes this InputMediaDocument to a dictionary.


Instruction:
Make a summary of the following Python 3 code
def from_array(array):
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.files import InputFile

        data = {}
        # 'type' is given by class type
        data['media'] = u(array.get('media'))
        if array.get('thumb') is None:
            data['thumb'] = None
        elif isinstance(array.get('thumb'), InputFile):
            data['thumb'] = None  # will be filled later by get_request_data()
        elif isinstance(array.get('thumb'), str):
            data['thumb'] = u(array.get('thumb'))
        else:
            raise TypeError('Unknown type, must be one of InputFile, str or None.')
        # end if
        data['caption'] = u(array.get('caption')) if array.get('caption') is not None else None
        data['parse_mode'] = u(array.get('parse_mode')) if array.get('parse_mode') is not None else None

        instance = InputMediaDocument(**data)
        instance._raw = array
        return instance

Response: Deserialize a new InputMediaDocument from a given dictionary.


Instruction:
Can you implement a function in Python 3 that
merges two lists of lists.

Response:
def _mergemap(map1, map2):
    """
    Positions in map2 have an integer indicating the relative shift to
    the equivalent position in map1. E.g., the i'th position in map2
    corresponds to the i + map2[i] position in map1.
    """
    merged = array('i', [0] * len(map2))
    for i, shift in enumerate(map2):
        merged[i] = shift + map1[i + shift]
    return merged


Instruction:
Can you generate a brief explanation for the following Python 3 code
def from_config(cls, path, directory=None):
        if not exists(path):
            raise REPPError('REPP config file not found: {}'.format(path))
        confdir = dirname(path)

        # TODO: can TDL parsing be repurposed for this variant?
        conf = io.open(path, encoding='utf-8').read()
        conf = re.sub(r';.*', '', conf).replace('\n',' ')
        m = re.search(
            r'repp-modules\s*:=\s*((?:[-\w]+\s+)*[-\w]+)\s*\.', conf)
        t = re.search(
            r'repp-tokenizer\s*:=\s*([-\w]+)\s*\.', conf)
        a = re.search(
            r'repp-calls\s*:=\s*((?:[-\w]+\s+)*[-\w]+)\s*\.', conf)
        f = re.search(
            r'format\s*:=\s*(\w+)\s*\.', conf)
        d = re.search(
            r'repp-directory\s*:=\s*(.*)\.\s*$', conf)

        if m is None:
            raise REPPError('repp-modules option must be set')
        if t is None:
            raise REPPError('repp-tokenizer option must be set')

        mods = m.group(1).split()
        tok = t.group(1).strip()
        active = a.group(1).split() if a is not None else None
        fmt = f.group(1).strip() if f is not None else None

        if directory is None:
            if d is not None:
                directory = d.group(1).strip(' "')
            elif exists(joinpath(confdir, tok + '.rpp')):
                directory = confdir
            elif exists(joinpath(confdir, 'rpp', tok + '.rpp')):
                directory = joinpath(confdir, 'rpp')
            elif exists(joinpath(confdir, '../rpp', tok + '.rpp')):
                directory = joinpath(confdir, '../rpp')
            else:
                raise REPPError('Could not find a suitable REPP directory.')

        # ignore repp-modules and format?
        return REPP.from_file(
            joinpath(directory, tok + '.rpp'),
            directory=directory,
            active=active
        )

Response: Instantiate a REPP from a PET - style. set configuration file.


Instruction:
Explain what the following Python 3 code does
def from_file(cls, path, directory=None, modules=None, active=None):
        name = basename(path)
        if name.endswith('.rpp'):
            name = name[:-4]
        lines = _repp_lines(path)
        directory = dirname(path) if directory is None else directory
        r = cls(name=name, modules=modules, active=active)
        _parse_repp(lines, r, directory)
        return r

Response: Instantiate a REPP from a. rpp file.


Instruction:
How would you explain what the following Python 3 function does
def from_string(cls, s, name=None, modules=None, active=None):
        r = cls(name=name, modules=modules, active=active)
        _parse_repp(s.splitlines(), r, None)
        return r

Response: Instantiate a REPP from a string.


Instruction:
How would you implement a function in Python 3 that
deactivates an external module.

Response:
def deactivate(self, mod):
        """
        Set external module *mod* to inactive.
        """
        if mod in self.active:
            self.active.remove(mod)


Instruction:
Can you tell what is the following Python 3 function doing
def apply(self, s, active=None):
        if active is None:
            active = self.active
        return self.group.apply(s, active=active)

Response: Applies the REPP s rewrite rules to the input string s*.


Instruction:
Make a summary of the following Python 3 code
def trace(self, s, active=None, verbose=False):
        if active is None:
            active = self.active
        return self.group.trace(s, active=active, verbose=verbose)

Response: Trace the input string s and return a list of REPPStep objects for each intermediate rewrite rule.


Instruction:
Can you create a Python 3 function that
rewrites and tokenize the input string s.

Response:
def tokenize(self, s, pattern=None, active=None):
        """
        Rewrite and tokenize the input string *s*.

        Args:
            s (str): the input string to process
            pattern (str, optional): the regular expression pattern on
                which to split tokens; defaults to `[ \t]+`
            active (optional): a collection of external module names
                that may be applied if called
        Returns:
            a :class:`~delphin.tokens.YyTokenLattice` containing the
            tokens and their characterization information
        """
        if pattern is None:
            if self.tokenize_pattern is None:
                pattern = r'[ \t]+'
            else:
                pattern = self.tokenize_pattern
        if active is None:
            active = self.active
        return self.group.tokenize(s, pattern=pattern, active=active)


Instruction:
Can you tell what is the following Python 3 function doing
def _apply_update_receiver(self, receiver, reply_id):
        if self.receiver is None:
            self.receiver = receiver
        # end if
        if self.reply_id is DEFAULT_MESSAGE_ID:
            self.reply_id = reply_id

Response: Applies receiver and reply_id to self. receiver and self. reply_id.


Instruction:
Write a Python 3 script for
sending the message via pytgbot.

Response:
def send(self, sender: PytgbotApiBot):
        """
        Send the message via pytgbot.

        :param sender: The bot instance to send with.
        :type  sender: pytgbot.bot.Bot

        :rtype: PytgbotApiMessage
        """
        return sender.send_message(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            text=self.text, chat_id=self.receiver, reply_to_message_id=self.reply_id, parse_mode=self.parse_mode, disable_web_page_preview=self.disable_web_page_preview, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )


Instruction:
Make a summary of the following Python 3 code
def to_array(self):
        array = super(TextMessage, self).to_array()
        array['text'] = u(self.text)  # py2: type unicode, py3: type str

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        if self.disable_web_page_preview is not None:
            array['disable_web_page_preview'] = bool(self.disable_web_page_preview)  # type bool
        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this TextMessage to a dictionary.


Instruction:
Can you generate a brief explanation for the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_photo(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            photo=self.photo, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Given the following Python 3 function, write the documentation
def send(self, sender: PytgbotApiBot):
        return sender.send_audio(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            audio=self.audio, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, duration=self.duration, performer=self.performer, title=self.title, thumb=self.thumb, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Write a Python 3 script to
serialize this AudioMessage to a dictionary.

Response:
def to_array(self):
        """
        Serializes this AudioMessage to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(AudioMessage, self).to_array()
        if isinstance(self.audio, InputFile):
            array['audio'] = self.audio.to_array()  # type InputFile
        elif isinstance(self.audio, str):
            array['audio'] = u(self.audio)  # py2: type unicode, py3: type str
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.performer is not None:
            array['performer'] = u(self.performer)  # py2: type unicode, py3: type str

        if self.title is not None:
            array['title'] = u(self.title)  # py2: type unicode, py3: type str

        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = self.thumb.to_array()  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array


Instruction:
Here you have a function in Python 3, explain what it does
def send(self, sender: PytgbotApiBot):
        return sender.send_document(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            document=self.document, chat_id=self.receiver, reply_to_message_id=self.reply_id, thumb=self.thumb, caption=self.caption, parse_mode=self.parse_mode, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Here you have a function in Python 3, explain what it does
def send(self, sender: PytgbotApiBot):
        return sender.send_video(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            video=self.video, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, width=self.width, height=self.height, thumb=self.thumb, caption=self.caption, parse_mode=self.parse_mode, supports_streaming=self.supports_streaming, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via the bot.


Instruction:
How would you implement a function in Python 3 that
sends the message via pytgbot.

Response:
def send(self, sender: PytgbotApiBot):
        """
        Send the message via pytgbot.

        :param sender: The bot instance to send with.
        :type  sender: pytgbot.bot.Bot

        :rtype: PytgbotApiMessage
        """
        return sender.send_animation(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            animation=self.animation, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, width=self.width, height=self.height, thumb=self.thumb, caption=self.caption, parse_mode=self.parse_mode, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )


Instruction:
How would you explain what the following Python 3 function does
def to_array(self):
        array = super(AnimationMessage, self).to_array()
        if isinstance(self.animation, InputFile):
            array['animation'] = self.animation.to_array()  # type InputFile
        elif isinstance(self.animation, str):
            array['animation'] = u(self.animation)  # py2: type unicode, py3: type str
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.width is not None:
            array['width'] = int(self.width)  # type int
        if self.height is not None:
            array['height'] = int(self.height)  # type int
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = self.thumb.to_array()  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if

        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this AnimationMessage to a dictionary.


Instruction:
Make a summary of the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_voice(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            voice=self.voice, chat_id=self.receiver, reply_to_message_id=self.reply_id, caption=self.caption, parse_mode=self.parse_mode, duration=self.duration, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Implement a Python 3 function for
serializing this VoiceMessage to a dictionary.

Response:
def to_array(self):
        """
        Serializes this VoiceMessage to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(VoiceMessage, self).to_array()
        if isinstance(self.voice, InputFile):
            array['voice'] = self.voice.to_array()  # type InputFile
        elif isinstance(self.voice, str):
            array['voice'] = u(self.voice)  # py2: type unicode, py3: type str
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.caption is not None:
            array['caption'] = u(self.caption)  # py2: type unicode, py3: type str

        if self.parse_mode is not None:
            array['parse_mode'] = u(self.parse_mode)  # py2: type unicode, py3: type str

        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array


Instruction:
Make a summary of the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_video_note(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            video_note=self.video_note, chat_id=self.receiver, reply_to_message_id=self.reply_id, duration=self.duration, length=self.length, thumb=self.thumb, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Make a summary of the following Python 3 code
def to_array(self):
        array = super(VideoNoteMessage, self).to_array()
        if isinstance(self.video_note, InputFile):
            array['video_note'] = self.video_note.to_array()  # type InputFile
        elif isinstance(self.video_note, str):
            array['video_note'] = u(self.video_note)  # py2: type unicode, py3: type str
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.duration is not None:
            array['duration'] = int(self.duration)  # type int
        if self.length is not None:
            array['length'] = int(self.length)  # type int
        if self.thumb is not None:
            if isinstance(self.thumb, InputFile):
                array['thumb'] = self.thumb.to_array()  # type InputFile
            elif isinstance(self.thumb, str):
                array['thumb'] = u(self.thumb)  # py2: type unicode, py3: type str
            else:
                raise TypeError('Unknown type, must be one of InputFile, str.')
            # end if

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this VideoNoteMessage to a dictionary.


Instruction:
Make a summary of the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_media_group(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            media=self.media, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification
        )

Response: Send the message via pytgbot.


Instruction:
Can you tell what is the following Python 3 function doing
def to_array(self):
        array = super(MediaGroupMessage, self).to_array()
        if isinstance(self.media, InputMediaPhoto):
            array['media'] = self._as_array(self.media)  # type list of InputMediaPhoto | list of InputMediaVideo
        elif isinstance(self.media, InputMediaVideo):
            array['media'] = self._as_array(self.media)  # type list of InputMediaPhoto | list of InputMediaVideo
        else:
            raise TypeError('Unknown type, must be one of InputMediaPhoto, InputMediaVideo.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        return array

Response: Serializes this MediaGroupMessage to a dictionary.


Instruction:
Can you generate a brief explanation for the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_location(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            latitude=self.latitude, longitude=self.longitude, chat_id=self.receiver, reply_to_message_id=self.reply_id, live_period=self.live_period, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
How would you explain what the following Python 3 function does
def to_array(self):
        array = super(LocationMessage, self).to_array()
        array['latitude'] = float(self.latitude)  # type float
        array['longitude'] = float(self.longitude)  # type float
        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.live_period is not None:
            array['live_period'] = int(self.live_period)  # type int
        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this LocationMessage to a dictionary.


Instruction:
Make a summary of the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_venue(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            latitude=self.latitude, longitude=self.longitude, title=self.title, address=self.address, chat_id=self.receiver, reply_to_message_id=self.reply_id, foursquare_id=self.foursquare_id, foursquare_type=self.foursquare_type, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via the bot.


Instruction:
Make a summary of the following Python 3 code
def to_array(self):
        array = super(VenueMessage, self).to_array()
        array['latitude'] = float(self.latitude)  # type float
        array['longitude'] = float(self.longitude)  # type float
        array['title'] = u(self.title)  # py2: type unicode, py3: type str

        array['address'] = u(self.address)  # py2: type unicode, py3: type str

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.foursquare_id is not None:
            array['foursquare_id'] = u(self.foursquare_id)  # py2: type unicode, py3: type str

        if self.foursquare_type is not None:
            array['foursquare_type'] = u(self.foursquare_type)  # py2: type unicode, py3: type str

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this VenueMessage to a dictionary.


Instruction:
Implement a function in Python 3 to
send the message via the bot.

Response:
def send(self, sender: PytgbotApiBot):
        """
        Send the message via pytgbot.

        :param sender: The bot instance to send with.
        :type  sender: pytgbot.bot.Bot

        :rtype: PytgbotApiMessage
        """
        return sender.send_contact(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            phone_number=self.phone_number, first_name=self.first_name, chat_id=self.receiver, reply_to_message_id=self.reply_id, last_name=self.last_name, vcard=self.vcard, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )


Instruction:
Here you have a function in Python 3, explain what it does
def to_array(self):
        array = super(ContactMessage, self).to_array()
        array['phone_number'] = u(self.phone_number)  # py2: type unicode, py3: type str

        array['first_name'] = u(self.first_name)  # py2: type unicode, py3: type str

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.last_name is not None:
            array['last_name'] = u(self.last_name)  # py2: type unicode, py3: type str

        if self.vcard is not None:
            array['vcard'] = u(self.vcard)  # py2: type unicode, py3: type str

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array

Response: Serializes this ContactMessage to a dictionary.


Instruction:
Implement a Python 3 function for
sending the message via pytgbot.

Response:
def send(self, sender: PytgbotApiBot):
        """
        Send the message via pytgbot.

        :param sender: The bot instance to send with.
        :type  sender: pytgbot.bot.Bot

        :rtype: PytgbotApiMessage
        """
        return sender.send_chat_action(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            action=self.action, chat_id=self.receiver
        )


Instruction:
Here you have a function in Python 3, explain what it does
def to_array(self):
        array = super(ChatActionMessage, self).to_array()
        array['action'] = u(self.action)  # py2: type unicode, py3: type str

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        return array

Response: Serializes this ChatActionMessage to a dictionary.


Instruction:
Make a summary of the following Python 3 code
def send(self, sender: PytgbotApiBot):
        return sender.send_sticker(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            sticker=self.sticker, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via pytgbot.


Instruction:
Create a Python 3 function to
serialize this StickerMessage to a dictionary.

Response:
def to_array(self):
        """
        Serializes this StickerMessage to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(StickerMessage, self).to_array()
        if isinstance(self.sticker, InputFile):
            array['sticker'] = self.sticker.to_array()  # type InputFile
        elif isinstance(self.sticker, str):
            array['sticker'] = u(self.sticker)  # py2: type unicode, py3: type str
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            if isinstance(self.reply_markup, InlineKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardMarkup):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardMarkup
            elif isinstance(self.reply_markup, ReplyKeyboardRemove):
                array['reply_markup'] = self.reply_markup.to_array()  # type ReplyKeyboardRemove
            elif isinstance(self.reply_markup, ForceReply):
                array['reply_markup'] = self.reply_markup.to_array()  # type ForceReply
            else:
                raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply.')
            # end if

        return array


Instruction:
Can you generate a brief explanation for the following Python 3 code
def from_array(array):
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.files import InputFile
        from pytgbot.api_types.sendable.reply_markup import ForceReply
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup
        from pytgbot.api_types.sendable.reply_markup import ReplyKeyboardMarkup
        from pytgbot.api_types.sendable.reply_markup import ReplyKeyboardRemove

        data = {}
        if isinstance(array.get('sticker'), InputFile):
            data['sticker'] = InputFile.from_array(array.get('sticker'))
        elif isinstance(array.get('sticker'), str):
            data['sticker'] = u(array.get('sticker'))
        else:
            raise TypeError('Unknown type, must be one of InputFile, str.')
        # end if
        if array.get('chat_id') is None:
            data['receiver'] = None
        elif isinstance(array.get('chat_id'), None):
            data['receiver'] = None(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), str):
            data['receiver'] = u(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), int):
            data['receiver'] = int(array.get('chat_id'))
        else:
            raise TypeError('Unknown type, must be one of None, str, int or None.')
        # end if
        if array.get('reply_to_message_id') is None:
            data['reply_id'] = None
        elif isinstance(array.get('reply_to_message_id'), DEFAULT_MESSAGE_ID):
            data['reply_id'] = DEFAULT_MESSAGE_ID(array.get('reply_to_message_id'))
        elif isinstance(array.get('reply_to_message_id'), int):
            data['reply_id'] = int(array.get('reply_to_message_id'))
        else:
            raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int or None.')
        # end if
        data['disable_notification'] = bool(array.get('disable_notification')) if array.get('disable_notification') is not None else None
        if array.get('reply_markup') is None:
            data['reply_markup'] = None
        elif isinstance(array.get('reply_markup'), InlineKeyboardMarkup):
            data['reply_markup'] = InlineKeyboardMarkup.from_array(array.get('reply_markup'))
        elif isinstance(array.get('reply_markup'), ReplyKeyboardMarkup):
            data['reply_markup'] = ReplyKeyboardMarkup.from_array(array.get('reply_markup'))
        elif isinstance(array.get('reply_markup'), ReplyKeyboardRemove):
            data['reply_markup'] = ReplyKeyboardRemove.from_array(array.get('reply_markup'))
        elif isinstance(array.get('reply_markup'), ForceReply):
            data['reply_markup'] = ForceReply.from_array(array.get('reply_markup'))
        else:
            raise TypeError('Unknown type, must be one of InlineKeyboardMarkup, ReplyKeyboardMarkup, ReplyKeyboardRemove, ForceReply or None.')
        # end if
        return StickerMessage(**data)

Response: Deserialize a new StickerMessage from a given dictionary.


Instruction:
Can you tell what is the following Python 3 function doing
def send(self, sender: PytgbotApiBot):
        return sender.send_invoice(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            title=self.title, description=self.description, payload=self.payload, provider_token=self.provider_token, start_parameter=self.start_parameter, currency=self.currency, prices=self.prices, chat_id=self.receiver, reply_to_message_id=self.reply_id, provider_data=self.provider_data, photo_url=self.photo_url, photo_size=self.photo_size, photo_width=self.photo_width, photo_height=self.photo_height, need_name=self.need_name, need_phone_number=self.need_phone_number, need_email=self.need_email, need_shipping_address=self.need_shipping_address, send_phone_number_to_provider=self.send_phone_number_to_provider, send_email_to_provider=self.send_email_to_provider, is_flexible=self.is_flexible, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )

Response: Send the message via the bot.


Instruction:
How would you implement a function in Python 3 that
serializes this InvoiceMessage to a dictionary.

Response:
def to_array(self):
        """
        Serializes this InvoiceMessage to a dictionary.

        :return: dictionary representation of this object.
        :rtype: dict
        """
        array = super(InvoiceMessage, self).to_array()
        array['title'] = u(self.title)  # py2: type unicode, py3: type str

        array['description'] = u(self.description)  # py2: type unicode, py3: type str

        array['payload'] = u(self.payload)  # py2: type unicode, py3: type str

        array['provider_token'] = u(self.provider_token)  # py2: type unicode, py3: type str

        array['start_parameter'] = u(self.start_parameter)  # py2: type unicode, py3: type str

        array['currency'] = u(self.currency)  # py2: type unicode, py3: type str

        array['prices'] = self._as_array(self.prices)  # type list of LabeledPrice

        if self.receiver is not None:
            if isinstance(self.receiver, None):
                array['chat_id'] = None(self.receiver)  # type Noneelif isinstance(self.receiver, str):
                array['chat_id'] = u(self.receiver)  # py2: type unicode, py3: type str
            elif isinstance(self.receiver, int):
                array['chat_id'] = int(self.receiver)  # type intelse:
                raise TypeError('Unknown type, must be one of None, str, int.')
            # end if

        if self.reply_id is not None:
            if isinstance(self.reply_id, DEFAULT_MESSAGE_ID):
                array['reply_to_message_id'] = DEFAULT_MESSAGE_ID(self.reply_id)  # type DEFAULT_MESSAGE_IDelif isinstance(self.reply_id, int):
                array['reply_to_message_id'] = int(self.reply_id)  # type intelse:
                raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int.')
            # end if

        if self.provider_data is not None:
            array['provider_data'] = u(self.provider_data)  # py2: type unicode, py3: type str

        if self.photo_url is not None:
            array['photo_url'] = u(self.photo_url)  # py2: type unicode, py3: type str

        if self.photo_size is not None:
            array['photo_size'] = int(self.photo_size)  # type int
        if self.photo_width is not None:
            array['photo_width'] = int(self.photo_width)  # type int
        if self.photo_height is not None:
            array['photo_height'] = int(self.photo_height)  # type int
        if self.need_name is not None:
            array['need_name'] = bool(self.need_name)  # type bool
        if self.need_phone_number is not None:
            array['need_phone_number'] = bool(self.need_phone_number)  # type bool
        if self.need_email is not None:
            array['need_email'] = bool(self.need_email)  # type bool
        if self.need_shipping_address is not None:
            array['need_shipping_address'] = bool(self.need_shipping_address)  # type bool
        if self.send_phone_number_to_provider is not None:
            array['send_phone_number_to_provider'] = bool(self.send_phone_number_to_provider)  # type bool
        if self.send_email_to_provider is not None:
            array['send_email_to_provider'] = bool(self.send_email_to_provider)  # type bool
        if self.is_flexible is not None:
            array['is_flexible'] = bool(self.is_flexible)  # type bool
        if self.disable_notification is not None:
            array['disable_notification'] = bool(self.disable_notification)  # type bool
        if self.reply_markup is not None:
            array['reply_markup'] = self.reply_markup.to_array()  # type InlineKeyboardMarkup

        return array


Instruction:
How would you explain what the following Python 3 function does
def from_array(array):
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")
        from pytgbot.api_types.sendable.payments import LabeledPrice
        from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup

        data = {}
        data['title'] = u(array.get('title'))
        data['description'] = u(array.get('description'))
        data['payload'] = u(array.get('payload'))
        data['provider_token'] = u(array.get('provider_token'))
        data['start_parameter'] = u(array.get('start_parameter'))
        data['currency'] = u(array.get('currency'))
        data['prices'] = LabeledPrice.from_array_list(array.get('prices'), list_level=1)
        if array.get('chat_id') is None:
            data['receiver'] = None
        elif isinstance(array.get('chat_id'), None):
            data['receiver'] = None(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), str):
            data['receiver'] = u(array.get('chat_id'))
        elif isinstance(array.get('chat_id'), int):
            data['receiver'] = int(array.get('chat_id'))
        else:
            raise TypeError('Unknown type, must be one of None, str, int or None.')
        # end if
        if array.get('reply_to_message_id') is None:
            data['reply_id'] = None
        elif isinstance(array.get('reply_to_message_id'), DEFAULT_MESSAGE_ID):
            data['reply_id'] = DEFAULT_MESSAGE_ID(array.get('reply_to_message_id'))
        elif isinstance(array.get('reply_to_message_id'), int):
            data['reply_id'] = int(array.get('reply_to_message_id'))
        else:
            raise TypeError('Unknown type, must be one of DEFAULT_MESSAGE_ID, int or None.')
        # end if
        data['provider_data'] = u(array.get('provider_data')) if array.get('provider_data') is not None else None
        data['photo_url'] = u(array.get('photo_url')) if array.get('photo_url') is not None else None
        data['photo_size'] = int(array.get('photo_size')) if array.get('photo_size') is not None else None
        data['photo_width'] = int(array.get('photo_width')) if array.get('photo_width') is not None else None
        data['photo_height'] = int(array.get('photo_height')) if array.get('photo_height') is not None else None
        data['need_name'] = bool(array.get('need_name')) if array.get('need_name') is not None else None
        data['need_phone_number'] = bool(array.get('need_phone_number')) if array.get('need_phone_number') is not None else None
        data['need_email'] = bool(array.get('need_email')) if array.get('need_email') is not None else None
        data['need_shipping_address'] = bool(array.get('need_shipping_address')) if array.get('need_shipping_address') is not None else None
        data['send_phone_number_to_provider'] = bool(array.get('send_phone_number_to_provider')) if array.get('send_phone_number_to_provider') is not None else None
        data['send_email_to_provider'] = bool(array.get('send_email_to_provider')) if array.get('send_email_to_provider') is not None else None
        data['is_flexible'] = bool(array.get('is_flexible')) if array.get('is_flexible') is not None else None
        data['disable_notification'] = bool(array.get('disable_notification')) if array.get('disable_notification') is not None else None
        data['reply_markup'] = InlineKeyboardMarkup.from_array(array.get('reply_markup')) if array.get('reply_markup') is not None else None
        return InvoiceMessage(**data)

Response: Deserialize a new InvoiceMessage from a given dictionary.


Instruction:
Create a Python 3 function for
sending the message via pytgbot.

Response:
def send(self, sender: PytgbotApiBot):
        """
        Send the message via pytgbot.

        :param sender: The bot instance to send with.
        :type  sender: pytgbot.bot.Bot

        :rtype: PytgbotApiMessage
        """
        return sender.send_game(
            # receiver, self.media, disable_notification=self.disable_notification, reply_to_message_id=reply_id
            game_short_name=self.game_short_name, chat_id=self.receiver, reply_to_message_id=self.reply_id, disable_notification=self.disable_notification, reply_markup=self.reply_markup
        )