Ë
    Fü´j00  ã                  ó¬   — d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZ erddlZ G d„ d	e	«      Z G d
„ de	«      Z G d„ de«      Z G d„ de«      Zy)zProvide models for new modmail.é    )Úannotations)ÚTYPE_CHECKINGÚAny)ÚAPI_PATH)Ú
RedditBase)Úsnake_case_keysNc                  ó
  ‡ — e Zd ZdZdZdZedd„«       Zedd„«       Ze		 	 	 	 	 	 dd„«       Z
	 dddd	œ	 	 	 	 	 	 	 	 	 dˆ fd
„Zdd„Zdˆ fd„Zd d„Zdd„Zdd„Zedœd!d„Zddœd"d„Zdddœd#d„Zdd„Zdd„Zdd„Zddœd"d„Zˆ xZS )$ÚModmailConversationa¨  A class for modmail conversations.

    .. include:: ../../typical_attributes.rst

    ==================== ===============================================================
    Attribute            Description
    ==================== ===============================================================
    ``authors``          Provides an ordered list of :class:`.Redditor` instances. The
                         authors of each message in the modmail conversation.
    ``id``               The ID of the :class:`.ModmailConversation`.
    ``is_highlighted``   Whether or not the :class:`.ModmailConversation` is
                         highlighted.
    ``is_internal``      Whether or not the :class:`.ModmailConversation` is a private
                         mod conversation.
    ``last_mod_update``  Time of the last mod message reply, represented in the `ISO
                         8601`_ standard with timezone.
    ``last_updated``     Time of the last message reply, represented in the `ISO 8601`_
                         standard with timezone.
    ``last_user_update`` Time of the last user message reply, represented in the `ISO
                         8601`_ standard with timezone.
    ``num_messages``     The number of messages in the :class:`.ModmailConversation`.
    ``obj_ids``          Provides a list of dictionaries representing mod actions on the
                         :class:`.ModmailConversation`. Each dict contains attributes of
                         ``"key"`` and ``"id"``. The key can be either ``""messages"``
                         or ``"ModAction"``. ``"ModAction"`` represents
                         archiving/highlighting etc.
    ``owner``            Provides an instance of :class:`.Subreddit`. The subreddit that
                         the :class:`.ModmailConversation` belongs to.
    ``participant``      Provides an instance of :class:`.Redditor`. The participating
                         user in the :class:`.ModmailConversation`.
    ``subject``          The subject of the :class:`.ModmailConversation`.
    ==================== ===============================================================

    .. _iso 8601: https://en.wikipedia.org/wiki/ISO_8601

    é   Úidc                óÀ   — g g dœ}| d   D ]@  }|d   }| |   |d      }||   j                  |j                  j                  |¬«      «       ŒB | j                  |«       y)z1Convert messages and mod actions to PRAW objects.)ÚmessagesÚ
modActionsÚobjIdsÚkeyr   ©ÚdataN)ÚappendÚ	_objectorÚ	objectifyÚupdate)r   ÚredditÚresultÚthingr   Ú
thing_datas         úX/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/modmail.pyÚ_convert_conversation_objectsz1ModmailConversation._convert_conversation_objects8   sr   € ð !°Ñ3ˆØ˜(‘^ò 	LˆEØ˜‘,ˆCØ˜c™ 5¨¡;Ñ/ˆJØ�3‰K×Ñ˜v×/Ñ/×9Ñ9¸zÐ9ÓJÕKð	Lð 	�‰�FÕó    c           	     ó  — |j                   j                  |j                  j                  d      t        |j                   j                  |j                  j                  d      dœ}|j                  «       D ]’  \  }}g }| |   j                  «       D ]c  \  }} |||j                  dd«      d   ¬«      }|t        ur|d= |j                  «       D ]  \  }	}
t        ||	|
«       Œ |j                  |«       Œe t        |d	„ d
¬«      | |<   Œ” y)z<Convert dictionaries of recent user history to PRAW objects.ÚcommentÚ
submission)ÚrecentCommentsÚrecentConvosÚrecentPostsÚ_é   éÿÿÿÿ©r   Ú	permalinkc                ó0   — t        | j                  d¬«      S )Né$   )Úbase)Úintr   )Úxs    r   ú<lambda>z;ModmailConversation._convert_user_summary.<locals>.<lambda>T   s   € ´s¸1¿4¹4ÀbÔ7I€ r   T)r   ÚreverseN)
r   ÚparsersÚconfigÚkindsr
   ÚitemsÚrsplitÚsetattrr   Úsorted)r   r   r1   ÚkindÚparserÚobjectsÚthing_idÚsummaryr   r   Úvalues              r   Ú_convert_user_summaryz)ModmailConversation._convert_user_summaryB   s  € ð %×.Ñ.×6Ñ6°v·}±}×7JÑ7JÈ9Ñ7UÑVÜ/Ø!×+Ñ+×3Ñ3°F·M±M×4GÑ4GÈÑ4UÑVñ
ˆð
 $ŸM™M›Oò 
	Y‰LˆD�&ØˆGØ%)¨$¡Z×%5Ñ%5Ó%7ò &Ñ!�˜'Ù˜v¨(¯/©/¸#¸qÓ*AÀ"Ñ*EÔF�ØÔ!4Ñ4Ø Ð,Ø")§-¡-£/ò /‘J�C˜Ü˜E 3¨Õ.ð/à—‘˜uÕ%ð&ô   Ñ-IÐSWÔXˆD�ŠJñ
	Yr   c                óx  — |d   D �cg c]  }|j                   j                  |¬«      ‘Œ  c}|d<   dD ]$  }|j                   j                  ||   ¬«      ||<   Œ& |j                  d«      r7| j                  |d   |«       |j                   j                  |d   ¬«      |d<   t	        |«      } | ||¬«      S c c}w )z¯Return an instance of :class:`.ModmailConversation` from ``data``.

        :param data: The structured data.
        :param reddit: An instance of :class:`.Reddit`.

        Úauthorsr   )ÚownerÚparticipantÚuser©Ú_data)r   r   Úgetr>   r   )Úclsr   r   ÚauthorÚentitys        r   ÚparsezModmailConversation.parseV   sÆ   € ð RVÐV_ÑQ`ÖaÀv˜6×+Ñ+×5Ñ5¸6Ð5ÕBÒaˆˆY‰Ø,ò 	IˆFØ!×+Ñ+×5Ñ5¸4À¹<Ð5ÓHˆD�ŠLð	Ið �8‰8�FÔØ×%Ñ% d¨6¡l°FÔ;Ø!×+Ñ+×5Ñ5¸4À¹<Ð5ÓHˆD�‰Lä˜tÓ$ˆá�6 Ô&Ð&ùò bs   ˆ#B7NF)rE   Ú	mark_readc               ó¨   •— t        |«      t        |«      k(  rd}t        |«      ‚|r|| _        t        ‰| �  ||¬«       |r
ddi| _        yd| _        y)z§Initialize a :class:`.ModmailConversation` instance.

        :param mark_read: If ``True``, conversation is marked as read (default:
            ``False``).

        z(Either 'id' or '_data' must be provided.rD   ÚmarkReadTN)ÚboolÚ	TypeErrorr   ÚsuperÚ__init__Ú_info_params)Úselfr   r   rE   rK   ÚmsgÚ	__class__s         €r   rQ   zModmailConversation.__init__n   sV   ø€ ô �‹8”t˜E“{Ò"Ø<ˆCÜ˜C“.Ð áØˆDŒGä‰Ñ˜ uÐÔ-á2;˜Z¨Ð.ˆÕÀˆÕr   c                óF   — | g|xs g z   }dj                  d„ |D «       «      S )z2Return a comma-separated list of conversation IDs.ú,c              3  ó4   K  — | ]  }|j                   –— Œ y ­w©Nr(   )Ú.0Úconversations     r   ú	<genexpr>z?ModmailConversation._build_conversation_list.<locals>.<genexpr>Š   s   è ø€ ÒJ¨L˜Ÿ�ÑJùs   ‚)Újoin)rS   Úother_conversationsÚconversationss      r   Ú_build_conversation_listz,ModmailConversation._build_conversation_list‡   s)   € à˜Ð"5Ò";¸Ñ<ˆØ�x‰xÑJ¸MÔJÓJÐJr   c                óØ   •— | j                  «       }| j                  j                  j                  |¬«      }| j                  j                  |j                  «       t        ‰| �  «        y )Nr   )Ú_fetch_dataÚ_redditr   r   Ú__dict__r   rP   Ú_fetch)rS   r   ÚotherrU   s      €r   re   zModmailConversation._fetchŒ   sN   ø€ Ø×ÑÓ!ˆØ—‘×&Ñ&×0Ñ0°dÐ0Ó;ˆØ�‰×Ñ˜UŸ^™^Ô,Ü‰‰Õr   c                ó8   — dd| j                   i| j                  fS )NÚmodmail_conversationr   )r   rR   ©rS   s    r   Ú_fetch_infozModmailConversation._fetch_info’   s   € Ø%¨¨d¯g©g ¸×8IÑ8IÐIÐIr   c                ó|   — | j                   j                  t        d   j                  | j                  ¬«      «       y)z™Archive the conversation.

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").archive()

        Úmodmail_archiver(   N©rc   Úpostr   Úformatr   ri   s    r   ÚarchivezModmailConversation.archive•   s.   € ð 	�‰×Ñœ(Ð#4Ñ5×<Ñ<ÀÇÁÐ<ÓHÕIr   c                ó|   — | j                   j                  t        d   j                  | j                  ¬«      «       y)z�Highlight the conversation.

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").highlight()

        Úmodmail_highlightr(   Nrm   ri   s    r   Ú	highlightzModmailConversation.highlight¡   ó.   € ð 	�‰×Ñœ(Ð#6Ñ7×>Ñ>À$Ç'Á'Ð>ÓJÕKr   )Únum_daysc               ó²   — || j                   k7  rd|dz  ini }| j                  j                  d|t        d   j	                  | j
                  ¬«      ¬«       y)a´  Mute the non-mod user associated with the conversation.

        :param num_days: Duration of mute in days. Valid options are ``3``, ``7``, or
            ``28`` (default: ``3``).

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").mute()

        To mute for 7 days:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").mute(num_days=7)

        Ú	num_hoursé   ÚPOSTÚmodmail_muter(   )ÚmethodÚparamsÚpathN)ÚDEFAULT_NUMBER_OF_MUTE_DAYSrc   Úrequestr   ro   r   )rS   ru   r|   s      r   ÚmutezModmailConversation.mute­   s^   € ð( -5¸×8XÑ8XÒ,Xˆ[˜( R™-Ñ(Ð^`ð 	ð 	�‰×ÑØØÜ˜.Ñ)×0Ñ0°D·G±GÐ0Ó<ð 	õ 	
r   )r^   c               ór   — d| j                  |«      i}| j                  j                  t        d   |¬«       y)a÷  Mark the conversation(s) as read.

        :param other_conversations: A list of other conversations to mark (default:
            ``None``).

        For example, to mark the conversation as read along with other recent
        conversations from the same user:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            conversation = subreddit.modmail.conversation("2gmz")
            conversation.read(other_conversations=conversation.user.recent_convos)

        ÚconversationIdsÚmodmail_readr   N©r`   rc   rn   r   ©rS   r^   r   s      r   ÚreadzModmailConversation.readÉ   s6   € ð  " 4×#@Ñ#@ÐATÓ#UÐVˆØ�‰×Ñœ( >Ñ2¸ÐÕ>r   )Úauthor_hiddenÚinternalc               óˆ  ‡— |||dœ}| j                   j                  t        d   j                  | j                  ¬«      |¬«      Št        ‰t        «      rP‰d   d   d   d   }‰d	   |   }| j                   j                  j                  |¬«      }t        |t        «      sJ ‚|S t        ˆfd
„‰j                  D «       «      S )a[  Reply to the conversation.

        :param author_hidden: When ``True``, author is hidden from non-moderators
            (default: ``False``).
        :param body: The Markdown formatted content for a message.
        :param internal: When ``True``, message is a private moderator note, hidden from
            non-moderators (default: ``False``).

        :returns: A :class:`.ModmailMessage` object for the newly created message.

        For example, to reply to the non-mod user while hiding your username:

        .. code-block:: python

            conversation = reddit.subreddit("test").modmail("2gmz")
            conversation.reply(body="Message body", author_hidden=True)

        To create a private moderator note on the conversation:

        .. code-block:: python

            conversation.reply(body="Message body", internal=True)

        )ÚbodyÚisAuthorHiddenÚ
isInternalrh   r(   r   r[   r   r'   r   r   c              3  ób   •K  — | ]&  }|j                   ‰j                  d    d   k(  sŒ#|–— Œ( y­w)r'   r   N)r   Úobj_ids)rZ   ÚmessageÚresponses     €r   r\   z,ModmailConversation.reply.<locals>.<genexpr>  s.   øè ø€ Òi ÀÇ
Á
Èh×N^ÑN^Ð_aÑNbÐcgÑNhÓ@h”GÑiùs   ƒ$/¨/)rc   rn   r   ro   r   Ú
isinstanceÚdictr   r   ÚModmailMessageÚnextr   )	rS   r‡   rŠ   rˆ   r   Ú
message_idÚmessage_datar�   r�   s	           @r   ÚreplyzModmailConversation.replyÜ   sÇ   ø€ ð4 Ø+Ø"ñ
ˆð
 —<‘<×$Ñ$¤XÐ.DÑ%E×%LÑ%LÐPT×PWÑPWÐ%LÓ%XÐ_cÐ$ÓdˆÜ�h¤Ô%à! .Ñ1°(Ñ;¸BÑ?ÀÑEˆJØ# JÑ/°
Ñ;ˆLØ—l‘l×,Ñ,×6Ñ6¸LÐ6ÓIˆGÜ˜g¤~Ô6Ð6Ð6ØˆNÜÓi¨8×+<Ñ+<ÔiÓiÐir   c                ó|   — | j                   j                  t        d   j                  | j                  ¬«      «       y)z�Unarchive the conversation.

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").unarchive()

        Úmodmail_unarchiver(   Nrm   ri   s    r   Ú	unarchivezModmailConversation.unarchive  rt   r   c                ó|   — | j                   j                  t        d   j                  | j                  ¬«      «       y)z¢Un-highlight the conversation.

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").unhighlight()

        rr   r(   N)rc   Údeleter   ro   r   ri   s    r   ÚunhighlightzModmailConversation.unhighlight  s.   € ð 	�‰×ÑœHÐ%8Ñ9×@Ñ@ÀDÇGÁGÐ@ÓLÕMr   c                ó€   — | j                   j                  dt        d   j                  | j                  ¬«      ¬«       y)z¸Unmute the non-mod user associated with the conversation.

        For example:

        .. code-block:: python

            reddit.subreddit("test").modmail("2gmz").unmute()

        ry   Úmodmail_unmuter(   )r{   r}   N)rc   r   r   ro   r   ri   s    r   ÚunmutezModmailConversation.unmute  s6   € ð 	�‰×Ñ F´Ð:JÑ1K×1RÑ1RÐVZ×V]ÑV]Ð1RÓ1^ÐÕ_r   c               ór   — d| j                  |«      i}| j                  j                  t        d   |¬«       y)aý  Mark the conversation(s) as unread.

        :param other_conversations: A list of other conversations to mark (default:
            ``None``).

        For example, to mark the conversation as unread along with other recent
        conversations from the same user:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            conversation = subreddit.modmail.conversation("2gmz")
            conversation.unread(other_conversations=conversation.user.recent_convos)

        r‚   Úmodmail_unreadr   Nr„   r…   s      r   ÚunreadzModmailConversation.unread(  s7   € ð  " 4×#@Ñ#@ÐATÓ#UÐVˆØ�‰×Ñœ(Ð#3Ñ4¸4ÐÕ@r   )r   údict[str, Any]r   úpraw.RedditÚreturnÚNone)r   r¤   r   r¥   r¦   r
   rY   )
r   r¥   r   z
str | NonerE   zdict[str, Any] | NonerK   rN   r¦   r§   )r^   ú list[ModmailConversation] | Noner¦   Ústr)r¦   r§   )r¦   z2tuple[str, dict[str, str], dict[str, bool] | None])ru   r-   r¦   r§   )r^   r¨   r¦   r§   )r‡   rN   rŠ   r©   rˆ   rN   r¦   r“   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r~   Ú	STR_FIELDÚstaticmethodr   r>   ÚclassmethodrJ   rQ   r`   re   rj   rp   rs   r€   r†   r—   rš   r�   r    r£   Ú__classcell__©rU   s   @r   r
   r
      s$  ø„ ñ#ðJ #$ÐØ€Iàòó ðð òYó ðYð& ð'àð'ð ð'ð 
ò	'ó ð'ð4 ðFð
 (,ØñFàðFð ðFð
 %ðFð ðFð 
õFó2Kõ
óJó
Jó
Lð 'Bõ 
ð8 OSõ ?ð& .3ÐPUõ &jóP
Ló
Nó
`ð QU÷ Añ Ar   r
   c                  ó,   ‡ — e Zd ZdZdZdZdˆ fd„Zˆ xZS )ÚModmailObjectz7A base class for objects within a modmail conversation.rH   r   c                ó�   •— || j                   k(  r&| j                  j                  j                  |¬«      }t        ‰| �  ||«       y)z)Objectify the AUTHOR_ATTRIBUTE attribute.r   N)ÚAUTHOR_ATTRIBUTErc   r   r   rP   Ú__setattr__)rS   Ú	attributer=   rU   s      €r   r·   zModmailObject.__setattr__B  s=   ø€ à˜×-Ñ-Ò-Ø—L‘L×*Ñ*×4Ñ4¸%Ð4Ó@ˆEÜ‰Ñ˜I uÕ-r   )r¸   r©   r=   r   r¦   r§   )rª   r«   r¬   r­   r¶   r®   r·   r±   r²   s   @r   r´   r´   <  s   ø„ ÙAàÐØ€I÷.ñ .r   r´   c                  ó   — e Zd ZdZy)ÚModmailActionz7A class for moderator actions on modmail conversations.N©rª   r«   r¬   r­   © r   r   rº   rº   I  s   „ ÚAr   rº   c                  ó   — e Zd ZdZy)r“   zA class for modmail messages.Nr»   r¼   r   r   r“   r“   M  s   „ Ú'r   r“   )r­   Ú
__future__r   Útypingr   r   Ú
praw.constr   Úpraw.models.reddit.baser   Ú	praw.utilr   Úprawr
   r´   rº   r“   r¼   r   r   ú<module>rÄ      sT   ðÙ %å "ç %å Ý .Ý %áÛôjA˜*ô jAôZ	
.�Jô 
.ôB�Mô Bô(�]õ (r   