U
    2tc                    @   sV  d Z ddlZddlZddlmZ ddlmZmZmZm	Z	m
Z
mZmZmZ ddlmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7 ddl8m9Z9m:Z:m;Z;m<Z< erBddlm=Z=m>Z>m?Z?m@Z@mAZAmBZBmCZCmDZDmEZE G d	d
 d
e ZFdS )zBThis module contains an object that represents a Telegram Message.    N)escape)TYPE_CHECKINGAnyDictListOptionalUnionClassVarTuple)#	AnimationAudioChatContactDiceDocumentGameInlineKeyboardMarkupInvoiceLocationMessageEntity	ParseModePassportData	PhotoSizePollStickerSuccessfulPaymentTelegramObjectUserVenueVideo	VideoNoteVoiceVoiceChatStartedVoiceChatEndedVoiceChatParticipantsInvitedProximityAlertTriggeredReplyMarkupMessageAutoDeleteTimerChangedVoiceChatScheduledVideoChatStartedVideoChatEndedVideoChatParticipantsInvited
WebAppDataVideoChatScheduled)escape_markdownfrom_timestampto_timestampDEFAULT_NONE
DEFAULT_20)JSONDict	FileInputODVInputDVInput)	BotGameHighScore
InputMedia	MessageIdInputMediaAudioInputMediaDocumentInputMediaPhotoInputMediaVideoLabeledPricec                C       s  e Zd ZU dZdZddddddd	d
ddddddgZeee  e	d< ddddddddddddddd d!d"d#d$d%d&ge Z
eee  e	d'< deejeeeeeejd ejeed* ed* eeeee eeeeee eeeeeeee eeeeeed eeeeeeeeeee d+e!ee"ee#e$e%e&e'eee(e)e*e+e,e-d,Ad-d.Z.e/ed/d0d1Z0e/e1e d/d2d3Z2e3e1e4 d+e1d  d4d5d6Z5e/e6eeeeeeee eeeeeed(f d/d7d8Z7ee-d9 fd:d;Z8e4d/ fd<d=Z9e1e e1e e1e d>d?d@Z:e;e;e;d(d(e;d(e;d(d(d(fee<e e<e e=e ee>e<e? e4e<e e6ed* e@dA f eed dBdCdDZAe;e;d(d(e;d(e;d(d(d(f
ee<e e=e ee>e<e? e4e<e e6ed* e@dA f eed dEdFdGZBe;e;d(d(e;d(e;d(d(d(f
ee<e e=e ee>e<e? e4e<e e6ed* e@dA f eed dEdHdIZCe;e;d(d(e;d(e;d(d(d(f
ee<e e=e ee>e<e? e4e<e e6ed* e@dA f eed dEdJdKZDe;d(eEd(e;d(d(fee6dL  e<e ee=e? e4e<e eeed  dM	dNdOZFd(e;d(d(eEe;d(e;d(d(d(d(fe6eGdPf ee=e ee>e=e? e<e e4e<e e6ed* e@dA f eeed dQdRdSZHd(d(d(d(e;d(d(eEe;d(d(e;d(d(d(d(fe6eGdTf eeeee=e ee>e=e? e<e eGe4e<e e6ed* e@dA f eeed dUdVdWZId(d(e;d(d(eEe;d(d(d(e;d(d(d(fe6eGdXf eee=e ee>e=e? e<e eGe4ee<e e6ed* e@dA f eed dYdZd[ZJd(d(d(d(d(e;e;d(d(eEd(e;d(d(d(d(fe6eGd\f eeeeGee<e e=e ee>e=e? e4e<e e6ed* e@dA f eeed d]d^d_ZKe;d(d(eEd(e;d(d(fe6eGd`f e=e ee>e=e? e4e<e eed da
dbdcZLd(d(e;d(d(eEd(d(e;d(d(d(e;d(d(d(d(fe6eGddf eee=e ee>e=e? eee<e eeGe4e<e e6ed* e@dA f eeed dedfdgZMd(d(e;d(d(eEd(d(e;d(d(d(fe6eGdhf eee=e ee>e=e? eGe4e<e eeed didjdkZNd(d(e;d(d(eEe;d(e;d(d(d(d(fe6eGdlf eee=e ee>e=e? e<e e4e<e e6ed* e@dA f eeed dmdndoZOd(d(e;d(d(e;d(d(d(d(d(d(e;d(d(fe?e?e=e ee>e<e? eee4e?eee<e eed dpdqdrZPd(d(d(d(d(e;d(d(e;d(d(d(d(d(e;d(d(fe?e?eeee=e ee>e<e? eee4eee<e eed dsdtduZQd(d(d(e;d(d(e;d(d(d(e;d(d(feeee=e ee>e<e? eee4e<e eed dvdwdxZRdyejSd)d(d(e;d(d(e;d(e;d(d(d(e;d(d(d(feee eeeeee<e ee>e<e? ee<e ee6eejf e4e<e e6ed* e@dA f eed dzd{d|ZTe;d(d(e;d(d(e;d(d(f	e<e ee>e<e? ee4e<e eed d}
d~dZUe;d(fee<e? e4edddZVe;d(d(e;d(e;d(d(fee=e ede<e? e4e<e eed d
ddZWd(d(d(d(d(d(d(d(d(d(e;d(d(d(d(d(e;d(e;d(d(d(d(feeeeeed eeeeeeeeeee=e ede6eeXf eee<e? e4e<e eeee ed dddZYe;e;d(d(fe6eef e=e e<e? e4ed dddZZd(e;d(e;d(e;d(e;d(d(f
e6eef ee<e e6e@dA ed* f e=e ee=e e>e<e? e4eddddZ[d(e;d(e;d(e;d(e;d(d(d(fe6eef eee<e e6e@dA ed* f e=e ee=e e>e<e? e4eeddddZ\e;e;d(e;d(d(fee<e e<e e e<e? e4e6ed* e@dA f e6d ef dddZ]d(d(e;e;d(d(fee e<e? e<e e4e6ed* e@dA f e6d ef dddZ^d(d(e;d(fde e<e? e4e6d ef dddZ_d(e;d(fe1d e<e? e4e6d ef dddZ`d(d(d(d(e;d(d(d(d(f	e?e?ee e<e? e4e?eee6d ef d
ddZad(e;d(fe e<e? e4e6d ef dddZbd(d(e;d(fe6eef eeee<e? e4e6d ef dddZce;d(fe6eef e<e? e4ed dddZde;d(fe<e? e4edddZed(e;d(fe e<e? e4edddZfe;e;d(fe<e e<e? e4edddZge;d(fe<e? e4edddZheiedddZjeiedddZkdee eleief dddZmdee eleief dddZneode1e eleief eee1e dÜddńZpe/ed/ddǄZqe/ed/ddɄZre/ed/dd˄Zse/ed/dd̈́Zteode1e eleief eeee1e dϜddфZue/ed/ddӄZve/ed/ddՄZwe/ed/ddׄZxe/ed/ddلZye/ed/ddۄZze/ed/dd݄Z{e/ed/dd߄Z|e/ed/ddZ}  Z~S )MessageaR  This object represents a message.

    Objects of this class are comparable in terms of equality. Two objects of this class are
    considered equal, if their :attr:`message_id` and :attr:`chat` are equal.

    Note:
        In Python ``from`` is a reserved word, use ``from_user`` instead.

    .. versionchanged:: 13.12
        Since Bot API 6.0, voice chat was renamed to video chat.

    Args:
        message_id (:obj:`int`): Unique message identifier inside this chat.
        from_user (:class:`telegram.User`, optional): Sender of the message; empty for messages
            sent to channels. For backward compatibility, this will contain a fake sender user in
            non-channel chats, if the message was sent on behalf of a chat.
        sender_chat (:class:`telegram.Chat`, optional): Sender of the message, sent on behalf of a
            chat.  For example, the channel itself for channel posts, the supergroup itself for
            messages from anonymous group administrators, the linked channel for messages
            automatically forwarded to the discussion group. For backward compatibility,
            :attr:`from_user` contains a fake sender user in non-channel chats, if the message was
            sent on behalf of a chat.
        date (:class:`datetime.datetime`): Date the message was sent in Unix time. Converted to
            :class:`datetime.datetime`.
        chat (:class:`telegram.Chat`): Conversation the message belongs to.
        forward_from (:class:`telegram.User`, optional): For forwarded messages, sender of
            the original message.
        forward_from_chat (:class:`telegram.Chat`, optional): For messages forwarded from channels
            or from anonymous administrators, information about the original sender chat.
        forward_from_message_id (:obj:`int`, optional): For forwarded channel posts, identifier of
            the original message in the channel.
        forward_sender_name	(:obj:`str`, optional): Sender's name for messages forwarded from users
            who disallow adding a link to their account in forwarded messages.
        forward_date (:class:`datetime.datetime`, optional): For forwarded messages, date the
            original message was sent in Unix time. Converted to :class:`datetime.datetime`.
        is_automatic_forward (:obj:`bool`, optional): :obj:`True`, if the message is a channel post
            that was automatically forwarded to the connected discussion group.

            .. versionadded:: 13.9
        reply_to_message (:class:`telegram.Message`, optional): For replies, the original message.
        edit_date (:class:`datetime.datetime`, optional): Date the message was last edited in Unix
            time. Converted to :class:`datetime.datetime`.
        has_protected_content (:obj:`bool`, optional): :obj:`True`, if the message can't be
            forwarded.

            .. versionadded:: 13.9
        media_group_id (:obj:`str`, optional): The unique identifier of a media message group this
            message belongs to.
        text (str, optional): For text messages, the actual UTF-8 text of the message, 0-4096
            characters. Also found as :attr:`telegram.constants.MAX_MESSAGE_LENGTH`.
        entities (List[:class:`telegram.MessageEntity`], optional): For text messages, special
            entities like usernames, URLs, bot commands, etc. that appear in the text. See
            :attr:`parse_entity` and :attr:`parse_entities` methods for how to use properly.
        caption_entities (List[:class:`telegram.MessageEntity`]): Optional. For Messages with a
            Caption. Special entities like usernames, URLs, bot commands, etc. that appear in the
            caption. See :attr:`Message.parse_caption_entity` and :attr:`parse_caption_entities`
            methods for how to use properly.
        audio (:class:`telegram.Audio`, optional): Message is an audio file, information
            about the file.
        document (:class:`telegram.Document`, optional): Message is a general file, information
            about the file.
        animation (:class:`telegram.Animation`, optional): Message is an animation, information
            about the animation. For backward compatibility, when this field is set, the document
            field will also be set.
        game (:class:`telegram.Game`, optional): Message is a game, information about the game.
        photo (List[:class:`telegram.PhotoSize`], optional): Message is a photo, available
            sizes of the photo.
        sticker (:class:`telegram.Sticker`, optional): Message is a sticker, information
            about the sticker.
        video (:class:`telegram.Video`, optional): Message is a video, information about the video.
        voice (:class:`telegram.Voice`, optional): Message is a voice message, information about
            the file.
        video_note (:class:`telegram.VideoNote`, optional): Message is a video note, information
            about the video message.
        new_chat_members (List[:class:`telegram.User`], optional): New members that were added to
            the group or supergroup and information about them (the bot itself may be one of these
            members).
        caption (:obj:`str`, optional): Caption for the animation, audio, document, photo, video
            or voice, 0-1024 characters.
        contact (:class:`telegram.Contact`, optional): Message is a shared contact, information
            about the contact.
        location (:class:`telegram.Location`, optional): Message is a shared location, information
            about the location.
        venue (:class:`telegram.Venue`, optional): Message is a venue, information about the venue.
            For backward compatibility, when this field is set, the location field will also be
            set.
        left_chat_member (:class:`telegram.User`, optional): A member was removed from the group,
            information about them (this member may be the bot itself).
        new_chat_title (:obj:`str`, optional): A chat title was changed to this value.
        new_chat_photo (List[:class:`telegram.PhotoSize`], optional): A chat photo was changed to
            this value.
        delete_chat_photo (:obj:`bool`, optional): Service message: The chat photo was deleted.
        group_chat_created (:obj:`bool`, optional): Service message: The group has been created.
        supergroup_chat_created (:obj:`bool`, optional): Service message: The supergroup has been
            created. This field can't be received in a message coming through updates, because bot
            can't be a member of a supergroup when it is created. It can only be found in
            :attr:`reply_to_message` if someone replies to a very first message in a directly
            created supergroup.
        channel_chat_created (:obj:`bool`, optional): Service message: The channel has been
            created. This field can't be received in a message coming through updates, because bot
            can't be a member of a channel when it is created. It can only be found in
            :attr:`reply_to_message` if someone replies to a very first message in a channel.
        message_auto_delete_timer_changed (:class:`telegram.MessageAutoDeleteTimerChanged`,             optional): Service message: auto-delete timer settings changed in the chat.

            .. versionadded:: 13.4
        migrate_to_chat_id (:obj:`int`, optional): The group has been migrated to a supergroup with
            the specified identifier. This number may be greater than 32 bits and some programming
            languages may have difficulty/silent defects in interpreting it. But it is smaller than
            52 bits, so a signed 64 bit integer or double-precision float type are safe for storing
            this identifier.
        migrate_from_chat_id (:obj:`int`, optional): The supergroup has been migrated from a group
            with the specified identifier. This number may be greater than 32 bits and some
            programming languages may have difficulty/silent defects in interpreting it. But it is
            smaller than 52 bits, so a signed 64 bit integer or double-precision float type are
            safe for storing this identifier.
        pinned_message (:class:`telegram.Message`, optional): Specified message was pinned. Note
            that the Message object in this field will not contain further :attr:`reply_to_message`
            fields even if it is itself a reply.
        invoice (:class:`telegram.Invoice`, optional): Message is an invoice for a payment,
            information about the invoice.
        successful_payment (:class:`telegram.SuccessfulPayment`, optional): Message is a service
            message about a successful payment, information about the payment.
        connected_website (:obj:`str`, optional): The domain name of the website on which the user
            has logged in.
        forward_signature (:obj:`str`, optional): For messages forwarded from channels, signature
            of the post author if present.
        author_signature (:obj:`str`, optional):  Signature of the post author for messages in
            channels, or the custom title of an anonymous group administrator.
        passport_data (:class:`telegram.PassportData`, optional): Telegram Passport data.
        poll (:class:`telegram.Poll`, optional): Message is a native poll,
            information about the poll.
        dice (:class:`telegram.Dice`, optional): Message is a dice with random value from 1 to 6.
        via_bot (:class:`telegram.User`, optional): Message was sent through an inline bot.
        proximity_alert_triggered (:class:`telegram.ProximityAlertTriggered`, optional): Service
            message. A user in the chat triggered another user's proximity alert while sharing
            Live Location.
        voice_chat_scheduled (:class:`telegram.VoiceChatScheduled`, optional): Service message:
            voice chat scheduled.

            .. versionadded:: 13.5
            .. deprecated:: 13.12
        voice_chat_started (:class:`telegram.VoiceChatStarted`, optional): Service message: voice
            chat started.

            .. versionadded:: 13.4
            .. deprecated:: 13.12
        voice_chat_ended (:class:`telegram.VoiceChatEnded`, optional): Service message: voice chat
            ended.

            .. versionadded:: 13.4
            .. deprecated:: 13.12
        voice_chat_participants_invited (:class:`telegram.VoiceChatParticipantsInvited` optional):
            Service message: new participants invited to a voice chat.

            .. versionadded:: 13.4
            .. deprecated:: 13.12
        video_chat_scheduled (:class:`telegram.VideoChatScheduled`, optional): Service message:
            video chat scheduled.

            .. versionadded:: 13.12
        video_chat_started (:class:`telegram.VideaChatStarted`, optional): Service message: video
            chat started.

            .. versionadded:: 13.12
        video_chat_ended (:class:`telegram.VideaChatEnded`, optional): Service message: video chat
            ended.

            .. versionadded:: 13.12
        video_chat_participants_invited (:class:`telegram.VideoChatParticipantsInvited` optional):
            Service message: new participants invited to a video chat.

            .. versionadded:: 13.12
        web_app_data (:class:`telegram.WebAppData`, optional): Service message: data sent by a Web
            App.
            .. versionadded:: 13.12
        reply_markup (:class:`telegram.InlineKeyboardMarkup`, optional): Inline keyboard attached
            to the message. ``login_url`` buttons are represented as ordinary url buttons.
        bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods.

    Attributes:
        message_id (:obj:`int`): Unique message identifier inside this chat.
        from_user (:class:`telegram.User`): Optional. Sender of the message; empty for messages
            sent to channels. For backward compatibility, this will contain a fake sender user in
            non-channel chats, if the message was sent on behalf of a chat.
        sender_chat (:class:`telegram.Chat`): Optional. Sender of the message, sent on behalf of a
            chat. For backward compatibility, :attr:`from_user` contains a fake sender user in
            non-channel chats, if the message was sent on behalf of a chat.
        date (:class:`datetime.datetime`): Date the message was sent.
        chat (:class:`telegram.Chat`): Conversation the message belongs to.
        forward_from (:class:`telegram.User`): Optional. Sender of the original message.
        forward_from_chat (:class:`telegram.Chat`): Optional. For messages forwarded from channels
            or from anonymous administrators, information about the original sender chat.
        forward_from_message_id (:obj:`int`): Optional. Identifier of the original message in the
            channel.
        forward_date (:class:`datetime.datetime`): Optional. Date the original message was sent.
        is_automatic_forward (:obj:`bool`): Optional. :obj:`True`, if the message is a channel post
            that was automatically forwarded to the connected discussion group.

            .. versionadded:: 13.9
        reply_to_message (:class:`telegram.Message`): Optional. For replies, the original message.
            Note that the Message object in this field will not contain further
            ``reply_to_message`` fields even if it itself is a reply.
        edit_date (:class:`datetime.datetime`): Optional. Date the message was last edited.
        has_protected_content (:obj:`bool`): Optional. :obj:`True`, if the message can't be
            forwarded.

            .. versionadded:: 13.9
        media_group_id (:obj:`str`): Optional. The unique identifier of a media message group this
            message belongs to.
        text (:obj:`str`): Optional. The actual UTF-8 text of the message.
        entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities like
            usernames, URLs, bot commands, etc. that appear in the text. See
            :attr:`Message.parse_entity` and :attr:`parse_entities` methods for how to use
            properly.
        caption_entities (List[:class:`telegram.MessageEntity`]): Optional. Special entities like
            usernames, URLs, bot commands, etc. that appear in the caption. See
            :attr:`Message.parse_caption_entity` and :attr:`parse_caption_entities` methods for how
            to use properly.
        audio (:class:`telegram.Audio`): Optional. Information about the file.
        document (:class:`telegram.Document`): Optional. Information about the file.
        animation (:class:`telegram.Animation`) Optional. Information about the file.
            For backward compatibility, when this field is set, the document field will also be
            set.
        game (:class:`telegram.Game`): Optional. Information about the game.
        photo (List[:class:`telegram.PhotoSize`]): Optional. Available sizes of the photo.
        sticker (:class:`telegram.Sticker`): Optional. Information about the sticker.
        video (:class:`telegram.Video`): Optional. Information about the video.
        voice (:class:`telegram.Voice`): Optional. Information about the file.
        video_note (:class:`telegram.VideoNote`): Optional. Information about the video message.
        new_chat_members (List[:class:`telegram.User`]): Optional. Information about new members to
            the chat. (the bot itself may be one of these members).
        caption (:obj:`str`): Optional. Caption for the document, photo or video, 0-1024
            characters.
        contact (:class:`telegram.Contact`): Optional. Information about the contact.
        location (:class:`telegram.Location`): Optional. Information about the location.
        venue (:class:`telegram.Venue`): Optional. Information about the venue.
        left_chat_member (:class:`telegram.User`): Optional. Information about the user that left
            the group. (this member may be the bot itself).
        new_chat_title (:obj:`str`): Optional. A chat title was changed to this value.
        new_chat_photo (List[:class:`telegram.PhotoSize`]): Optional. A chat photo was changed to
            this value.
        delete_chat_photo (:obj:`bool`): Optional. The chat photo was deleted.
        group_chat_created (:obj:`bool`): Optional. The group has been created.
        supergroup_chat_created (:obj:`bool`): Optional. The supergroup has been created.
        channel_chat_created (:obj:`bool`): Optional. The channel has been created.
        message_auto_delete_timer_changed (:class:`telegram.MessageAutoDeleteTimerChanged`):
            Optional. Service message: auto-delete timer settings changed in the chat.

            .. versionadded:: 13.4
        migrate_to_chat_id (:obj:`int`): Optional. The group has been migrated to a supergroup with
            the specified identifier.
        migrate_from_chat_id (:obj:`int`): Optional. The supergroup has been migrated from a group
            with the specified identifier.
        pinned_message (:class:`telegram.message`): Optional. Specified message was pinned.
        invoice (:class:`telegram.Invoice`): Optional. Information about the invoice.
        successful_payment (:class:`telegram.SuccessfulPayment`): Optional. Information about the
            payment.
        connected_website (:obj:`str`): Optional. The domain name of the website on which the user
            has logged in.
        forward_signature (:obj:`str`): Optional. Signature of the post author for messages
            forwarded from channels.
        forward_sender_name	(:obj:`str`): Optional. Sender's name for messages forwarded from users
            who disallow adding a link to their account in forwarded messages.
        author_signature (:obj:`str`): Optional. Signature of the post author for messages in
            channels, or the custom title of an anonymous group administrator.
        passport_data (:class:`telegram.PassportData`): Optional. Telegram Passport data.
        poll (:class:`telegram.Poll`): Optional. Message is a native poll,
            information about the poll.
        dice (:class:`telegram.Dice`): Optional. Message is a dice.
        via_bot (:class:`telegram.User`): Optional. Bot through which the message was sent.
        proximity_alert_triggered (:class:`telegram.ProximityAlertTriggered`): Optional. Service
            message. A user in the chat triggered another user's proximity alert while sharing
            Live Location.
        voice_chat_scheduled (:class:`telegram.VoiceChatScheduled`): Optional. Service message:
            voice chat scheduled.

            .. versionadded:: 13.5
            .. deprecated:: 13.12 contains the same value as :attr:`VideoChatScheduled`
                for backwards compatibility.
        voice_chat_started (:class:`telegram.VoiceChatStarted`): Optional. Service message: voice
            chat started.

            .. versionadded:: 13.4
            .. deprecated:: 13.12 contains the same value as :attr:`VideoChatStarted`
                for backwards compatibility.
        voice_chat_ended (:class:`telegram.VoiceChatEnded`): Optional. Service message: voice chat
            ended.

            .. versionadded:: 13.4
            .. deprecated:: 13.12 contains the same value as :attr:`VideoChatEnded`
                for backwards compatibility.
        voice_chat_participants_invited (:class:`telegram.VoiceChatParticipantsInvited`): Optional.
            Service message: new participants invited to a voice chat.

            .. versionadded:: 13.4
            .. deprecated:: 13.12 contains the same value as :attr:`VideoChatParticipantsInvited`
                for backwards compatibility.
        video_chat_scheduled (:class:`telegram.VideoChatScheduled`): Optional. Service message:
            video chat scheduled.

            .. versionadded:: 13.12
        video_chat_started (:class:`telegram.VideoChatStarted`): Optional. Service message: video
            chat started.

            .. versionadded:: 13.12
        video_chat_ended (:class:`telegram.VideoChatEnded`): Optional. Service message: video chat
            ended.

            .. versionadded:: 13.12
        video_chat_participants_invited (:class:`telegram.VideoChatParticipantsInvited`): Optional.
            Service message: new participants invited to a video chat.

            .. versionadded:: 13.12
        web_app_data (:class:`telegram.WebAppData`): Optional. Service message: data sent by a Web
            App.

            .. versionadded:: 13.12
        reply_markup (:class:`telegram.InlineKeyboardMarkup`): Optional. Inline keyboard attached
            to the message.
        bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.

    .. |custom_emoji_formatting_note| replace:: Custom emoji entities will currently be ignored
        by this function. Instead, the supplied replacement for the emoji will be used.
    )Breply_markupaudiocontactmigrate_to_chat_idforward_signaturechatsuccessful_paymentgametextforward_sender_namedocumentnew_chat_titleforward_dategroup_chat_createdmedia_group_idcaptionvideobotentitiesvia_botnew_chat_membersconnected_website	animationmigrate_from_chat_idforward_fromstickerlocationvenue	edit_datereply_to_messagepassport_datapinned_messageforward_from_chatnew_chat_photo
message_iddelete_chat_photo	from_userauthor_signatureproximity_alert_triggeredsender_chatdiceforward_from_message_idcaption_entitiesvoicedatesupergroup_chat_createdpollleft_chat_memberphotochannel_chat_createdinvoice
video_note_effective_attachment!message_auto_delete_timer_changedvoice_chat_endedvoice_chat_participants_invitedvoice_chat_startedvoice_chat_scheduledvideo_chat_endedvideo_chat_participants_invitedvideo_chat_startedvideo_chat_scheduledis_automatic_forwardhas_protected_contentweb_app_data	_id_attrsrB   rH   rW   rK   rq   rZ   rQ   rl   rt   rC   r[   r\   rs   rG   ATTACHMENT_TYPESrI   rU   rp   rL   rb   rd   rN   rn   rr   rv   rD   rX   r`   ro   ri   r_   rg   rz   ry   rw   rx   MESSAGE_TYPESNFr   r7   )Arc   rm   rF   re   rY   ra   rj   rM   r^   r]   rI   rS   rk   rB   rK   rH   rq   rZ   rQ   rl   rt   rU   rP   rC   r[   r\   rp   rL   rb   rd   rN   rn   rr   rD   rX   r`   rs   rG   rE   rf   rO   rV   rW   r_   ro   rJ   rA   rR   ri   rT   rg   rh   ry   rw   rx   rv   rz   r   r   r~   r}   r{   r|   r   _kwargscA           F      K   sl  |9d k	r |<d k	r |9|<kr t d|6d k	r@|>d k	r@|6|>kr@t d|7d k	r`|?d k	r`|7|?kr`t dt|| _|| _|4| _|| _|| _|| _|| _|| _	|:| _
|	| _|
| _|;| _|| _|pg | _|pg | _|| _|| _|| _|pg | _|| _|| _|| _|| _|| _|| _|| _|| _|pg | _|| _|| _|p2g | _ t!|| _"t!|| _#t!| | _$|"| _%|#| _&t!|!| _'|8| _(|$| _)|| _*|%| _+|&| _,|*| _-|'| _.|.| _/|(| _0|)| _1|+| _2|,| _3|-| _4|1| _5|2| _6|3| _7|/| _8|<d k	r|<n|9}B|B| _9|B| _:|=d k	r|=n|5}C|C| _;|C| _<|>d k	r|>n|6}D|D| _=|D| _>|?d k	r8|?n|7}E|E| _?|E| _@|@| _A|0| _BtC| _D| j| jf| _Ed S )NzKOnly supply one of `video_chat_scheduled`/`voice_chat_scheduled`, not both.zCOnly supply one of `video_chat_ended`/`voice_chat_ended`, not both.zaOnly supply one of `video_chat_participants_invited`/`voice_chat_participants_invited`, not both.)F
ValueErrorintrc   re   rh   rm   rF   rY   ra   rM   r   r^   r]   r   rI   rS   rk   rB   rH   rK   rq   rZ   rQ   rl   rt   rP   rC   r[   r\   rU   rp   rL   rb   boolrd   rN   rn   rD   rX   rr   rv   r`   rj   rs   rG   rV   rE   rJ   rf   rO   rW   r_   ro   ri   rT   rg   rA   rz   r~   ry   r}   rw   r{   rx   r|   r   rR   r1   ru   r   )Fselfrc   rm   rF   re   rY   ra   rj   rM   r^   r]   rI   rS   rk   rB   rK   rH   rq   rZ   rQ   rl   rt   rU   rP   rC   r[   r\   rp   rL   rb   rd   rN   rn   rr   rD   rX   r`   rs   rG   rE   rf   rO   rV   rW   r_   ro   rJ   rA   rR   ri   rT   rg   rh   ry   rw   rx   rv   rz   r   r   r~   r}   r{   r|   r   r   Ztemp0Ztemp1Ztemp2Ztemp3 r   4/tmp/pip-unpacked-wheel-2u9rcp5s/telegram/message.py__init__  s    E







zMessage.__init__)returnc                 C   s   | j jS )zC:obj:`int`: Shortcut for :attr:`telegram.Chat.id` for :attr:`chat`.)rF   idr   r   r   r   chat_id  s    zMessage.chat_idc                 C   sV   | j jtjtjfkrR| j jr&| j j}ndt| j jdd  }d| d| j S dS )z:obj:`str`: Convenience property. If the chat of the message is not
        a private chat or normal group, returns a t.me link of the message.
        zc/   Nzhttps://t.me//)	rF   typer   PRIVATEZGROUPusernamestrr   rc   )r   Zto_linkr   r   r   link  s    
zMessage.link)datarR   r   c                 C   s  |  |}|sdS t|d||d< t|d||d< t|d |d< t|d||d< t|d||d< t|d||d< t|d	||d	< t|d
||d
< t|d|d< t|d||d< t|d|d< t	|d||d< t
|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d||d< t|d ||d < t|d!||d!< t|d"||d"< t|d#||d#< t|d$||d$< t|d%||d%< t|d&||d&< t|d'||d'< t|d(||d(< t|d)||d)< t |d*||d*< t|d+||d+< t|d,||d,< t|d-||d-< t |d.||d.< t!|d/||d/< | f d0|i|S )1z,See :meth:`telegram.TelegramObject.de_json`.Nfromre   rh   rm   rF   rS   rk   rY   ra   rM   r^   r]   rB   rK   rW   rH   rq   rZ   rQ   rl   rt   rC   r[   r\   rU   rp   rb   rv   r`   rs   rG   r_   ro   ri   rT   rg   rA   rz   ry   rw   rx   r~   r}   r{   r|   r   rR   )"Z_parse_datar   de_jsongetr   r/   r   Zde_listr@   r   r   r   r   r   r   r   r!   r    r   r   r   r'   r   r   r   r   r   r%   r   r-   r)   r*   r+   r,   )clsr   rR   r   r   r   r     s    
      zMessage.de_jsonc                 C   sD   | j tk	r| j S tjD ] }t| |drt| || _  q>qd| _ | j S )a  
        :class:`telegram.Audio`
            or :class:`telegram.Contact`
            or :class:`telegram.Document`
            or :class:`telegram.Animation`
            or :class:`telegram.Game`
            or :class:`telegram.Invoice`
            or :class:`telegram.Location`
            or List[:class:`telegram.PhotoSize`]
            or :class:`telegram.Sticker`
            or :class:`telegram.SuccessfulPayment`
            or :class:`telegram.Venue`
            or :class:`telegram.Video`
            or :class:`telegram.VideoNote`
            or :class:`telegram.Voice`: The attachment that this message was sent with. May be
            :obj:`None` if no attachment was sent.

        N)ru   r1   r@   r   getattr)r   ir   r   r   effective_attachment  s    %

zMessage.effective_attachment)itemr   c                    s   |dkr| j jS t |S )Nr   )rF   r   super__getitem__)r   r   	__class__r   r   r   D  s    zMessage.__getitem__c                    s   t   }t| j|d< | jr,t| j|d< | jr@t| j|d< | jrZdd | jD |d< | jrtdd | jD |d< | jrd	d | jD |d
< | j	rdd | j	D |d< | j
rdd | j
D |d< |S )z,See :meth:`telegram.TelegramObject.to_dict`.rm   rM   r]   c                 S   s   g | ]}|  qS r   to_dict.0pr   r   r   
<listcomp>S  s     z#Message.to_dict.<locals>.<listcomp>rq   c                 S   s   g | ]}|  qS r   r   r   er   r   r   r   U  s     rS   c                 S   s   g | ]}|  qS r   r   r   r   r   r   r   W  s     rk   c                 S   s   g | ]}|  qS r   r   r   r   r   r   r   Y  s     rb   c                 S   s   g | ]}|  qS r   r   )r   ur   r   r   r   [  s     rU   )r   r   r0   rm   rM   r]   rq   rS   rk   rb   rU   )r   r   r   r   r   r   G  s"    
zMessage.to_dict)quotereply_to_message_idr   c                 C   s\   |dk	r|S |dk	r |rX| j S n8| jjr4| jjj}nd}|dkrN| jjtjksR|rX| j S dS )z3Modify kwargs for replying with or without quoting.N)rc   rR   defaultsr   rF   r   r   r   )r   r   r   Zdefault_quoter   r   r   _quote_  s    zMessage._quote)r   .)rI   
parse_modedisable_web_page_previewdisable_notificationr   rA   timeout
api_kwargsallow_sending_without_replyrS   r   protect_contentr   c                 C   s2   |  ||}| jj| j|||||||||	|
|dS )a  Shortcut for::

            bot.send_message(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_message`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the message is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        r   rI   r   r   r   r   rA   r   r   r   rS   r   )r   rR   send_messager   )r   rI   r   r   r   r   rA   r   r   r   rS   r   r   r   r   r   
reply_textr  s    zMessage.reply_text)rI   r   r   r   rA   r   r   r   rS   r   r   r   c                 C   s4   |  |
|}| jj| j|tj||||||||	|dS )a  Shortcut for::

            bot.send_message(
                update.effective_message.chat_id,
                parse_mode=ParseMode.MARKDOWN,
                *args,
                **kwargs,
            )

        Sends a message with Markdown version 1 formatting.

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_message`.

        Note:
            :attr:`telegram.ParseMode.MARKDOWN` is a legacy mode, retained by Telegram for
            backward compatibility. You should use :meth:`reply_markdown_v2` instead.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the message is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.
        r   )r   rR   r   r   r   ZMARKDOWNr   rI   r   r   r   rA   r   r   r   rS   r   r   r   r   r   reply_markdown  s    (zMessage.reply_markdownc                 C   s4   |  |
|}| jj| j|tj||||||||	|dS )a8  Shortcut for::

            bot.send_message(
                update.effective_message.chat_id,
                parse_mode=ParseMode.MARKDOWN_V2,
                *args,
                **kwargs,
            )

        Sends a message with markdown version 2 formatting.

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_message`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the message is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.
        r   )r   rR   r   r   r   ZMARKDOWN_V2r   r   r   r   reply_markdown_v2  s    $zMessage.reply_markdown_v2c                 C   s4   |  |
|}| jj| j|tj||||||||	|dS )a#  Shortcut for::

            bot.send_message(
                update.effective_message.chat_id,
                parse_mode=ParseMode.HTML,
                *args,
                **kwargs,
            )

        Sends a message with HTML formatting.

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_message`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the message is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.
        r   )r   rR   r   r   r   ZHTMLr   r   r   r   
reply_html  s    $zMessage.reply_html)r;   r<   r=   r>   )	mediar   r   r   r   r   r   r   r   c	           	   
   C   s*   |  ||}| jj| j|||||||dS )a  Shortcut for::

            bot.send_media_group(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_media_group`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the media group is sent as an
                actual reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            List[:class:`telegram.Message`]: An array of the sent Messages.

        Raises:
            :class:`telegram.error.TelegramError`
        )r   r   r   r   r   r   r   r   )r   rR   Zsend_media_groupr   )	r   r   r   r   r   r   r   r   r   r   r   r   reply_media_groupA  s    zMessage.reply_media_groupr   )rq   rP   r   r   rA   r   r   r   r   rk   filenamer   r   r   c                 C   s4   |  ||}| jj| j|||||||||	|
||dS )a  Shortcut for::

            bot.send_photo(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_photo`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the photo is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rq   rP   r   r   rA   r   r   r   r   rk   r   r   )r   rR   Z
send_photor   )r   rq   rP   r   r   rA   r   r   r   r   rk   r   r   r   r   r   r   reply_photol  s      zMessage.reply_photor   )rB   duration	performertitlerP   r   r   rA   r   r   thumbr   r   rk   r   r   r   r   c                 C   s<   |  ||}| jj| j|||||||||	|
||||||dS )a  Shortcut for::

            bot.send_audio(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_audio`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the audio is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rB   r   r   r   rP   r   r   rA   r   r   r   r   r   rk   r   r   )r   rR   Z
send_audior   )r   rB   r   r   r   rP   r   r   rA   r   r   r   r   r   rk   r   r   r   r   r   r   reply_audio  s(    $zMessage.reply_audior   )rK   r   rP   r   r   rA   r   r   r   r   disable_content_type_detectionr   rk   r   r   r   c                 C   s8   |  ||}| jj| j|||||||||	|
||||dS )a  Shortcut for::

            bot.send_document(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_document`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the document is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rK   r   rP   r   r   rA   r   r   r   r   r   r   rk   r   )r   rR   Zsend_documentr   )r   rK   r   rP   r   r   rA   r   r   r   r   r   r   rk   r   r   r   r   r   reply_document  s$    "zMessage.reply_documentr   )rW   r   widthheightr   rP   r   r   r   rA   r   r   r   rk   r   r   r   r   c                 C   s<   |  ||	}	| jj| j|||||||||	|
||||||dS )a  Shortcut for::

            bot.send_animation(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_animation`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the animation is sent as an
                actual reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rW   r   r   r   r   rP   r   r   r   rA   r   r   r   rk   r   r   )r   rR   Zsend_animationr   )r   rW   r   r   r   r   rP   r   r   r   rA   r   r   r   rk   r   r   r   r   r   r   reply_animation  s(    $zMessage.reply_animationr   )
rZ   r   r   rA   r   r   r   r   r   r   c
           
      C   s,   |  ||}| jj| j||||||||	d	S )a  Shortcut for::

            bot.send_sticker(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_sticker`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the sticker is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )	r   rZ   r   r   rA   r   r   r   r   )r   rR   Zsend_stickerr   )
r   rZ   r   r   rA   r   r   r   r   r   r   r   r   reply_stickerD  s    zMessage.reply_stickerr   )rQ   r   rP   r   r   rA   r   r   r   r   supports_streamingr   r   r   rk   r   r   r   r   c                 C   s>   |  ||}| jj| j|||||||||	|
|||||||dS )a  Shortcut for::

            bot.send_video(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_video`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the video is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rQ   r   rP   r   r   rA   r   r   r   r   r   r   r   r   rk   r   r   )r   rR   Z
send_videor   )r   rQ   r   rP   r   r   rA   r   r   r   r   r   r   r   r   rk   r   r   r   r   r   r   reply_videom  s*    %zMessage.reply_videor    )rt   r   lengthr   r   rA   r   r   r   r   r   r   r   r   c                 C   s4   |  ||}| jj| j|||||||||	|
||dS )a  Shortcut for::

            bot.send_video_note(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_video_note`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the video note is sent as an
                actual reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rt   r   r   r   r   rA   r   r   r   r   r   r   )r   rR   Zsend_video_noter   )r   rt   r   r   r   r   rA   r   r   r   r   r   r   r   r   r   r   reply_video_note  s      zMessage.reply_video_noter!   )rl   r   rP   r   r   rA   r   r   r   r   rk   r   r   r   r   c                 C   s6   |  ||}| jj| j|||||||||	|
|||dS )a  Shortcut for::

            bot.send_voice(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_voice`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the voice note is sent as an
                actual reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   rl   r   rP   r   r   rA   r   r   r   r   rk   r   r   )r   rR   Z
send_voicer   )r   rl   r   rP   r   r   rA   r   r   r   r   rk   r   r   r   r   r   r   reply_voice  s"    !zMessage.reply_voice)latitude	longituder   r   rA   r   r[   live_periodr   horizontal_accuracyheadingproximity_alert_radiusr   r   r   r   c                 C   s8   |  ||}| jj| j|||||||||	|
||||dS )a  Shortcut for::

            bot.send_location(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_location`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the location is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   r   r   r   r   rA   r   r[   r   r   r   r   r   r   r   )r   rR   Zsend_locationr   )r   r   r   r   r   rA   r   r[   r   r   r   r   r   r   r   r   r   r   r   reply_location  s$    "zMessage.reply_location)r   r   r   addressfoursquare_idr   r   rA   r   r\   foursquare_typer   google_place_idgoogle_place_typer   r   r   r   c                 C   s<   |  ||}| jj| j|||||||||	|
||||||dS )a  Shortcut for::

            bot.send_venue(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_venue`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the venue is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   r   r   r   r   r   r   r   rA   r   r\   r   r   r   r   r   r   )r   rR   Z
send_venuer   )r   r   r   r   r   r   r   r   rA   r   r\   r   r   r   r   r   r   r   r   r   r   reply_venueA  s(    $zMessage.reply_venue)phone_number
first_name	last_namer   r   rA   r   rC   vcardr   r   r   r   r   c                 C   s4   |  ||}| jj| j|||||||||	|
||dS )a  Shortcut for::

            bot.send_contact(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_contact`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the contact is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False` in
                private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   r   r   r   r   r   rA   r   rC   r   r   r   r   )r   rR   Zsend_contactr   )r   r   r   r   r   r   rA   r   rC   r   r   r   r   r   r   r   r   reply_contactz  s      zMessage.reply_contactT)questionoptionsis_anonymousr   allows_multiple_answerscorrect_option_id	is_closedr   r   rA   r   explanationexplanation_parse_modeopen_period
close_dater   r   explanation_entitiesr   r   r   c                 C   sB   |  ||	}	| jj| j|||||||||	|
|||||||||dS )a  Shortcut for::

            bot.send_poll(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_poll`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the poll is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   r   r   r   r   r   r   r   r   r   rA   r   r   r   r   r   r   r   r   r   )r   rR   Z	send_pollr   )r   r   r   r   r   r   r   r   r   r   rA   r   r   r   r   r   r   r   r   r   r   r   r   r   
reply_poll  s.    'zMessage.reply_poll)
r   r   rA   r   emojir   r   r   r   r   c
           
      C   s,   |  ||}| jj| j||||||||	d	S )a  Shortcut for::

            bot.send_dice(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_dice`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the dice is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False`
                in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )	r   r   r   rA   r   r   r   r   r   )r   rR   Z	send_dicer   )
r   r   r   rA   r   r   r   r   r   r   r   r   r   
reply_dice  s    zMessage.reply_dice)actionr   r   r   c                 C   s   | j j| j|||dS )a@  Shortcut for::

            bot.send_chat_action(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_chat_action`.

        .. versionadded:: 13.2

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        )r   r   r   r   )rR   Zsend_chat_actionr   )r   r   r   r   r   r   r   reply_chat_action  s    zMessage.reply_chat_actionr   )
game_short_namer   r   rA   r   r   r   r   r   r   c
           
      C   s,   |  ||}| jj| j||||||||	d	S )a  Shortcut for::

            bot.send_game(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_game`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the game is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False`
                in private chats.

        .. versionadded:: 13.2

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )	r   r   r   r   rA   r   r   r   r   )r   rR   Z	send_gamer   )
r   r   r   r   rA   r   r   r   r   r   r   r   r   
reply_game,  s    zMessage.reply_gamer?   )r   descriptionpayloadprovider_tokencurrencypricesstart_parameter	photo_url
photo_sizephoto_widthphoto_height	need_nameneed_phone_number
need_emailneed_shipping_addressis_flexibler   r   rA   provider_datasend_phone_number_to_providersend_email_to_providerr   r   r   r   max_tip_amountsuggested_tip_amountsr   r   c                 C   sT   |  ||}| jj| j|||||||||	|
||||||||||||||||||dS )a  Shortcut for::

            bot.send_invoice(update.effective_message.chat_id, *args, **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.send_invoice`.

        Warning:
            As of API 5.2 :attr:`start_parameter` is an optional argument and therefore the order
            of the arguments had to be changed. Use keyword arguments to make sure that the
            arguments are passed correctly.

        .. versionadded:: 13.2

        .. versionchanged:: 13.5
            As of Bot API 5.2, the parameter :attr:`start_parameter` is optional.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the invoice is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``, this
                parameter will be ignored. Default: :obj:`True` in group chats and :obj:`False`
                in private chats.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message posted.

        )r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r   rA   r  r  r	  r   r   r   r
  r  r   )r   rR   Zsend_invoicer   )r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r   r   rA   r  r  r	  r   r   r   r   r
  r  r   r   r   r   reply_invoiceW  s@    :zMessage.reply_invoice)r   r   r   r   r   r   c              	   C   s   | j j|| j| j||||dS )a  Shortcut for::

            bot.forward_message(chat_id=chat_id,
                                from_chat_id=update.effective_message.chat_id,
                                message_id=update.effective_message.message_id,
                                *args,
                                **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.forward_message`.

        Note:
            Since the release of Bot API 5.5 it can be impossible to forward messages from
            some chats. Use the attributes :attr:`telegram.Message.has_protected_content` and
            :attr:`telegram.Chat.has_protected_content` to check this.

            As a workaround, it is still possible to use :meth:`copy`. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, instance representing the message forwarded.

        )r   from_chat_idrc   r   r   r   r   )rR   Zforward_messager   rc   )r   r   r   r   r   r   r   r   r   forward  s    zMessage.forwardr:   )r   rP   r   rk   r   r   r   rA   r   r   r   r   c                 C   s*   | j j|| j| j||||||||	|
|dS )a  Shortcut for::

            bot.copy_message(chat_id=chat_id,
                             from_chat_id=update.effective_message.chat_id,
                             message_id=update.effective_message.message_id,
                             *args,
                             **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.copy_message`.

        Returns:
            :class:`telegram.MessageId`: On success, returns the MessageId of the sent message.

        r   r  rc   rP   r   rk   r   r   r   rA   r   r   r   )rR   copy_messager   rc   )r   r   rP   r   rk   r   r   r   rA   r   r   r   r   r   r   copy  s    zMessage.copy)r  rc   rP   r   rk   r   r   r   rA   r   r   r   r   r   c                 C   s4   |  ||}| jj| j|||||||||	|
||dS )aP  Shortcut for::

            bot.copy_message(chat_id=message.chat.id,
                             from_chat_id=from_chat_id,
                             message_id=message_id,
                             *args,
                             **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.copy_message`.

        Args:
            quote (:obj:`bool`, optional): If set to :obj:`True`, the copy is sent as an actual
                reply to this message. If ``reply_to_message_id`` is passed in ``kwargs``,
                this parameter will be ignored. Default: :obj:`True` in group chats and
                :obj:`False` in private chats.

                .. versionadded:: 13.1

        Returns:
            :class:`telegram.MessageId`: On success, returns the MessageId of the sent message.

        r  )r   rR   r  r   )r   r  rc   rP   r   rk   r   r   r   rA   r   r   r   r   r   r   r   
reply_copy  s     &zMessage.reply_copy)rI   r   r   rA   r   r   rS   r   c                 C   s$   | j j| j| j|||||||dd
S )a  Shortcut for::

            bot.edit_message_text(chat_id=message.chat_id,
                                  message_id=message.message_id,
                                  *args,
                                  **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.edit_message_text`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise ``True`` is returned.

        N)
r   rc   rI   r   r   rA   r   r   rS   inline_message_id)rR   Zedit_message_textr   rc   )r   rI   r   r   rA   r   r   rS   r   r   r   	edit_text=  s    zMessage.edit_text)rP   rA   r   r   r   rk   r   c                 C   s"   | j j| j| j||||||dd	S )a6  Shortcut for::

            bot.edit_message_caption(chat_id=message.chat_id,
                                     message_id=message.message_id,
                                     *args,
                                     **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_caption`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise ``True`` is returned.

        N)	r   rc   rP   rA   r   r   r   rk   r  )rR   Zedit_message_captionr   rc   )r   rP   rA   r   r   r   rk   r   r   r   edit_captiong  s    zMessage.edit_captionr9   )r   rA   r   r   r   c              	   C   s   | j j| j| j||||ddS )a+  Shortcut for::

            bot.edit_message_media(chat_id=message.chat_id,
                                   message_id=message.message_id,
                                   *args,
                                   **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_media`.

        Note:
            You can only edit messages that the bot sent itself(i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise ``True`` is returned.

        N)r   rc   r   rA   r   r   r  )rR   Zedit_message_mediar   rc   )r   r   rA   r   r   r   r   r   
edit_media  s    zMessage.edit_media)rA   r   r   r   c                 C   s   | j j| j| j|||ddS )aN  Shortcut for::

            bot.edit_message_reply_markup(chat_id=message.chat_id,
                                          message_id=message.message_id,
                                          *args,
                                          **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_reply_markup`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise ``True`` is returned.
        Nr   rc   rA   r   r   r  )rR   Zedit_message_reply_markupr   rc   r   rA   r   r   r   r   r   edit_reply_markup  s    zMessage.edit_reply_markup)
r   r   r[   rA   r   r   r   r   r   r   c
           
      C   s(   | j j| j| j|||||||||	ddS )aV  Shortcut for::

            bot.edit_message_live_location(chat_id=message.chat_id,
                                           message_id=message.message_id,
                                           *args,
                                           **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.edit_message_live_location`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.
        N)r   rc   r   r   r[   rA   r   r   r   r   r   r  )rR   Zedit_message_live_locationr   rc   )
r   r   r   r[   rA   r   r   r   r   r   r   r   r   edit_live_location  s    zMessage.edit_live_locationc                 C   s   | j j| j| j|||ddS )aV  Shortcut for::

            bot.stop_message_live_location(chat_id=message.chat_id,
                                           message_id=message.message_id,
                                           *args,
                                           **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.stop_message_live_location`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.
        Nr  )rR   Zstop_message_live_locationr   rc   r  r   r   r   stop_live_location	  s    zMessage.stop_live_location)user_idscoreforcedisable_edit_messager   r   r   c                 C   s"   | j j| j| j||||||dd	S )a  Shortcut for::

            bot.set_game_score(chat_id=message.chat_id,
                               message_id=message.message_id,
                               *args,
                               **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.set_game_score`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            :class:`telegram.Message`: On success, if edited message is sent by the bot, the
            edited Message is returned, otherwise :obj:`True` is returned.
        N)	r   rc   r  r  r  r  r   r   r  )rR   set_game_scorer   rc   )r   r  r  r  r  r   r   r   r   r   r   '	  s    zMessage.set_game_scorer8   )r  r   r   r   c                 C   s   | j j| j| j|||ddS )a  Shortcut for::

            bot.get_game_high_scores(chat_id=message.chat_id,
                                     message_id=message.message_id,
                                     *args,
                                     **kwargs)

        For the documentation of the arguments, please see
        :meth:`telegram.Bot.get_game_high_scores`.

        Note:
            You can only edit messages that the bot sent itself (i.e. of the ``bot.send_*`` family
            of methods) or channel posts, if the bot is an admin in that channel. However, this
            behaviour is undocumented and might be changed by Telegram.

        Returns:
            List[:class:`telegram.GameHighScore`]
        N)r   rc   r  r   r   r  )rR   get_game_high_scoresr   rc   )r   r  r   r   r   r   r   r!  N	  s    zMessage.get_game_high_scores)r   r   r   c                 C   s   | j j| j| j||dS )a  Shortcut for::

             bot.delete_message(chat_id=message.chat_id,
                                message_id=message.message_id,
                                *args,
                                **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.delete_message`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        r   rc   r   r   )rR   Zdelete_messager   rc   r   r   r   r   r   r   deleteo	  s    zMessage.deletec                 C   s   | j j| j| j|||dS )a  Shortcut for::

             bot.stop_poll(chat_id=message.chat_id,
                           message_id=message.message_id,
                           *args,
                           **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.stop_poll`.

        Returns:
            :class:`telegram.Poll`: On success, the stopped Poll with the final results is
            returned.

        )r   rc   rA   r   r   )rR   	stop_pollr   rc   r  r   r   r   r%  	  s    zMessage.stop_poll)r   r   r   r   c                 C   s   | j j| j| j|||dS )a  Shortcut for::

             bot.pin_chat_message(chat_id=message.chat_id,
                                  message_id=message.message_id,
                                  *args,
                                  **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.pin_chat_message`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        )r   rc   r   r   r   )rR   Zpin_chat_messager   rc   )r   r   r   r   r   r   r   pin	  s    zMessage.pinc                 C   s   | j j| j| j||dS )a  Shortcut for::

             bot.unpin_chat_message(chat_id=message.chat_id,
                                    message_id=message.message_id,
                                    *args,
                                    **kwargs)

        For the documentation of the arguments, please see :meth:`telegram.Bot.unpin_chat_message`.

        Returns:
            :obj:`bool`: On success, :obj:`True` is returned.

        r"  )rR   Zunpin_chat_messager   rc   r#  r   r   r   unpin	  s    zMessage.unpin)entityr   c                 C   sd   | j stdtjdkr0| j |j|j|j  S | j d}||jd |j|j d  }|dS )a  Returns the text from a given :class:`telegram.MessageEntity`.

        Note:
            This method is present because Telegram calculates the offset and length in
            UTF-16 codepoint pairs, which some versions of Python don't handle automatically.
            (That is, you can't just slice ``Message.text`` with the offset and length.)

        Args:
            entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must
                be an entity that belongs to this message.

        Returns:
            :obj:`str`: The text of the given entity.

        Raises:
            RuntimeError: If the message has no text.

        zThis Message has no 'text'.  	utf-16-le   )rI   RuntimeErrorsys
maxunicodeoffsetr   encodedecoder   r(  Zentity_textr   r   r   parse_entity	  s    
zMessage.parse_entityc                 C   sd   | j stdtjdkr0| j |j|j|j  S | j d}||jd |j|j d  }|dS )a  Returns the text from a given :class:`telegram.MessageEntity`.

        Note:
            This method is present because Telegram calculates the offset and length in
            UTF-16 codepoint pairs, which some versions of Python don't handle automatically.
            (That is, you can't just slice ``Message.caption`` with the offset and length.)

        Args:
            entity (:class:`telegram.MessageEntity`): The entity to extract the text from. It must
                be an entity that belongs to this message.

        Returns:
            :obj:`str`: The text of the given entity.

        Raises:
            RuntimeError: If the message has no caption.

        zThis Message has no 'caption'.r)  r*  r+  )rP   r,  r-  r.  r/  r   r0  r1  r2  r   r   r   parse_caption_entity	  s    
zMessage.parse_caption_entity)typesr   c                    s(   dkrt j fdd jp"g D S )ai  
        Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
        It contains entities from this message filtered by their
        :attr:`telegram.MessageEntity.type` attribute as the key, and the text that each entity
        belongs to as the value of the :obj:`dict`.

        Note:
            This method should always be used instead of the :attr:`entities` attribute, since it
            calculates the correct substring from the message text based on UTF-16 codepoints.
            See :attr:`parse_entity` for more info.

        Args:
            types (List[:obj:`str`], optional): List of :class:`telegram.MessageEntity` types as
                strings. If the ``type`` attribute of an entity is contained in this list, it will
                be returned. Defaults to a list of all types. All types can be found as constants
                in :class:`telegram.MessageEntity`.

        Returns:
            Dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to
            the text that belongs to them, calculated based on UTF-16 codepoints.

        Nc                    s"   i | ]}|j kr| |qS r   )r   r3  r   r(  r   r5  r   r   
<dictcomp>.
  s   
 z*Message.parse_entities.<locals>.<dictcomp>)r   	ALL_TYPESrS   r7  r   r7  r   parse_entities
  s
    zMessage.parse_entitiesc                    s(   dkrt j fdd jp"g D S )a{  
        Returns a :obj:`dict` that maps :class:`telegram.MessageEntity` to :obj:`str`.
        It contains entities from this message's caption filtered by their
        :attr:`telegram.MessageEntity.type` attribute as the key, and the text that each entity
        belongs to as the value of the :obj:`dict`.

        Note:
            This method should always be used instead of the :attr:`caption_entities` attribute,
            since it calculates the correct substring from the message text based on UTF-16
            codepoints. See :attr:`parse_entity` for more info.

        Args:
            types (List[:obj:`str`], optional): List of :class:`telegram.MessageEntity` types as
                strings. If the ``type`` attribute of an entity is contained in this list, it will
                be returned. Defaults to a list of all types. All types can be found as constants
                in :class:`telegram.MessageEntity`.

        Returns:
            Dict[:class:`telegram.MessageEntity`, :obj:`str`]: A dictionary of entities mapped to
            the text that belongs to them, calculated based on UTF-16 codepoints.

        Nc                    s"   i | ]}|j kr| |qS r   )r   r4  r6  r7  r   r   r8  N
  s   
 z2Message.parse_caption_entities.<locals>.<dictcomp>)r   r9  rk   r7  r   r7  r   parse_caption_entities4
  s
    zMessage.parse_caption_entitiesr   )message_textrS   urledr/  r   c                    sJ  | d krd S t jdkr | d} d}d}t| dd d}g }|D ]z\ } |krD fdd	|D }	|t|	  |}
t|}|	rt	j
|
|	| jd
} jtjkrd j d| d}n: jtjkr jrd jj d| d}n jtjkr|rd| d| d}n jtjkr2d| d }nʈ jtjkrNd| d }n jtjkrjd| d }n jtjkr jrd j d| d}nd| d }nX jtjkrd| d }n< jtjkrd| d }n  jtjkrd| d}n|}|dkr`t jdkr2|t| | j|  | 7 }n,|t| |d  j| d  d| 7 }nPt jdkr|| | j|  | 7 }n(|| |d  j| d  d| 7 } j|  j }qD|dkrt jdkr|t| |d  7 }n|t| |d d  d7 }n8t jdkr,|| |d  7 }n|| |d d  d7 }|S ) Nr)  r*   r   c                 S   s
   | d j S Nr   r/  r   r   r   r   <lambda>d
      z%Message._parse_html.<locals>.<lambda>keyc                    sB   i | ]:\}}|j  j kr|j |j  j  j kr| kr||qS r   r/  r   r   r   tr(  r   r   r8  i
  s    z'Message._parse_html.<locals>.<dictcomp>)r=  r/  z	<a href="z">z</a>z<a href="tg://user?id=z<b>z</b>z<i>z</i>z<code>z</code>z<pre><code class="z</code></pre>z<pre>z</pre>z<u>z</u>z<s>z</s>z<span class="tg-spoiler">z</span>r+  )r-  r.  r0  sorteditemsextendlistkeysr   r@   _parse_htmlr/  r   r   	TEXT_LINKurlTEXT_MENTIONuserr   URLBOLDITALICCODEPRElanguage	UNDERLINESTRIKETHROUGHSPOILERr1  r   )r<  rS   r=  r/  Z	html_textlast_offsetsorted_entitiesparsed_entitiesrI   nested_entities	orig_textinsertr   rI  r   rO  T
  s    


   
 	 
zMessage._parse_htmlc                 C   s   | j | j|  ddS )a  Creates an HTML-formatted string from the markup entities found in the message.

        Use this if you want to retrieve the message text with the entities formatted as HTML in
        the same way the original message was formatted.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as HTML.

        Returns:
            :obj:`str`: Message text with entities formatted as HTML.

        Fr=  rO  rI   r:  r   r   r   r   	text_html
  s    zMessage.text_htmlc                 C   s   | j | j|  ddS )a  Creates an HTML-formatted string from the markup entities found in the message.

        Use this if you want to retrieve the message text with the entities formatted as HTML.
        This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as HTML.

        Returns:
            :obj:`str`: Message text with entities formatted as HTML.

        Trc  rd  r   r   r   r   text_html_urled
  s    zMessage.text_html_urledc                 C   s   | j | j|  ddS )a  Creates an HTML-formatted string from the markup entities found in the message's
        caption.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        HTML in the same way the original message was formatted.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as HTML.

        Returns:
            :obj:`str`: Message caption with caption entities formatted as HTML.
        Frc  rO  rP   r;  r   r   r   r   caption_html
  s    zMessage.caption_htmlc                 C   s   | j | j|  ddS )a  Creates an HTML-formatted string from the markup entities found in the message's
        caption.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        HTML. This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as HTML.

        Returns:
            :obj:`str`: Message caption with caption entities formatted as HTML.
        Trc  rg  r   r   r   r   caption_html_urled
  s    zMessage.caption_html_urled   )r<  rS   r=  versionr/  r   c                    s  t |}| d krd S tjdkr(| d} d}d}t| dd d}g }|D ]:\ }	 |krL fdd	|D }
|t|
  |	}t	|	|d
}	|
r|dk rt
dtj||
| j|d}	 jtjkr|dkrڈ j}nt	 j|tjd}d|	 d| d}n jtjkr2 jr2d|	 d jj d}n jtjkrp|rp|dkrV|}n|	}d| d| d}nL jtjkrd|	 d }n. jtjkrd|	 d }n jtjkrdt	||tjd d }n jtjkr.t	||tjd} jr
d j d }n|drd}nd}|| d }n jtjkr\|dkrNt
dd|	 d }n` jtjkr|dkr|t
dd|	 d }n2 jtjkr|dkrt
dd |	 d }n|	}|dkr(tjdkr|t	| | j|  |d
| 7 }n0|t	| |d  j| d  d|d
| 7 }nPtjdkrP|| | j|  | 7 }n(|| |d  j| d  d| 7 } j|  j  }qL|dkrtjdkr|t	| |d  |d
7 }n"|t	| |d d  d|d
7 }n8tjdkr|| |d  7 }n|| |d d  d7 }|S )!Nr)  r*  r>  r   c                 S   s
   | d j S r?  r@  rA  r   r   r   rB    rC  z)Message._parse_markdown.<locals>.<lambda>rD  c                    sB   i | ]:\}}|j  j kr|j |j  j  j kr| kr||qS r   rF  rG  rI  r   r   r8  "  s    z+Message._parse_markdown.<locals>.<dictcomp>)rk  r+  z8Nested entities are not supported for Markdown version 1)r=  r/  rk  rj  )rk  Zentity_type[z]()z](tg://user?id=*_`z```
\z```
z;Underline entities are not supported for Markdown version 1__z?Strikethrough entities are not supported for Markdown version 1~z9Spoiler entities are not supported for Markdown version 1z||)!r   r-  r.  r0  rJ  rK  rL  rM  rN  r.   r   r@   _parse_markdownr/  r   r   rP  rQ  rR  rS  r   rT  rU  rV  rW  rX  rY  
startswithrZ  r[  r\  r1  r   )r<  rS   r=  rk  r/  Zmarkdown_textr]  r^  r_  rI   r`  ra  rQ  rb  r   codeprefixr   rI  r   ru  
  s   


  
    



  
 

zMessage._parse_markdownc                 C   s   | j | j|  ddS )a  Creates an Markdown-formatted string from the markup entities found in the message
        using :class:`telegram.ParseMode.MARKDOWN`.

        Use this if you want to retrieve the message text with the entities formatted as Markdown
        in the same way the original message was formatted.

        Note:
            * :attr:`telegram.ParseMode.MARKDOWN` is a legacy mode, retained by Telegram for
                backward compatibility. You should use :meth:`text_markdown_v2` instead.

            * |custom_emoji_formatting_note|

        Returns:
            :obj:`str`: Message text with entities formatted as Markdown.

        Raises:
            :exc:`ValueError`: If the message contains underline, strikethrough, spoiler or nested
                entities.

        Frc  ru  rI   r:  r   r   r   r   text_markdown  s    zMessage.text_markdownc                 C   s   | j | j|  dddS )a(  Creates an Markdown-formatted string from the markup entities found in the message
        using :class:`telegram.ParseMode.MARKDOWN_V2`.

        Use this if you want to retrieve the message text with the entities formatted as Markdown
        in the same way the original message was formatted.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as Markdown V2.

        Returns:
            :obj:`str`: Message text with entities formatted as Markdown.
        Fr+  r=  rk  ry  r   r   r   r   text_markdown_v2  s    zMessage.text_markdown_v2c                 C   s   | j | j|  ddS )a$  Creates an Markdown-formatted string from the markup entities found in the message
        using :class:`telegram.ParseMode.MARKDOWN`.

        Use this if you want to retrieve the message text with the entities formatted as Markdown.
        This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            * :attr:`telegram.ParseMode.MARKDOWN` is a legacy mode, retained by Telegram for
                backward compatibility. You should use :meth:`text_markdown_v2_urled` instead.

            * |custom_emoji_formatting_note|

        Returns:
            :obj:`str`: Message text with entities formatted as Markdown.

        Raises:
            :exc:`ValueError`: If the message contains underline, strikethrough, spoiler or nested
                entities.

        Trc  ry  r   r   r   r   text_markdown_urled  s    zMessage.text_markdown_urledc                 C   s   | j | j|  dddS )a:  Creates an Markdown-formatted string from the markup entities found in the message
        using :class:`telegram.ParseMode.MARKDOWN_V2`.

        Use this if you want to retrieve the message text with the entities formatted as Markdown.
        This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as Markdown V2.

        Returns:
            :obj:`str`: Message text with entities formatted as Markdown.
        Tr+  r{  ry  r   r   r   r   text_markdown_v2_urled  s    zMessage.text_markdown_v2_urledc                 C   s   | j | j|  ddS )a/  Creates an Markdown-formatted string from the markup entities found in the message's
        caption using :class:`telegram.ParseMode.MARKDOWN`.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        Markdown in the same way the original message was formatted.

        Note:
            * :attr:`telegram.ParseMode.MARKDOWN` is a legacy mode, retained by Telegram for
                backward compatibility. You should use :meth:`caption_markdown_v2` instead.

            * |custom_emoji_formatting_note|

        Returns:
            :obj:`str`: Message caption with caption entities formatted as Markdown.

        Raises:
            :exc:`ValueError`: If the message contains underline, strikethrough, spoiler or nested
                entities.

        Frc  ru  rP   r;  r   r   r   r   caption_markdown  s    zMessage.caption_markdownc                 C   s   | j | j|  dddS )aH  Creates an Markdown-formatted string from the markup entities found in the message's
        caption using :class:`telegram.ParseMode.MARKDOWN_V2`.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        Markdown in the same way the original message was formatted.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as Markdown V2.

        Returns:
            :obj:`str`: Message caption with caption entities formatted as Markdown.
        Fr+  r{  r  r   r   r   r   caption_markdown_v2  s       zMessage.caption_markdown_v2c                 C   s   | j | j|  ddS )aG  Creates an Markdown-formatted string from the markup entities found in the message's
        caption using :class:`telegram.ParseMode.MARKDOWN`.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        Markdown. This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            * :attr:`telegram.ParseMode.MARKDOWN` is a legacy mode, retained by Telegram for
                backward compatibility. You should use :meth:`caption_markdown_v2_urled` instead.

            * |custom_emoji_formatting_note|

        Returns:
            :obj:`str`: Message caption with caption entities formatted as Markdown.

        Raises:
            :exc:`ValueError`: If the message contains underline, strikethrough, spoiler or nested
                entities.

        Trc  r  r   r   r   r   caption_markdown_urled2  s    zMessage.caption_markdown_urledc                 C   s   | j | j|  dddS )aZ  Creates an Markdown-formatted string from the markup entities found in the message's
        caption using :class:`telegram.ParseMode.MARKDOWN_V2`.

        Use this if you want to retrieve the message caption with the caption entities formatted as
        Markdown. This also formats :attr:`telegram.MessageEntity.URL` as a hyperlink.

        Note:
            |custom_emoji_formatting_note|

        .. versionchanged:: 13.10
           Spoiler entities are now formatted as Markdown V2.

        Returns:
            :obj:`str`: Message caption with caption entities formatted as Markdown.
        Tr+  r{  r  r   r   r   r   caption_markdown_v2_urledJ  s       z!Message.caption_markdown_v2_urled)=NNNNNNNNNNNNNNNNNNNNNNNNNNFFFFNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN)N)N)Fr   )Frj  r   )__name__
__module____qualname____doc__	__slots__r   r	   r   r   __annotations__r   r   datetimer   r   r   r   r   r   r   r   r!   r    r   r   r   r   r   r   r   r   r   r   r   r%   r"   r#   r$   r'   r(   r-   r)   r*   r+   r,   r   r   propertyr   r   r   classmethodr3   r   r   r   r   r   r   r1   r5   r6   r&   floatr
   r   r   r   r   r2   r   r4   r   r   r   r   r   r   r   r   r   r   r   ZREGULARr   r   r   r   objectr  r  r  r  r  r  r  r  r  r  r   r!  r$  r%  r&  r'  r   r3  r4  r   r:  r;  staticmethodrO  re  rf  rh  ri  ru  rz  r|  r}  r~  r  r  r  r  __classcell__r   r   r   r   r@   V   sD  
  IF                                                              1C02;79.
4
<
8
<
,
>
4
57;5A,3
^
+
0
:
,
+
'
$
0
&

*
#    
i   
 %r@   )Gr  r  r-  htmlr   typingr   r   r   r   r   r   r	   r
   Ztelegramr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   Ztelegram.utils.helpersr.   r/   r0   r1   r2   Ztelegram.utils.typesr3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   r   r   r   r   <module>   s   (%,