o
    2g*                     @  s   d Z ddlmZ ddl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mZ er0ddlZG d
d deZG dd deZdS )z*Provide the :class:`.UserSubreddit` class.    )annotationsN)TYPE_CHECKINGAnyCallable)warn   )cachedproperty   )	SubredditSubredditModerationc                      sH   e Zd ZdZedddZeddd	ZdddZd fddZ	  Z
S )UserSubredditaZ  A class for :class:`.User` Subreddits.

    To obtain an instance of this class execute:

    .. code-block:: python

        subreddit = reddit.user.me().subreddit

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

    ========================= ==========================================================
    Attribute                 Description
    ========================= ==========================================================
    ``can_assign_link_flair`` Whether users can assign their own link flair.
    ``can_assign_user_flair`` Whether users can assign their own user flair.
    ``created_utc``           Time the subreddit was created, represented in `Unix
                              Time`_.
    ``description``           Subreddit description, in Markdown.
    ``description_html``      Subreddit description, in HTML.
    ``display_name``          Name of the subreddit.
    ``id``                    ID of the subreddit.
    ``name``                  Fullname of the subreddit.
    ``over18``                Whether the subreddit is NSFW.
    ``public_description``    Description of the subreddit, shown in searches and on the
                              "You must be invited to visit this community" page (if
                              applicable).
    ``spoilers_enabled``      Whether the spoiler tag feature is enabled.
    ``subscribers``           Count of subscribers. This will be ``0`` unless unless the
                              authenticated user is a moderator.
    ``user_is_banned``        Whether the authenticated user is banned.
    ``user_is_moderator``     Whether the authenticated user is a moderator.
    ``user_is_subscriber``    Whether the authenticated user is subscribed.
    ========================= ==========================================================

    .. _unix time: https://en.wikipedia.org/wiki/Unix_time

    funcr   returnc                   s   d fdd}|S )z.Show deprecation notice for dict only methods.argsr   kwargsc                    s&   t d j dtdd  | i |S )NzT'Redditor.subreddit' is no longer a dict and is now an UserSubreddit object. Using 'z.' is deprecated and will be removed in PRAW 8.   category
stacklevel)r   __name__DeprecationWarning)r   r   r    Y/home/garg/my-data/venv/lib/python3.10/site-packages/praw/models/reddit/user_subreddit.pywrapper;   s   z7UserSubreddit._dict_deprecated_wrapper.<locals>.wrapperN)r   r   r   r   r   )r   r   r   r   r   _dict_deprecated_wrapper7   s   
z&UserSubreddit._dict_deprecated_wrapper9praw.models.reddit.user_subreddit.UserSubredditModerationc                 C  s   t | S )zProvide an instance of :class:`.UserSubredditModeration`.

        For example, to update the authenticated user's display name:

        .. code-block:: python

            reddit.user.me().subreddit.mod.update(title="New display name")

        )UserSubredditModeration)selfr   r   r   modG   s   zUserSubreddit.moditemstrr   c                 C  s   t dtdd t| |S )z8Show deprecation notice for dict method ``__getitem__``.z'Redditor.subreddit' is no longer a dict and is now an UserSubreddit object. Accessing attributes using string indices is deprecated.r   r   )r   r   getattr)r   r    r   r   r   __getitem__T   s   
zUserSubreddit.__getitem__redditpraw.Redditr   r   c              	     sb   ddd}t jt|dD ]\}}|dkr!t| || t| j| qt j|g|R i | dS )	aL  Initialize an :class:`.UserSubreddit` instance.

        :param reddit: An instance of :class:`.Reddit`.

        .. note::

            This class should not be initialized directly. Instead, obtain an instance
            via: ``reddit.user.me().subreddit`` or
            ``reddit.redditor("redditor_name").subreddit``.

        r    r!   c                 S  s,   t | dd }|tttt vo|ttv S )Nr   )r"   dirobjectr
   dict)r    namer   r   r   	predicatek   s    z)UserSubreddit.__init__.<locals>.predicate)r*   r#   N)r    r!   )	inspect
getmembersr(   setattrr   r"   __dict__super__init__)r   r$   r   r   r*   r)   _member	__class__r   r   r0   ^   s   
zUserSubreddit.__init__)r   r   r   r   )r   r   )r    r!   r   r   )r$   r%   r   r   r   r   )r   
__module____qualname____doc__staticmethodr   r   r   r#   r0   __classcell__r   r   r2   r   r      s    &

r   c                   @  s   e Zd ZdZd	ddZdS )
r   zProvides a set of moderation functions to a :class:`.UserSubreddit`.

    For example, to accept a moderation invite from the user subreddit of u/spez:

    .. code-block:: python

        reddit.subreddit("test").mod.accept_invite()

    settingsstr | int | boolr   dict[str, str | int | bool]c                 K  s\   |   }ddddddd}| D ]\}}||||< q|| tjd
d| jji|S )a  Update the :class:`.Subreddit`'s settings.

        :param all_original_content: Mandate all submissions to be original content
            only.
        :param allow_chat_post_creation: Allow users to create chat submissions.
        :param allow_images: Allow users to upload images using the native image
            hosting.
        :param allow_polls: Allow users to post polls to the subreddit.
        :param allow_post_crossposts: Allow users to crosspost submissions from other
            subreddits.
        :param allow_top: Allow the subreddit to appear on r/all as well as the default
            and trending lists.
        :param allow_videos: Allow users to upload videos using the native image
            hosting.
        :param collapse_deleted_comments: Collapse deleted and removed comments on
            comments pages by default.
        :param crowd_control_chat_level: Controls the crowd control level for chat
            rooms. Goes from 0-3.
        :param crowd_control_level: Controls the crowd control level for submissions.
            Goes from 0-3.
        :param crowd_control_mode: Enables/disables crowd control.
        :param comment_score_hide_mins: The number of minutes to hide comment scores.
        :param description: Shown in the sidebar of your subreddit.
        :param disable_contributor_requests: Specifies whether redditors may send
            automated modmail messages requesting approval as a submitter.
        :param exclude_banned_modqueue: Exclude posts by site-wide banned users from
            modqueue/unmoderated.
        :param free_form_reports: Allow users to specify custom reasons in the report
            menu.
        :param header_hover_text: The text seen when hovering over the snoo.
        :param hide_ads: Don't show ads within this subreddit. Only applies to
            Premium-user only subreddits.
        :param key_color: A 6-digit rgb hex color (e.g., ``"#AABBCC"``), used as a
            thematic color for your subreddit on mobile.
        :param lang: A valid IETF language tag (underscore separated).
        :param link_type: The types of submissions users can make. One of ``"any"``,
            ``"link"``, or ``"self"``.
        :param original_content_tag_enabled: Enables the use of the ``original content``
            label for submissions.
        :param over_18: Viewers must be over 18 years old (i.e., NSFW).
        :param public_description: Public description blurb. Appears in search results
            and on the landing page for private subreddits.
        :param public_traffic: Make the traffic stats page public.
        :param restrict_commenting: Specifies whether approved users have the ability to
            comment.
        :param restrict_posting: Specifies whether approved users have the ability to
            submit posts.
        :param show_media: Show thumbnails on submissions.
        :param show_media_preview: Expand media previews on comments pages.
        :param spam_comments: Spam filter strength for comments. One of ``"all"``,
            ``"low"``, or ``"high"``.
        :param spam_links: Spam filter strength for links. One of ``"all"``, ``"low"``,
            or ``"high"``.
        :param spam_selfposts: Spam filter strength for selfposts. One of ``"all"``,
            ``"low"``, or ``"high"``.
        :param spoilers_enabled: Enable marking posts as containing spoilers.
        :param submit_link_label: Custom label for submit link button (None for
            default).
        :param submit_text: Text to show on submission page.
        :param submit_text_label: Custom label for submit text post button (None for
            default).
        :param subreddit_type: The string ``"user"``.
        :param suggested_comment_sort: All comment threads will use this sorting method
            by default. Leave ``None``, or choose one of ``confidence``,
            ``"controversial"``, ``"live"``, ``"new"``, ``"old"``, ``"qa"``,
            ``"random"``, or ``"top"``.
        :param title: The title of the subreddit.
        :param welcome_message_enabled: Enables the subreddit welcome message.
        :param welcome_message_text: The text to be used as a welcome message. A welcome
            message is sent to all new subscribers by a Reddit bot.
        :param wiki_edit_age: Account age, in days, required to edit and create wiki
            pages.
        :param wiki_edit_karma: Subreddit karma required to edit and create wiki pages.
        :param wikimode: One of ``"anyone"``, ``"disabled"``, or ``"modonly"``.

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

        Settings that are documented here and aren't explicitly set by you in a call to
        :meth:`.SubredditModeration.update` should retain their current value. If they
        do not please file a bug.

        .. warning::

            Undocumented settings, or settings that were very recently documented, may
            not retain their current value when updating. This often occurs when Reddit
            adds a new setting but forgets to add that setting to the API endpoint that
            is used to fetch the current settings.

        default_setheader_hover_textlanguagecontent_optionssubreddit_idsubreddit_type)	allow_topheader_titlelang	link_typesrtype_redditNr   )r9   itemspopupdater   _create_or_update	subredditrH   )r   r9   current_settingsremapnewoldr   r   r   rK      s    [
zUserSubredditModeration.updateN)r9   r:   r   r;   )r   r4   r5   r6   rK   r   r   r   r   r   {   s    
r   )r6   
__future__r   r+   typingr   r   r   warningsr   
util.cacher   rM   r
   r   praw.modelsprawr   r   r   r   r   r   <module>   s    k