
    {i/                        S r SSKJr  SSKJrJr  SSKJr  SSKJ	r	J
r
  SSKJr  \(       a  SS	Kr " S
 S\5      r " S S\5      r " S S\5      r " S S\5      rg	)zProvide models for new modmail.    )annotations)TYPE_CHECKINGAny   )API_PATH)_deprecate_argssnake_case_keys   )
RedditBaseNc                  8   ^  \ rS rSrSrSrSrSU 4S jjrSrU =r	$ )ModmailObject   z7A base class for objects within a modmail conversation.authoridc                   > XR                   :X  a%  U R                  R                  R                  U5      n[        TU ]  X5        g)z)Objectify the AUTHOR_ATTRIBUTE attribute.N)AUTHOR_ATTRIBUTE_reddit	_objector	objectifysuper__setattr__)self	attributevalue	__class__s      T/home/james-whalen/.local/lib/python3.13/site-packages/praw/models/reddit/modmail.pyr   ModmailObject.__setattr__   s6    ---LL**44U;EI-     )r   strr   r   )
__name__
__module____qualname____firstlineno____doc__r   	STR_FIELDr   __static_attributes____classcell__r   s   @r   r   r      s    AI. .r   r   c                    ^  \ rS rSrSrSr\S S j5       r\S S j5       r\	      S!S j5       r
   S"       S#U 4S	 jjjr    S$S jrU 4S jrS rS rS r\" S5      SS.S%S jj5       r\" S
5      SS.S&S jj5       r\" SSS5      SSS.       S'S jj5       rS rS rS r\" S
5      SS.S&S jj5       rSrU =r$ )(ModmailConversation   a,  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

r   c                    / / S.nU S    H>  nUS   nX   US      nX$   R                  UR                  R                  U5      5        M@     U R                  U5        g)z1Convert messages and mod actions to PRAW objects.)messages
modActionsobjIdskeyr   N)appendr   r   update)dataredditresultthingr1   
thing_datas         r   _convert_conversation_objects1ModmailConversation._convert_conversation_objectsD   sd     !3(^E,C5;/JKv//99*EF $ 	Fr   c           	        UR                   R                  UR                  R                  S      [        UR                   R                  UR                  R                  S      S.nUR                  5        H  u  p4/ nX   R                  5        H`  u  pgU" XR                  SS5      S   S9nU[        La  US	 UR                  5        H  u  p[        XU
5        M     UR                  U5        Mb     [        US	 S
S9X'   M     g)z<Convert dictionaries of recent user history to PRAW objects.comment
submission)recentCommentsrecentConvosrecentPosts_r
   r   	permalinkc                *    [        U R                  SS9$ )N$   )base)intr   )xs    r   <lambda>;ModmailConversation._convert_user_summary.<locals>.<lambda>`   s    s144b7Ir   T)r1   reverseN)
r   parsersconfigkindsr+   itemsrsplitsetattrr2   sorted)r4   r5   rM   kindparserobjectsthing_idsummaryr7   r1   r   s              r   _convert_user_summary)ModmailConversation._convert_user_summaryN   s     %..66v}}7J7J97UV/!++33FMM4G4G4UV

 $MMOLDG%)Z%5%5%7!v//#q*A"*EF!44,")--/JCE. #2u% &8  -ISWXDJ ,r   c                x   US    Vs/ s H  o2R                   R                  U5      PM     snUS'   S H"  nUR                   R                  X   5      X'   M$     UR                  S5      (       a6  U R                  US   U5        UR                   R                  US   5      US'   [	        U5      nU " X!S9$ s  snf )zReturn an instance of :class:`.ModmailConversation` from ``data``.

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

authors)ownerparticipantuser_data)r   r   getrY   r	   )clsr4   r5   r   entitys        r   parseModmailConversation.parseb   s     >B)_
=L6&&v._
Y -F!++55dlCDL - 88F%%d6lF;!++55d6lCDLt$6&&
s   $B7NFc                   > [        U5      [        U5      :X  a  Sn[        U5      eU(       a  X l        [        TU ]  XS9  U(       a
  SS0U l        gSU l        g)zInitialize a :class:`.ModmailConversation` instance.

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

z(Either 'id' or '_data' must be provided.r`   markReadTN)bool	TypeErrorr   r   __init___info_params)r   r5   r   	mark_readra   msgr   s         r   rk   ModmailConversation.__init__|   sR     8tE{"<CC. G-2;Z.r   other_conversationsc                P    U /U=(       d    / -   nSR                  S U 5       5      $ )z2Return a comma-separated list of conversation IDs.,c              3  8   #    U  H  oR                   v   M     g 7fNrC   ).0conversations     r   	<genexpr>?ModmailConversation._build_conversation_list.<locals>.<genexpr>   s     JMLMs   )join)r   rp   conversationss      r   _build_conversation_list,ModmailConversation._build_conversation_list   s+     "5";<xxJMJJJr   c                   > U R                  5       nU R                  R                  R                  U5      nU R                  R                  UR                  5        [        TU ]  5         g rt   )_fetch_datar   r   r   __dict__r3   r   _fetch)r   r4   otherr   s      r   r   ModmailConversation._fetch   sK    !&&006U^^,r   c                8    SSU R                   0U R                  4$ )Nmodmail_conversationr   )r   rl   r   s    r   _fetch_infoModmailConversation._fetch_info   s    %dgg8I8IIIr   c                v    U R                   R                  [        S   R                  U R                  S95        g)zyArchive the conversation.

For example:

.. code-block:: python

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

modmail_archiverC   Nr   postr   formatr   r   s    r   archiveModmailConversation.archive   s.     	(#45<<<HIr   c                v    U R                   R                  [        S   R                  U R                  S95        g)z}Highlight the conversation.

For example:

.. code-block:: python

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

modmail_highlightrC   Nr   r   s    r   	highlightModmailConversation.highlight   .     	(#67>>$''>JKr   num_daysr   )r   c                   US:w  a  SUS-  0O0 nU R                   R                  SU[        S   R                  U R                  S9S9  g)	al  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)

r   	num_hours   POSTmodmail_muterC   )methodparamspathNr   requestr   r   r   )r   r   r   s      r   muteModmailConversation.mute   sQ    ( 2:Q+x"}-B.)00DGG0< 	 	
r   )rp   c               l    SU R                  U5      0nU R                  R                  [        S   US9  g)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_readr4   Nr{   r   r   r   r   rp   r4   s      r   readModmailConversation.read   s6    " "4#@#@AT#UV(>2>r   bodyauthor_hiddeninternal)r   r   c                  UUUS.nU R                   R                  [        S   R                  U R                  S9US9n[        U[        5      (       a;  US   S   S   S   nUS	   U   nU R                   R                  R                  U5      $ UR                   H'  nUR                  UR                  S   S   :X  d  M%  Us  $    g
)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)

)r   isAuthorHidden
isInternalr   rC   r   rv   r0   rB   r   r.   N)r   r   r   r   r   
isinstancedictr   r   r.   obj_ids)	r   r   r   r   r4   response
message_idmessage_datamessages	            r   replyModmailConversation.reply   s    : +"

 <<$$+,33tww3?d % 
 h%%!.1(;B?EJ#J/
;L<<))33LAA((GzzX--b1$77 )r   c                v    U R                   R                  [        S   R                  U R                  S95        g)z}Unarchive the conversation.

For example:

.. code-block:: python

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

modmail_unarchiverC   Nr   r   s    r   	unarchiveModmailConversation.unarchive  r   r   c                v    U R                   R                  [        S   R                  U R                  S95        g)zUn-highlight the conversation.

For example:

.. code-block:: python

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

r   rC   N)r   deleter   r   r   r   s    r   unhighlightModmailConversation.unhighlight$  s.     	H%89@@DGG@LMr   c                t    U R                   R                  S[        S   R                  U R                  S9S9  g)zUnmute the non-mod user associated with the conversation.

For example:

.. code-block:: python

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

r   modmail_unmuterC   )r   r   Nr   r   s    r   unmuteModmailConversation.unmute0  s8     	)9 : A ATWW A M 	 	
r   c               l    SU R                  U5      0nU R                  R                  [        S   US9  g)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   unreadModmailConversation.unread>  s7    " "4#@#@AT#UV(#344@r   )rl   r   )r4   dict[str, Any]r5   praw.Reddit)r4   r   r5   r   returnr+   )NFN)r5   r   r   z
str | Nonerm   ri   ra   zdict[str, Any] | None)rp   zlist[ModmailConversation]r   r    )r   rH   )rp   z list[ModmailConversation] | None)r   ri   r   r    r   ri   r   ModmailMessage)r!   r"   r#   r$   r%   r&   staticmethodr9   rY   classmethodre   rk   r{   r   r   r   r   r   r   r   r   r   r   r   r   r'   r(   r)   s   @r   r+   r+      s   #J I  Y Y& '' ' 
	' '8 '+FF F 	F
 %F F0K#<K	KJ
J
L Z &' 
 !
4 *+NR ? ,?& V_j9',%* $*47*CG*	* :*X
L
N
 *+PT A ,Ar   r+   c                      \ rS rSrSrSrg)ModmailActioniS  z7A class for moderator actions on modmail conversations.r   Nr!   r"   r#   r$   r%   r'   r   r   r   r   r   S  s    Ar   r   c                      \ rS rSrSrSrg)r   iW  zA class for modmail messages.r   Nr   r   r   r   r   r   W  s    'r   r   )r%   
__future__r   typingr   r   constr   utilr   r	   rG   r   prawr   r+   r   r   r   r   r   <module>r      sT    % " %  4 
.J 
.tA* tAn	BM B(] (r   