Ë
    Fü´j@  ã                  ó
  — d Z ddlmZ ddlmZ ddlmZ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 dd
lmZmZ erddlmZ ddlmZ  G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Z G d„ de«      Zy)zProvide the helper classes.é    )Úannotations)Údumps)ÚTYPE_CHECKINGÚAnyÚoverload)ÚAPI_PATH)ÚPRAWBase)ÚListingGenerator)ÚDraft)Ú
LiveThread)ÚMultiredditÚ	Subreddit)ÚIterator)Úmodelsc                  ó0   — e Zd ZdZdd„Zdd„Zd	d„Zdd„Zy)
ÚAnnouncementHelperzßProvide a set of functions to interact with :class:`.Announcement`\ s.

    .. note::

        The methods provided by this class will only work on the currently authenticated
        user's :class:`.Announcement`\ s.

    c                ó‚   — |j                  d|j                  dd«      «       t        | j                  t        d   fi |¤ŽS )ad  Return a :class:`.ListingGenerator` for the authenticated user's announcements.

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

        Example usage:

        .. code-block:: python

            for announcement in reddit.announcements():
                print(announcement.subject)

        Úrequest_limitÚlimitéd   Úannouncements)Ú
setdefaultÚgetr
   Ú_redditr   )ÚselfÚgenerator_kwargss     úQ/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/helpers.pyÚ__call__zAnnouncementHelper.__call__   s?   € ð$ 	×#Ñ# OÐ5E×5IÑ5IÈ'ÐSVÓ5WÔXÜ §¡¬h°Ñ.GÑ\ÐK[Ñ\Ð\ó    c                óœ   — |rJdj                  d„ |dd D «       «      }| j                  j                  t        d   d|i¬«       |dd }|rŒIyy)a«  Hide :class:`.Announcement`\ s.

        :param announcements: A list of :class:`.Announcement` instances to hide.

        Requests are batched at 100 items (Reddit limit).

        For example, to hide every announcement:

        .. code-block:: python

            reddit.announcements.hide(list(reddit.announcements()))

        .. seealso::

            :meth:`.Announcement.hide` to hide a single announcement.

        ú,c              3  ó4   K  — | ]  }|j                   –— Œ y ­w©N©Úfullname©Ú.0Úannouncements     r   ú	<genexpr>z*AnnouncementHelper.hide.<locals>.<genexpr>G   ó   è ø€ ÒY°\˜<×0Õ0ÑYùó   ‚Nr   Úhide_announcementsÚids©Údata©Újoinr   Úpostr   ©r   r   r-   s      r   ÚhidezAnnouncementHelper.hide4   sV   € ñ$ Ø—(‘(ÑYÀ]ÐSWÐTWÐEXÔYÓYˆCØ�L‰L×ÑœhÐ';Ñ<ÀEÈ3À<ÐÔPØ)¨#¨$Ð/ˆMô r   c                óH   — | j                   j                  t        d   «       y)zªMark all announcements as read with just one API call.

        Example usage:

        .. code-block:: python

            reddit.announcements.mark_all_read()

        Úread_all_announcementsN©r   r2   r   ©r   s    r   Úmark_all_readz AnnouncementHelper.mark_all_readK   s   € ð 	�‰×Ñœ(Ð#;Ñ<Õ=r   c                óœ   — |rJdj                  d„ |dd D «       «      }| j                  j                  t        d   d|i¬«       |dd }|rŒIyy)a‹  Mark :class:`.Announcement`\ s as read.

        :param announcements: A list of :class:`.Announcement` instances to mark as
            read.

        Requests are batched at 100 items (Reddit limit).

        For example, to mark every unread announcement as read:

        .. code-block:: python

            unread = [a for a in reddit.announcements() if a.read_at is None]
            reddit.announcements.mark_read(unread)

        .. seealso::

            - :meth:`.Announcement.mark_read` to mark a single announcement as read.
            - :meth:`.AnnouncementHelper.mark_all_read` to mark all announcements as
              read.

        r!   c              3  ó4   K  — | ]  }|j                   –— Œ y ­wr#   r$   r&   s     r   r)   z/AnnouncementHelper.mark_read.<locals>.<genexpr>n   r*   r+   Nr   Úread_announcementsr-   r.   r0   r3   s      r   Ú	mark_readzAnnouncementHelper.mark_readW   sV   € ñ, Ø—(‘(ÑYÀ]ÐSWÐTWÐEXÔYÓYˆCØ�L‰L×ÑœhÐ';Ñ<ÀEÈ3À<ÐÔPØ)¨#¨$Ð/ˆMô r   N)r   r   ÚreturnzIterator[models.Announcement])r   zlist[models.Announcement]r>   ÚNone)r>   r?   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r4   r9   r=   © r   r   r   r      s   „ ñó]ó*0ó.
>ô0r   r   c                  óœ   — e Zd ZdZeddd„«       Zedd„«       Zddd„Zdd„Zdddddddddddd	œ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 dd
„Zy)ÚDraftHelperzØProvide a set of functions to interact with :class:`.Draft` instances.

    .. note::

        The methods provided by this class will only work on the currently authenticated
        user's :class:`.Draft`\ s.

    Nc                 ó   — y r#   rD   ©r   Údraft_ids     r   r   zDraftHelper.__call__}   s   € ØEHr   c                 ó   — y r#   rD   rH   s     r   r   zDraftHelper.__call__€   s   € Ø7:r   c                óT   — |�t        | j                  |¬«      S | j                  «       S )aÐ  Return a list of :class:`.Draft` instances.

        :param draft_id: When provided, this returns a :class:`.Draft` instance
            (default: ``None``).

        :returns: A :class:`.Draft` instance if ``draft_id`` is provided. Otherwise, a
            list of :class:`.Draft` objects.

        .. note::

            Drafts fetched using a specific draft ID are lazily loaded, so you might
            have to access an attribute to get all the expected attributes.

        This method can be used to fetch a specific draft by ID, like so:

        .. code-block:: python

            draft_id = "124862bc-e1e9-11eb-aa4f-e68667a77cbb"
            draft = reddit.drafts(draft_id)
            print(draft)

        ©Úid)r   r   Ú_draft_listrH   s     r   r   zDraftHelper.__call__ƒ   s*   € ð. ÐÜ˜Ÿ™¨(Ô3Ð3Ø×ÑÓ!Ð!r   c                óN   — | j                   j                  t        d   ddi¬«      S )zjGet a list of :class:`.Draft` instances.

        :returns: A list of :class:`.Draft` instances.

        ÚdraftsÚmd_bodyT©Úparams©r   r   r   r8   s    r   rN   zDraftHelper._draft_listž   s(   € ð �|‰|×Ñ¤¨Ñ 2¸IÀtÐ;LÐÓMÐMr   FT©Úflair_idÚ
flair_textÚis_public_linkÚnsfwÚoriginal_contentÚselftextÚsend_repliesÚspoilerÚ	subredditÚtitleÚurlc               ó  — |r|rd}t        |«      ‚t        |	t        «      r| j                  j	                  |	«      }	t        j                  d|||||||||	|
|dœ|¤Ž}| j                  j                  t        d   |¬«      S )aa  Create a new :class:`.Draft`.

        :param flair_id: The flair template to select (default: ``None``).
        :param flair_text: If the template's ``flair_text_editable`` value is ``True``,
            this value will set a custom text (default: ``None``). ``flair_id`` is
            required when ``flair_text`` is provided.
        :param is_public_link: Whether to enable public viewing of the draft before it
            is submitted (default: ``False``).
        :param nsfw: Whether the draft should be marked NSFW (default: ``False``).
        :param original_content: Whether the submission should be marked as original
            content (default: ``False``).
        :param selftext: The Markdown formatted content for a text submission draft. Use
            ``None`` to make a title-only submission draft (default: ``None``).
            ``selftext`` can not be provided if ``url`` is provided.
        :param send_replies: When ``True``, messages will be sent to the submission
            author when comments are made to the submission (default: ``True``).
        :param spoiler: Whether the submission should be marked as a spoiler (default:
            ``False``).
        :param subreddit: The subreddit to create the draft for. This accepts a
            subreddit display name, :class:`.Subreddit` object, or
            :class:`.UserSubreddit` object. If ``None``, the :class:`.UserSubreddit` of
            currently authenticated user will be used (default: ``None``).
        :param title: The title of the draft (default: ``None``).
        :param url: The URL for a ``link`` submission draft (default: ``None``). ``url``
            can not be provided if ``selftext`` is provided.

        Additional keyword arguments can be provided to handle new parameters as Reddit
        introduces them.

        :returns: The new :class:`.Draft` object.

        z4Exactly one of 'selftext' or 'url' must be provided.rU   Údraftr.   rD   )	Ú	TypeErrorÚ
isinstanceÚstrr   r^   r   Ú_prepare_datar2   r   )r   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   Údraft_kwargsÚmsgr/   s                  r   ÚcreatezDraftHelper.create¦   s˜   € ñ` ™ØHˆCÜ˜C“.Ð Ü�i¤Ô%ØŸ™×.Ñ.¨yÓ9ˆIä×"Ñ"ð 
ØØ!Ø)ØØ-ØØ%ØØØØñ
ð ñ
ˆð �|‰|× Ñ ¤¨'Ñ!2¸Ð Ó>Ð>r   r#   )rI   r?   r>   úlist[models.Draft])rI   re   r>   úmodels.Draft)rI   ú
str | Noner>   z!list[models.Draft] | models.Draft)r>   rj   )rV   rl   rW   rl   rX   ÚboolrY   rm   rZ   rm   r[   rl   r\   rm   r]   rm   r^   z4str | models.Subreddit | models.UserSubreddit | Noner_   rl   r`   rl   rg   r   r>   rk   )r@   rA   rB   rC   r   r   rN   ri   rD   r   r   rF   rF   s   sé   „ ñð ÛHó ØHàÚ:ó Ø:ô"ó6Nð  $Ø!%Ø$ØØ!&Ø#Ø!ØØLPØ ØñD?ð ðD?ð ð	D?ð
 ðD?ð ðD?ð ðD?ð ðD?ð ðD?ð ðD?ð IðD?ð ðD?ð ðD?ð ðD?ð 
ôD?r   rF   c                  óL   — e Zd ZdZd	d„Zddddœ	 	 	 	 	 	 	 	 	 d
d„Zdd„Zdd„Zy)Ú
LiveHelperzDProvide a set of functions to interact with :class:`.LiveThread`\ s.c                ó0   — t        | j                  |¬«      S )a  Return a new lazy instance of :class:`.LiveThread`.

        This method is intended to be used as:

        .. code-block:: python

            livethread = reddit.live("ukaeu1ik4sw5")

        :param id: A live thread ID, e.g., ``ukaeu1ik4sw5``.

        rL   )r   r   )r   rM   s     r   r   zLiveHelper.__call__ð   s   € ô ˜$Ÿ,™,¨2Ô.Ð.r   NF)ÚdescriptionrY   Ú	resourcesc               óT   — | j                   j                  t        d   ||||dœ¬«      S )aÉ  Create a new :class:`.LiveThread`.

        :param title: The title of the new :class:`.LiveThread`.
        :param description: The new :class:`.LiveThread`'s description.
        :param nsfw: Indicate whether this thread is not safe for work (default:
            ``False``).
        :param resources: Markdown formatted information that is useful for the
            :class:`.LiveThread`.

        :returns: The new :class:`.LiveThread` object.

        Ú
livecreate)rq   rY   rr   r_   r.   r7   )r   r_   rq   rY   rr   s        r   ri   zLiveHelper.createþ   s9   € ð( �|‰|× Ñ Ü�\Ñ"à*ØØ&Øñ	ð !ó 
ð 	
r   c                ó\   ‡ ‡— t        ‰t        «      sd}t        |«      ‚dˆˆ fd„} |«       S )a  Fetch information about each live thread in ``ids``.

        :param ids: A list of IDs for a live thread.

        :returns: A generator that yields :class:`.LiveThread` instances.

        :raises: ``prawcore.ServerError`` if invalid live threads are requested.

        Requests will be issued in batches for each 100 IDs.

        .. note::

            This method doesn't support IDs for live updates.

        .. warning::

            Unlike :meth:`.Reddit.info`, the output of this method may not reflect the
            order of input.

        Usage:

        .. code-block:: python

            ids = ["3rgnbke2rai6hen7ciytwcxadi", "sw7bubeycai6hey4ciytwamw3a", "t8jnufucss07"]
            for thread in reddit.live.info(ids):
                print(thread.title)

        zids must be a listc               3  óú   •K  — t        dt        ‰«      d«      D ][  } ‰| | dz    }t        d   j                  dj	                  |«      ¬«      }ddi}‰j
                  j                  ||¬«      E d {  –—†  Œ] y 7 Œ­w)Nr   r   Ú	live_infor!   )r-   r   rR   )ÚrangeÚlenr   Úformatr1   r   r   )ÚpositionÚ	ids_chunkr`   rS   r-   r   s       €€r   Ú	generatorz"LiveHelper.info.<locals>.generator=  s‚   øè ø€ Ü! !¤S¨£X¨sÓ3ò @�Ø ¨8°c©>Ð:�	Ü˜{Ñ+×2Ñ2°s·x±xÀ	Ó7JÐ2ÓK�Ø07¸¨~�ØŸ<™<×+Ñ+¨C¸Ð+Ó?×?Ñ?ñ	@ð @ús   ƒA.A;Á1A9Á2A;)r>   úIterator[models.LiveThread])rd   Úlistrc   )r   r-   rh   r}   s   ``  r   ÚinfozLiveHelper.info  s.   ù€ ô: ˜#œtÔ$Ø&ˆCÜ˜C“.Ð ö	@ñ ‹{Ðr   c                óF   — | j                   j                  t        d   «      S )a!  Get the currently featured live thread.

        :returns: The :class:`.LiveThread` object, or ``None`` if there is no currently
            featured live thread.

        Usage:

        .. code-block:: python

            thread = reddit.live.now()  # LiveThread object or None

        Úlive_nowrT   r8   s    r   ÚnowzLiveHelper.nowF  s   € ð �|‰|×Ñ¤¨Ñ 4Ó5Ð5r   )rM   re   r>   úmodels.LiveThread)
r_   re   rq   rl   rY   rm   rr   rl   r>   r„   )r-   z	list[str]r>   r~   )r>   zmodels.LiveThread | None)r@   rA   rB   rC   r   ri   r€   rƒ   rD   r   r   ro   ro   í   sU   „ ÙOó/ð$ #'ØØ $ñ
àð
ð  ð	
ð
 ð
ð ð
ð 
ó
ó<(ôT6r   ro   c                  óL   — e Zd ZdZdd„Zddddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d	d„Zy)
ÚMultiredditHelperz9Provide a set of functions to interact with multireddits.c               óF   — d|› d|› �}t        | j                  ||dœ¬«      S )zÛReturn a lazy instance of :class:`.Multireddit`.

        :param name: The name of the multireddit.
        :param redditor: A redditor name or :class:`.Redditor` instance who owns the
            multireddit.

        z/user/z/m/)ÚnameÚpath)Ú_data)r   r   )r   rˆ   Úredditorr‰   s       r   r   zMultiredditHelper.__call__Y  s,   € ð ˜�z  T FÐ+ˆÜ˜4Ÿ<™<¸ÀdÑ/KÔLÐLr   NÚprivateÚclassic)Údescription_mdÚ	icon_nameÚ	key_colorÚ
visibilityÚweighting_schemec               ó°   — |||||D �cg c]  }dt        |«      i‘Œ c}||dœ}	| j                  j                  t        d   dt	        |	«      i¬«      S c c}w )a;  Create a new :class:`.Multireddit`.

        :param display_name: The display name for the new multireddit.
        :param subreddits: Subreddits to add to the new multireddit. Can be a list of
            either :class:`.Subreddit` instances or subreddit display names.
        :param description_md: Description for the new multireddit, formatted in
            markdown.
        :param icon_name: Can be one of: ``"art and design"``, ``"ask"``, ``"books"``,
            ``"business"``, ``"cars"``, ``"comics"``, ``"cute animals"``, ``"diy"``,
            ``"entertainment"``, ``"food and drink"``, ``"funny"``, ``"games"``,
            ``"grooming"``, ``"health"``, ``"life advice"``, ``"military"``, ``"models
            pinup"``, ``"music"``, ``"news"``, ``"philosophy"``, ``"pictures and
            gifs"``, ``"science"``, ``"shopping"``, ``"sports"``, ``"style"``,
            ``"tech"``, ``"travel"``, ``"unusual stories"``, ``"video"``, or ``None``.
        :param key_color: RGB hex color code of the form ``"#FFFFFF"``.
        :param visibility: Can be one of: ``"hidden"``, ``"private"``, or ``"public"``
            (default: ``"private"``).
        :param weighting_scheme: Can be one of: ``"classic"`` or ``"fresh"`` (default:
            ``"classic"``).

        :returns: The new :class:`.Multireddit` object.

        rˆ   )rŽ   Údisplay_namer�   r�   Ú
subredditsr‘   r’   Úmultireddit_baseÚmodelr.   )re   r   r2   r   r   )
r   rŽ   r”   r�   r�   r•   r‘   r’   Úsubr—   s
             r   ri   zMultiredditHelper.created  sg   € ðF -Ø(Ø"Ø"Ø9CÖD°#˜F¤C¨£HÒ-ÒDØ$Ø 0ñ
ˆð �|‰|× Ñ ¤Ð*<Ñ!=ÀWÌeÐTYËlÐD[Ð Ó\Ð\ùò	 Es   ‰A)rˆ   re   r‹   zstr | models.Redditorr>   úmodels.Multireddit)rŽ   rl   r”   re   r�   rl   r�   rl   r•   zlist[str | models.Subreddit]r‘   re   r’   re   r>   r™   ©r@   rA   rB   rC   r   ri   rD   r   r   r†   r†   V  sz   „ ÙCó	Mð &*à $Ø $à#Ø )ñ+]ð #ð+]ð ð	+]ð
 ð+]ð ð+]ð 1ð+]ð ð+]ð ð+]ð 
ô+]r   r†   c                  óF   — e Zd ZdZd	d„Zdddddœ	 	 	 	 	 	 	 	 	 	 	 	 	 d
d„Zy)ÚSubredditHelperz7Provide a set of functions to interact with Subreddits.c                ó0   — t        | j                  |¬«      S )zqReturn a lazy instance of :class:`.Subreddit`.

        :param display_name: The name of the subreddit.

        )r”   )r   r   )r   r”   s     r   r   zSubredditHelper.__call__•  s   € ô ˜Ÿ™°LÔAÐAr   ÚanyÚpublicNÚdisabled)Ú	link_typeÚsubreddit_typer_   Úwikimodec          
     óf   — t        j                  d| j                  ||||xs ||dœ|¤Ž  | |«      S )aÃ  Create a new :class:`.Subreddit`.

        :param name: The name for the new subreddit.
        :param link_type: The types of submissions users can make. One of ``"any"``,
            ``"link"``, or ``"self"`` (default: ``"any"``).
        :param subreddit_type: One of ``"archived"``, ``"employees_only"``,
            ``"gold_only"``, ``"gold_restricted"``, ``"private"``, ``"public"``, or
            ``"restricted"`` (default: ``"public"``).
        :param title: The title of the subreddit. When ``None`` or ``""`` use the value
            of ``name``.
        :param wikimode: One of ``"anyone"``, ``"disabled"``, or ``"modonly"`` (default:
            ``"disabled"``).

        Any keyword parameters not provided, or set explicitly to ``None``, will take on
        a default value assigned by the Reddit server.

        .. seealso::

            :meth:`~.SubredditModeration.update` for documentation of other available
            settings.

        )r   r¡   rˆ   r¢   r_   r£   rD   )r   Ú_create_or_updater   )r   rˆ   r¡   r¢   r_   r£   Úother_settingss          r   ri   zSubredditHelper.create�  sH   € ô@ 	×#Ñ#ð 	
Ø—L‘LØØØ)Ø’-˜4Øñ	
ð ò	
ñ �D‹zÐr   )r”   re   r>   úmodels.Subreddit)rˆ   re   r¡   re   r¢   re   r_   rl   r£   re   r¦   r   r>   r§   rš   rD   r   r   rœ   rœ   ’  sb   „ ÙAóBð Ø&Ø Ø"ñ)àð)ð ð	)ð
 ð)ð ð)ð ð)ð ð)ð 
ô)r   rœ   N)rC   Ú
__future__r   Újsonr   Útypingr   r   r   Ú
praw.constr   Úpraw.models.baser	   Úpraw.models.listing.generatorr
   Úpraw.models.reddit.draftr   Úpraw.models.reddit.liver   Úpraw.models.reddit.multir   r   Úcollections.abcr   Úprawr   r   rF   ro   r†   rœ   rD   r   r   ú<module>r³      sw   ðÙ !å "å ß /Ñ /å Ý %Ý :Ý *Ý .ß ;áÝ(åô[0˜ô [0ô|w?�(ô w?ôtf6�ô f6ôR9]˜ô 9]ôx4�hõ 4r   