o
    2g_*                     @  s|   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 dd	lmZ dd
lmZ er4ddlZG dd deZdS )zProvide the Front class.    )annotations)TYPE_CHECKINGIterator   )API_PATH)_deprecate_args   )PRAWBase)ListingGenerator)stream_generatorNc                   @  s   e Zd ZdZd1ddZd2d
dZd3ddZdd Zd4ddZd4ddZ	d3ddZ
d5ddZd6ddZd6d d!Zd7d$d%Zd3d&d'Zd2d(d)Zed*d+d,d8d.d/Zd0S )9Inboxz3Inbox is a Listing class that represents the inbox.generator_kwargsstr | int | dict[str, str]return3Iterator[praw.models.Message | praw.models.Comment]c                 K     t | jtd fi |S )a  Return a :class:`.ListingGenerator` for all inbox comments and messages.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        To output the type and ID of all items available via this listing do:

        .. code-block:: python

            for item in reddit.inbox.all(limit=None):
                print(repr(item))

        inboxr
   _redditr   selfr    r   I/home/garg/my-data/venv/lib/python3.10/site-packages/praw/models/inbox.pyall      z	Inbox.allitemslist[praw.models.Message]c                 C  P   |r&dd dd |dd D i}| jjtd |d |dd }|sdS dS )	ae  Mark an inbox message as collapsed.

        :param items: A list containing instances of :class:`.Message`.

        Requests are batched at 25 items (reddit limit).

        For example, to collapse all unread Messages, try:

        .. code-block:: python

            from praw.models import Message

            unread_messages = []
            for item in reddit.inbox.unread(limit=None):
                if isinstance(item, Message):
                    unread_messages.append(item)
            reddit.inbox.collapse(unread_messages)

        .. seealso::

            :meth:`.Message.uncollapse`

        id,c                 s      | ]}|j V  qd S Nfullname.0xr   r   r   	<genexpr>?       z!Inbox.collapse.<locals>.<genexpr>N   collapsedatajoinr   postr   r   r   r,   r   r   r   r*   &   
    zInbox.collapseIterator[praw.models.Comment]c                 K  r   )ay  Return a :class:`.ListingGenerator` for comment replies.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        To output the author of one request worth of comment replies try:

        .. code-block:: python

            for reply in reddit.inbox.comment_replies():
                print(reply.author)

        comment_repliesr   r   r   r   r   r3   C   
   
zInbox.comment_repliesc                 C  s   | j td  dS )a6  Mark all messages as read with just one API call.

        Example usage:

        .. code-block:: python

            reddit.inbox.mark_all_read()

        .. note::

            This method returns after Reddit acknowledges your request, instead of after
            the request has been fulfilled.

        read_all_messagesN)r   r/   r   )r   r   r   r   mark_all_readW   s   zInbox.mark_all_read/list[praw.models.Comment | praw.models.Message]c                 C  r   )	a  Mark Comments or Messages as read.

        :param items: A list containing instances of :class:`.Comment` and/or
            :class:`.Message` to be marked as read relative to the authorized user's
            inbox.

        Requests are batched at 25 items (reddit limit).

        For example, to mark all unread Messages as read, try:

        .. code-block:: python

            from praw.models import Message

            unread_messages = []
            for item in reddit.inbox.unread(limit=None):
                if isinstance(item, Message):
                    unread_messages.append(item)
            reddit.inbox.mark_read(unread_messages)

        .. seealso::

            - :meth:`.Comment.mark_read`
            - :meth:`.Message.mark_read`

        r   r   c                 s  r    r!   r"   r$   r   r   r   r'      r(   z"Inbox.mark_read.<locals>.<genexpr>Nr)   read_messager+   r-   r0   r   r   r   	mark_readh   s
    zInbox.mark_readc                 C  r   )	aX  Unmark Comments or Messages as read.

        :param items: A list containing instances of :class:`.Comment` and/or
            :class:`.Message` to be marked as unread relative to the authorized user's
            inbox.

        Requests are batched at 25 items (Reddit limit).

        For example, to mark the first 10 items as unread try:

        .. code-block:: python

            to_unread = list(reddit.inbox.all(limit=10))
            reddit.inbox.mark_unread(to_unread)

        .. seealso::

            - :meth:`.Comment.mark_unread`
            - :meth:`.Message.mark_unread`

        r   r   c                 s  r    r!   r"   r$   r   r   r   r'      r(   z$Inbox.mark_unread.<locals>.<genexpr>Nr)   unread_messager+   r-   r0   r   r   r   mark_unread   s
    zInbox.mark_unreadc                 K  r   )a
  Return a :class:`.ListingGenerator` for mentions.

        A mention is :class:`.Comment` in which the authorized redditor is named in its
        body like u/spez.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        For example, to output the author and body of the first 25 mentions try:

        .. code-block:: python

            for mention in reddit.inbox.mentions(limit=25):
                print(f"{mention.author}\\n{mention.body}\\n")

        mentionsr   r   r   r   r   r<      s   zInbox.mentions
message_idstrpraw.models.Messagec                 C  sj   | j td j|d}dd |d g|d j D }| D ]\}}||jd|_q|d|   S )zReturn a :class:`.Message` corresponding to ``message_id``.

        :param message_id: The base36 ID of a message.

        For example:

        .. code-block:: python

            message = reddit.inbox.message("7bnlgu")

        message)r   c                 S  s   i | ]}|j |qS r   r"   )r%   r@   r   r   r   
<dictcomp>   s    z!Inbox.message.<locals>.<dictcomp>r   Nt4_)	r   getr   formatrepliesr   	parent_idparentlower)r   r=   listingmessages	_fullnamer@   r   r   r   r@      s   zInbox.messageIterator[praw.models.Message]c                 K  r   )a  Return a :class:`.ListingGenerator` for inbox messages.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        For example, to output the subject of the most recent 5 messages try:

        .. code-block:: python

            for message in reddit.inbox.messages(limit=5):
                print(message.subject)

        rJ   r   r   r   r   r   rJ      r   zInbox.messagesc                 K  r   )a}  Return a :class:`.ListingGenerator` for sent messages.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        For example, to output the recipient of the most recent 15 messages try:

        .. code-block:: python

            for message in reddit.inbox.sent(limit=15):
                print(message.dest)

        sentr   r   r   r   r   rM      r   z
Inbox.sentstream_options3Iterator[praw.models.Comment | praw.models.Message]c                 K  s   t | jfi |S )a  Yield new inbox items as they become available.

        Items are yielded oldest first. Up to 100 historical items will initially be
        returned.

        Keyword arguments are passed to :func:`.stream_generator`.

        For example, to retrieve all new inbox items, try:

        .. code-block:: python

            for item in reddit.inbox.stream():
                print(item)

        )r   unread)r   rN   r   r   r   stream   s   zInbox.streamc                 K  r   )a  Return a :class:`.ListingGenerator` for submission replies.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        To output the author of one request worth of submission replies try:

        .. code-block:: python

            for reply in reddit.inbox.submission_replies():
                print(reply.author)

        submission_repliesr   r   r   r   r   rR     r4   zInbox.submission_repliesc                 C  r   )	ai  Mark an inbox message as uncollapsed.

        :param items: A list containing instances of :class:`.Message`.

        Requests are batched at 25 items (reddit limit).

        For example, to uncollapse all unread Messages, try:

        .. code-block:: python

            from praw.models import Message

            unread_messages = []
            for item in reddit.inbox.unread(limit=None):
                if isinstance(item, Message):
                    unread_messages.append(item)
            reddit.inbox.uncollapse(unread_messages)

        .. seealso::

            :meth:`.Message.collapse`

        r   r   c                 s  r    r!   r"   r$   r   r   r   r'   1  r(   z#Inbox.uncollapse.<locals>.<genexpr>Nr)   
uncollapser+   r-   r0   r   r   r   rS     r1   zInbox.uncollapser9   F)r9   boolc                K  s(   | j |d|d t| jtd fi |S )a  Return a :class:`.ListingGenerator` for unread comments and messages.

        :param mark_read: Marks the inbox as read (default: ``False``).

        .. note::

            This only marks the inbox as read not the messages. Use
            :meth:`.Inbox.mark_read` to mark the messages.

        Additional keyword arguments are passed in the initialization of
        :class:`.ListingGenerator`.

        For example, to output the author of unread comments try:

        .. code-block:: python

            from praw.models import Comment

            for item in reddit.inbox.unread(limit=None):
                if isinstance(item, Comment):
                    print(item.author)

        params)	argumentskeymarkrP   )_safely_add_argumentsr
   r   r   )r   r9   r   r   r   r   rP   5  s   zInbox.unreadN)r   r   r   r   )r   r   )r   r   r   r2   )r   r7   )r=   r>   r   r?   )r   r   r   rL   )rN   r   r   rO   )r9   rT   r   r   r   rO   )__name__
__module____qualname____doc__r   r*   r3   r6   r9   r;   r<   r@   rJ   rM   rQ   rR   rS   r   rP   r   r   r   r   r      s$    




 






r   )r]   
__future__r   typingr   r   constr   utilr   baser	   listing.generatorr
   r   praw.modelsprawr   r   r   r   r   <module>   s    