Ë
    Fü´jÑ3  ã                  ó¼   — d Z ddlm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 erdd	lmZ dd
lmZ  G d„ d«      Z G d„ de«      Z G d„ de«      Zy)z(Provide the SubredditRelationship class.é    )Úannotations)Údeepcopy)ÚTYPE_CHECKINGÚAny)ÚAPI_PATH)ÚListingGenerator)Ú
RedditBase)Úpermissions_string)ÚIterator)Úmodelsc                  ó>   — e Zd ZdZ	 d	 	 	 	 	 dd„Zd	d„Zd
d„Zdd„Zy)ÚSubredditRelationshipaš  Represents a relationship between a :class:`.Redditor` and :class:`.Subreddit`.

    Instances of this class can be iterated through in order to discover the Redditors
    that make up the relationship.

    For example, banned users of a subreddit can be iterated through like so:

    .. code-block:: python

        for ban in reddit.subreddit("test").banned():
            print(f"{ban}: {ban.note}")

    Nc                óÔ   — t        j                  |d|¬«       t        d| j                  › �   j	                  | j
                  ¬«      }t        | j
                  j                  |fi |¤ŽS )aË  Return a :class:`.ListingGenerator` for :class:`.Redditor`\ s in the relationship.

        :param redditor: When provided, yield at most a single :class:`.Redditor`
            instance. This is useful to confirm if a relationship exists, or to fetch
            the metadata associated with a particular relationship (default: ``None``).

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

        Úparams)Ú	argumentsÚkeyÚuserÚlist_©Ú	subreddit)r	   Ú_safely_add_argumentsr   ÚrelationshipÚformatr   r   Ú_reddit©ÚselfÚredditorÚgenerator_kwargsÚurls       úg/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/subreddit/relationship.pyÚ__call__zSubredditRelationship.__call__"   s_   € ô 	×(Ñ(Ð3CÈÐX`ÕaÜ˜˜t×0Ñ0Ð1Ð2Ñ3×:Ñ:ÀTÇ^Á^Ð:ÓTˆÜ §¡× 6Ñ 6¸ÑPÐ?OÑPÐPó    c                ó    — || _         || _        y)zÄInitialize a :class:`.SubredditRelationship` instance.

        :param subreddit: The :class:`.Subreddit` for the relationship.
        :param relationship: The name of the relationship.

        N)r   r   )r   r   r   s      r    Ú__init__zSubredditRelationship.__init__5   s   € ð )ˆÔØ"ˆ�r"   c                óê   — t        |«      | j                  dœ}|j                  |«       t        d   j	                  | j
                  ¬«      }| j
                  j                  j                  ||¬«       y)zzAdd ``redditor`` to this relationship.

        :param redditor: A redditor name or :class:`.Redditor` instance.

        ©ÚnameÚtypeÚfriendr   ©ÚdataN)Ústrr   Úupdater   r   r   r   Úpost)r   r   Úother_settingsr+   r   s        r    ÚaddzSubredditRelationship.add?   s]   € ô ˜H›¨t×/@Ñ/@ÑAˆØ�‰�NÔ#Ü�xÑ ×'Ñ'°$·.±.Ð'ÓAˆØ�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   c                óÈ   — t        |«      | j                  dœ}t        d   j                  | j                  ¬«      }| j                  j
                  j                  ||¬«       y)zRemove ``redditor`` from this relationship.

        :param redditor: A redditor name or :class:`.Redditor` instance.

        r&   Úunfriendr   r*   N)r,   r   r   r   r   r   r.   ©r   r   r+   r   s       r    ÚremovezSubredditRelationship.removeJ   sQ   € ô ˜H›¨t×/@Ñ/@ÑAˆÜ�zÑ"×)Ñ)°D·N±NÐ)ÓCˆØ�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   ©N©r   ústr | models.Redditor | Noner   r   ÚreturnzIterator[models.Redditor])r   zmodels.Subredditr   r,   r8   ÚNone)r   ústr | models.Redditorr/   r   r8   r9   ©r   r:   r8   r9   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r!   r$   r0   r4   © r"   r    r   r      s@   „ ñð  26ðQà.ðQð  ðQð 
#ó	Qó&#ó	4ô4r"   r   c                  ó   — e Zd ZdZdd„Zy)ÚContributorRelationshipaG  Provides methods to interact with a :class:`.Subreddit`'s contributors.

    Contributors are also known as approved submitters.

    Contributors of a subreddit can be iterated through like so:

    .. code-block:: python

        for contributor in reddit.subreddit("test").contributor():
            print(contributor)

    c                óŒ   — | j                   j                  j                  t        d   d| j                   j                  i¬«       y)z"Abdicate the contributor position.ÚleavecontributorÚidr*   N)r   r   r.   r   Úfullname)r   s    r    ÚleavezContributorRelationship.leavec   s4   € à�‰×Ñ×#Ñ#¤HÐ-?Ñ$@ÈÈdÏnÉn×NeÑNeÐGfÐ#Õgr"   N©r8   r9   )r<   r=   r>   r?   rG   r@   r"   r    rB   rB   U   s   „ ñôhr"   rB   c                  óö   ‡ — e Zd ZdZ eh d£«      Zedddœ	 	 	 	 	 dd„«       Z	 d	 	 	 dd„Zddœ	 	 	 	 	 	 	 dˆ fd„Z	ddœ	 	 	 	 	 	 	 dd	„Z
dd
œ	 	 	 	 	 dd„Zdd„Zdd„Zddœ	 	 	 	 	 dd„Zddœ	 	 	 	 	 dd„Zˆ xZS )ÚModeratorRelationshipa  Provides methods to interact with a :class:`.Subreddit`'s moderators.

    Moderators of a subreddit can be iterated through like so:

    .. code-block:: python

        for moderator in reddit.subreddit("test").moderator():
            print(moderator)

    >   ÚmailÚwikiÚflairÚpostsÚaccessÚconfigÚchat_configÚchat_operatorN©r/   Úpermissionsc                ór   — | rt        | «      ni } t        t        t        j                  «      |¬«      | d<   | S )N)Úknown_permissionsrT   rT   )r   r
   ÚsetrJ   ÚPERMISSIONSrS   s     r    Ú_handle_permissionsz)ModeratorRelationship._handle_permissions   s<   € ñ 6Dœ .Ô1ÈˆÜ(:Ü!Ô"7×"CÑ"CÓDÐR]ô)
ˆ�}Ñ%ð Ðr"   c                óÒ   — |€i ndt        |«      i}t        d| j                  › �   j                  | j                  ¬«      }| j                  j
                  j                  ||¬«      S )a�  Return a list of :class:`.Redditor`\ s who are moderators.

        :param redditor: When provided, return a list containing at most one
            :class:`.Redditor` instance. This is useful to confirm if a relationship
            exists, or to fetch the metadata associated with a particular relationship
            (default: ``None``).

        .. note::

            To help mitigate targeted moderator harassment, this call requires the
            :class:`.Reddit` instance to be authenticated i.e., :attr:`.read_only` must
            return ``False``. This call, however, only makes use of the ``read`` scope.
            For more information on why the moderator list is hidden can be found here:
            https://support.reddithelp.com/hc/en-us/articles/360049499032-Why-can-t-I-see-the-list-of-moderators-in-a-community-

        .. note::

            Unlike other relationship callables, this relationship is not paginated.
            Thus, it simply returns the full list, rather than an iterator for the
            results.

        To be used like:

        .. code-block:: python

            moderators = reddit.subreddit("test").moderator()

        For example, to list the moderators along with their permissions try:

        .. code-block:: python

            for moderator in reddit.subreddit("test").moderator():
                print(f"{moderator}: {moderator.mod_permissions}")

        r   r   r   )r   )r,   r   r   r   r   r   Úget)r   r   r   r   s       r    r!   zModeratorRelationship.__call__‹   se   € ðL .6Ð-=¡rÀFÌCÐPXËMÐCZˆÜ˜˜t×0Ñ0Ð1Ð2Ñ3×:Ñ:ÀTÇ^Á^Ð:ÓTˆØ�~‰~×%Ñ%×)Ñ)¨#°fÐ)Ó=Ð=r"   )rT   c               óL   •— | j                  ||¬«      }t        ‰| �  |fi |¤Ž y)a  Add or invite ``redditor`` to be a moderator of the :class:`.Subreddit`.

        :param redditor: A redditor name or :class:`.Redditor` instance.
        :param permissions: When provided (not ``None``), permissions should be a list
            of strings specifying which subset of permissions to grant. An empty list
            ``[]`` indicates no permissions, and when not provided ``None``, indicates
            full permissions (default: ``None``).

        An invite will be sent unless the user making this call is an admin user.

        For example, to invite u/spez with ``"posts"`` and ``"mail"`` permissions to
        r/test, try:

        .. code-block:: python

            reddit.subreddit("test").moderator.add("spez", permissions=["posts", "mail"])

        rS   N)rY   Úsuperr0   )r   r   rT   r/   Ú	__class__s       €r    r0   zModeratorRelationship.addµ   s,   ø€ ð2 ×1Ñ1ÀÐ]hÐ1ÓiˆÜ‰‰�HÑ/ Ó/r"   c               óø   — | j                  ||¬«      }|j                  t        |«      ddœ«       t        d   j	                  | j
                  ¬«      }| j
                  j                  j                  ||¬«       y)a´  Invite ``redditor`` to be a moderator of the :class:`.Subreddit`.

        :param redditor: A redditor name or :class:`.Redditor` instance.
        :param permissions: When provided (not ``None``), permissions should be a list
            of strings specifying which subset of permissions to grant. An empty list
            ``[]`` indicates no permissions, and when not provided ``None``, indicates
            full permissions (default: ``None``).

        For example, to invite u/spez with ``"posts"`` and ``"mail"`` permissions to
        r/test, try:

        .. code-block:: python

            reddit.subreddit("test").moderator.invite("spez", permissions=["posts", "mail"])

        rS   Úmoderator_inviter&   r)   r   r*   N)rY   r-   r,   r   r   r   r   r.   )r   r   rT   r/   r+   r   s         r    ÚinvitezModeratorRelationship.inviteÑ   si   € ð. ×'Ñ'°~ÐS^Ð'Ó_ˆØ�‰œS ›]Ð4FÑGÔHÜ�xÑ ×'Ñ'°$·.±.Ð'ÓAˆØ�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   )r   c               ó    — |rd|ind|d<   t         d   j                  | j                  ¬«      }t        | j                  j                  |fi |¤ŽS )a“  Return a :class:`.ListingGenerator` for :class:`.Redditor`\ s invited to be moderators.

        :param redditor: When provided, return a list containing at most one
            :class:`.Redditor` instance. This is useful to confirm if a relationship
            exists, or to fetch the metadata associated with a particular relationship
            (default: ``None``).

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

        .. note::

            Unlike other usages of :class:`.ListingGenerator`, ``limit`` has no effect
            in the quantity returned. This endpoint always returns moderators in batches
            of 25 at a time regardless of what ``limit`` is set to.

        Usage:

        .. code-block:: python

            for invited_mod in reddit.subreddit("test").moderator.invited():
                print(invited_mod)

        ÚusernameNr   Úlist_invited_moderatorr   )r   r   r   r   r   r   s       r    ÚinvitedzModeratorRelationship.invitedí   sT   € ñ< @H j°(Ñ%;ÈTÐ˜Ñ"ÜÐ/Ñ0×7Ñ7À$Ç.Á.Ð7ÓQˆÜ §¡× 6Ñ 6¸ÑPÐ?OÑPÐPr"   c                óâ   — | j                   j                  j                  j                  xs. | j                   j                  j                  j                  «       }|€J ‚| j                  |«       y)z¨Abdicate the moderator position (use with care).

        For example:

        .. code-block:: python

            reddit.subreddit("test").moderator.leave()

        N)r   r   rP   rc   r   Úmer4   )r   r   s     r    rG   zModeratorRelationship.leave  sU   € ð —>‘>×)Ñ)×0Ñ0×9Ñ9Ò]¸T¿^¹^×=SÑ=S×=XÑ=X×=[Ñ=[Ó=]ˆØÐ#Ð#Ð#Ø�‰�HÕr"   c                ó´   — t        |«      ddœ}t        d   j                  | j                  ¬«      }| j                  j                  j                  ||¬«       y)zýRemove the moderator invite for ``redditor``.

        :param redditor: A redditor name or :class:`.Redditor` instance.

        For example:

        .. code-block:: python

            reddit.subreddit("test").moderator.remove_invite("spez")

        r`   r&   r2   r   r*   N)r,   r   r   r   r   r.   r3   s       r    Úremove_invitez#ModeratorRelationship.remove_invite  sL   € ô ˜H›Ð/AÑBˆÜ�zÑ"×)Ñ)°D·N±NÐ)ÓCˆØ�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   c               óÖ   — t         d   j                  | j                  ¬«      }| j                  t	        |«      ddœ|¬«      }| j                  j
                  j                  ||¬«       y)aí  Update the moderator permissions for ``redditor``.

        :param redditor: A redditor name or :class:`.Redditor` instance.
        :param permissions: When provided (not ``None``), permissions should be a list
            of strings specifying which subset of permissions to grant. An empty list
            ``[]`` indicates no permissions, and when not provided, ``None``, indicates
            full permissions (default: ``None``).

        For example, to add all permissions to the moderator, try:

        .. code-block:: python

            subreddit.moderator.update("spez")

        To remove all permissions from the moderator, try:

        .. code-block:: python

            subreddit.moderator.update("spez", permissions=[])

        Úsetpermissionsr   Ú	moderatorr&   rS   r*   N©r   r   r   rY   r,   r   r.   ©r   r   rT   r   r+   s        r    r-   zModeratorRelationship.update-  sd   € ô6 Ð'Ñ(×/Ñ/¸$¿.¹.Ð/ÓIˆØ×'Ñ'Ü$'¨£M¸;ÑGØ#ð (ó 
ˆð 	�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   c               óÖ   — t         d   j                  | j                  ¬«      }| j                  t	        |«      ddœ|¬«      }| j                  j
                  j                  ||¬«       y)aª  Update the moderator invite permissions for ``redditor``.

        :param redditor: A redditor name or :class:`.Redditor` instance.
        :param permissions: When provided (not ``None``), permissions should be a list
            of strings specifying which subset of permissions to grant. An empty list
            ``[]`` indicates no permissions, and when not provided, ``None``, indicates
            full permissions (default: ``None``).

        For example, to grant the ``"flair"`` and ``"mail"`` permissions to the
        moderator invite, try:

        .. code-block:: python

            subreddit.moderator.update_invite("spez", permissions=["flair", "mail"])

        rk   r   r`   r&   rS   r*   Nrm   rn   s        r    Úupdate_invitez#ModeratorRelationship.update_inviteO  se   € ô, Ð'Ñ(×/Ñ/¸$¿.¹.Ð/ÓIˆØ×'Ñ'Ü$'¨£MÐ;MÑNØ#ð (ó 
ˆð 	�‰×Ñ×#Ñ# C¨dÐ#Õ3r"   )r/   zdict | NonerT   úlist[str] | Noner8   zdict[str, Any]r5   )r   r7   r8   zlist[models.Redditor])r   r:   rT   rq   r/   r   r8   r9   r6   rH   r;   )r   r:   rT   rq   r8   r9   )r<   r=   r>   r?   Ú	frozensetrX   ÚstaticmethodrY   r!   r0   ra   re   rG   ri   r-   rp   Ú__classcell__)r^   s   @r    rJ   rJ   h   sQ  ø„ ñ	ñ ò 	ó 	€Kð ð '+Ø(,ñ	à#ð	ð &ð	ð 
ò		ó ð	ð 8<ð(>Ø4ð(>à	ó(>ð\ )-ñ	0à'ð0ð &ð	0ð
 ð0ð 
õ0ð@ )-ñ	4à'ð4ð &ð	4ð
 ð4ð 
ó4ð> 26ñ Qð /ð Qð  ð	 Qð
 
#ó QóDó4ð( )-ñ	 4à'ð 4ð &ð	 4ð
 
ó 4ðL )-ñ	4à'ð4ð &ð	4ð
 
÷4r"   rJ   N)r?   Ú
__future__r   Úcopyr   Útypingr   r   Ú
praw.constr   Úpraw.models.listing.generatorr   Úpraw.models.reddit.baser	   Úpraw.models.utilr
   Úcollections.abcr   Úprawr   r   rB   rJ   r@   r"   r    ú<module>r~      sO   ðÙ .å "å ß %å Ý :Ý .Ý /áÝ(å÷?4ñ ?4ôDhÐ3ô hô&B4Ð1õ B4r"   