Ë
    …jÐjz*  ã                   óÎ   — d Z ddlmZmZmZ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 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rddlZ G d„ de«      Zy)zProvides the User class.é    )ÚTYPE_CHECKINGÚDictÚIteratorÚListÚOptionalÚUnion)Úwarn)ÚConflicté   )ÚAPI_PATH)ÚReadOnlyException)ÚPreferences)Ú_deprecate_args)Úcachedpropertyé   )ÚPRAWBase)ÚListingGenerator)ÚRedditor)Ú	SubredditNc                   óª  ‡ — e Zd ZdZedd„«       Zdˆ fd„Zded   fd„Zde	e
eee
e
f   f   ded   fd	„Z ed
«      ddœd
ee	e
df      de	ed   df   fd„«       Zdedee
ef   f   fd„Z ed«      ddœdeded   fd„«       Zde	e
eee
e
f   f   ded   fd„Zded   fd„Zdddœdddedefd„Zde	e
eee
e
f   f   ded   fd„Zded   fd„Zˆ xZS ) ÚUserzOThe :class:`.User` class provides methods for the currently authenticated user.Úreturnc                 ó,   — t        | j                  «      S )ap  Get an instance of :class:`.Preferences`.

        The preferences can be accessed as a ``dict`` like so:

        .. code-block:: python

            preferences = reddit.user.preferences()
            print(preferences["show_link_flair"])

        Preferences can be updated via:

        .. code-block:: python

            reddit.user.preferences.update(show_link_flair=True)

        The :meth:`.Preferences.update` method returns the new state of the preferences
        as a ``dict``, which can be used to check whether a change went through. Changes
        with invalid types or parameter names fail silently.

        .. code-block:: python

            original_preferences = reddit.user.preferences()
            new_preferences = reddit.user.preferences.update(invalid_param=123)
            print(original_preferences == new_preferences)  # True, no change

        )r   Ú_reddit©Úselfs    úŠ/var/labsstorage/home/Thilakkumar/htdocs/soical-media-automation/automation_platform/venv/lib/python3.12/site-packages/praw/models/user.pyÚpreferenceszUser.preferences   s   € ô8 ˜4Ÿ<™<Ó(Ð(ó    c                 ó(   •— t         ‰| �  |d¬«       y)zInitialize an :class:`.User` instance.

        This class is intended to be interfaced with through ``reddit.user``.

        N©Ú_data)ÚsuperÚ__init__)r   ÚredditÚ	__class__s     €r   r$   zUser.__init__6   s   ø€ ô 	‰Ñ˜ tÐÕ,r   zpraw.models.Redditorc                 óF   — | j                   j                  t        d   «      S )zAReturn a :class:`.RedditorList` of blocked :class:`.Redditor`\ s.Úblocked©r   Úgetr   r   s    r   r(   zUser.blocked>   s   € à�|‰|×Ñ¤¨Ñ 3Ó4Ð4r   Úgenerator_kwargszpraw.models.Subredditc                 ó>   — t        | j                  t        d   fi |¤ŽS )aí  Return a :class:`.ListingGenerator` of contributor :class:`.Subreddit`\ s.

        These are subreddits in which the user is an approved user.

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

        To print a list of the subreddits that you are an approved user in, try:

        .. code-block:: python

            for subreddit in reddit.user.contributor_subreddits(limit=None):
                print(str(subreddit))

        Úmy_contributor©r   r   r   ©r   r+   s     r   Úcontributor_subredditszUser.contributor_subredditsB   s(   € ô$  Ø�L‰Lœ(Ð#3Ñ4ñ
Ø8Hñ
ð 	
r   ÚuserN©r1   c                ó’   — |€	t         d   n!t         d   j                  t        |«      ¬«      }| j                  j	                  |«      S )aO  Return a :class:`.RedditorList` of friends or a :class:`.Redditor` in the friends list.

        :param user: Checks to see if you are friends with the redditor. Either an
            instance of :class:`.Redditor` or a string can be given.

        :returns: A list of :class:`.Redditor`\ s, or a single :class:`.Redditor` if
            ``user`` is specified. The :class:`.Redditor` instance(s) returned also has
            friend attributes.

        :raises: An instance of :class:`.RedditAPIException` if you are not friends with
            the specified :class:`.Redditor`.

        ÚfriendsÚ	friend_v1r2   )r   ÚformatÚstrr   r*   )r   r1   Úendpoints      r   r4   zUser.friendsX   sI   € ð& ˆ|ô �YÒä˜+Ñ&×-Ñ-´3°t³9Ð-Ó=ð 	ð
 �|‰|×Ñ Ó)Ð)r   c                 ó    — i }| j                   j                  t        d   «      d   D ]#  }t        | j                   |d   «      }|d= |||<   Œ% |S )a  Return a dictionary mapping :class:`.Subreddit`\ s to their karma.

        The returned dict contains subreddits as keys. Each subreddit key contains a
        sub-dict that have keys for ``comment_karma`` and ``link_karma``. The dict is
        sorted in descending karma order.

        .. note::

            Each key of the main dict is an instance of :class:`.Subreddit`. It is
            recommended to iterate over the dict in order to retrieve the values,
            preferably through :py:meth:`dict.items`.

        ÚkarmaÚdataÚsr)r   r*   r   r   )r   Ú	karma_mapÚrowÚ	subreddits       r   r:   z
User.karmap   s^   € ð ˆ	Ø—<‘<×#Ñ#¤H¨WÑ$5Ó6°vÑ>ò 	'ˆCÜ! $§,¡,°°D±	Ó:ˆIØ�D�	Ø#&ˆI�iÒ ð	'ð Ðr   Ú	use_cacheT)r@   c                ó|  — | j                   j                  rM| j                   j                  j                  j	                  d«      st        dt        d¬«       yt        d«      ‚d| j                  vs|s>| j                   j	                  t        d   «      }t        | j                   |¬	«      | _        | j                  S )
a'  Return a :class:`.Redditor` instance for the authenticated user.

        :param use_cache: When ``True``, and if this function has been previously
            called, returned the cached version (default: ``True``).

        .. note::

            If you change the :class:`.Reddit` instance's authorization, you might want
            to refresh the cached value. Prefer using separate :class:`.Reddit`
            instances, however, for distinct authorizations.

        .. deprecated:: 7.2

            In :attr:`.read_only` mode this method returns ``None``. In PRAW 8 this
            method will raise :class:`.ReadOnlyException` when called in
            :attr:`.read_only` mode. To operate in PRAW 8 mode, set the config variable
            ``praw8_raise_exception_on_me`` to ``True``.

        Úpraw8_raise_exception_on_mez•The 'None' return value is deprecated, and will raise a ReadOnlyException beginning with PRAW 8. See documentation for forward compatibility options.r   )ÚcategoryÚ
stacklevelNz+`user.me()` does not work in read_only modeÚ_meÚmer!   )r   Ú	read_onlyÚconfigÚcustomr*   r	   ÚDeprecationWarningr   Ú__dict__r   r   rE   )r   r@   Ú	user_datas      r   rF   zUser.me…   s—   € ð. �<‰<×!Ò!Ø—<‘<×&Ñ&×-Ñ-×1Ñ1Ð2OÔPÜð6ô 0Ø õð Ü#Ð$QÓRÐRØ˜Ÿ™Ñ%©YØŸ™×(Ñ(¬°$©Ó8ˆIÜ §¡°IÔ>ˆDŒHØ�x‰xˆr   c                 ó>   — t        | j                  t        d   fi |¤ŽS )aÛ  Return a :class:`.ListingGenerator` subreddits that the user moderates.

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

        To print a list of the names of the subreddits you moderate, try:

        .. code-block:: python

            for subreddit in reddit.user.moderator_subreddits(limit=None):
                print(str(subreddit))

        .. seealso::

            :meth:`.Redditor.moderated`

        Úmy_moderatorr.   r/   s     r   Úmoderator_subredditszUser.moderator_subreddits¬   s'   € ô(  Ø�L‰Lœ( >Ñ2ñ
Ø6Fñ
ð 	
r   zpraw.models.Multiredditc                 óF   — | j                   j                  t        d   «      S )z@Return a list of :class:`.Multireddit`\ s belonging to the user.Úmy_multiredditsr)   r   s    r   ÚmultiredditszUser.multiredditsÄ   s   € à�|‰|×Ñ¤Ð):Ñ ;Ó<Ð<r   )ÚnumÚstateÚ
submissionzpraw.models.SubmissionrS   rT   c                óŒ   — |j                   ||ddœ}	 | j                  j                  t        d   |¬«      S # t        $ r Y yw xY w)a"  Set the pin state of a submission on the authenticated user's profile.

        :param submission: An instance of :class:`.Submission` that will be
            pinned/unpinned.
        :param num: If specified, the slot in which the submission will be pinned into.
            If there is a submission already in the specified slot, it will be replaced.
            If ``None`` or there is not a submission in the specified slot, the first
            available slot will be used (default: ``None``). If all slots are used the
            following will occur:

            - Old Reddit:

              1. The submission in the last slot will be unpinned.
              2. The remaining pinned submissions will be shifted down a slot.
              3. The new submission will be pinned in the first slot.

            - New Reddit:

              1. The submission in the first slot will be unpinned.
              2. The remaining pinned submissions will be shifted up a slot.
              3. The new submission will be pinned in the last slot.

            .. note::

                At the time of writing (10/22/2021), there are 4 pin slots available and
                pins are in reverse order on old Reddit. If ``num`` is an invalid value,
                Reddit will ignore it and the same behavior will occur as if ``num`` is
                ``None``.

        :param state: ``True`` pins the submission, ``False`` unpins (default:
            ``True``).

        :raises: ``prawcore.BadRequest`` when pinning a removed or deleted submission.

        :raises: ``prawcore.Forbidden`` when pinning a submission the authenticated user
            is not the author of.

        .. code-block:: python

            submission = next(reddit.user.me().submissions.new())
            reddit.user.pin(submission)

        T)ÚidrS   rT   Ú
to_profileÚsticky_submission)r;   N)Úfullnamer   Úpostr   r
   )r   rU   rS   rT   r;   s        r   ÚpinzUser.pinÈ   sU   € ðf ×%Ñ%ØØØñ	
ˆð	Ø—<‘<×$Ñ$¤XÐ.AÑ%BÈÐ$ÓNÐNøÜò 	Ùð	ús   “#7 ·	AÁAc                 ó>   — t        | j                  t        d   fi |¤ŽS )a¤  Return a :class:`.ListingGenerator` of :class:`.Subreddit`\ s the user is subscribed to.

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

        To print a list of the subreddits that you are subscribed to, try:

        .. code-block:: python

            for subreddit in reddit.user.subreddits(limit=None):
                print(str(subreddit))

        Úmy_subredditsr.   r/   s     r   Ú
subredditszUser.subreddits  s'   € ô   Ø�L‰Lœ( ?Ñ3ñ
Ø7Gñ
ð 	
r   c                 óF   — | j                   j                  t        d   «      S )a{  Return a :class:`.RedditorList` of trusted :class:`.Redditor`\ s.

        To display the usernames of your trusted users and the times at which you
        decided to trust them, try:

        .. code-block:: python

            trusted_users = reddit.user.trusted()
            for user in trusted_users:
                print(f"User: {user.name}, time: {user.date}")

        Útrustedr)   r   s    r   ra   zUser.trusted  s   € ð �|‰|×Ñ¤¨Ñ 3Ó4Ð4r   )r   zpraw.models.Preferences)r%   zpraw.Reddit)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r$   r   r(   r   r7   Úintr   r   r0   r   r   r4   r:   ÚboolrF   rO   rR   r\   r_   ra   Ú__classcell__)r&   s   @r   r   r      s©  ø„ ÙYàò)ó ð)õ:-ð5˜Ð4Ñ5ó 5ð
Ø"'¨¨S°$°s¸C°x±.Ð(@Ñ"Að
à	Ð)Ñ	*ó
ñ, �VÓàFJò*Ø  cÐ+AÐ&AÑ BÑCð*à	ˆtÐ*Ñ+Ð-CÐCÑ	Dò*ó ð*ð.�tÐ3°T¸#¸s¸(±^ÐCÑDó ñ* �[Ó!à#'ò$Ø ð$à	Ð(Ñ	)ò$ó "ð$ðL
Ø"'¨¨S°$°s¸C°x±.Ð(@Ñ"Að
à	Ð)Ñ	*ó
ð0=˜dÐ#<Ñ=ó =ð Øò;à,ð;ð ð	;ð
 ó;ðz
Ø"'¨¨S°$°s¸C°x±.Ð(@Ñ"Að
à	Ð)Ñ	*ó
ð(5˜Ð4Ñ5÷ 5r   r   ) re   Útypingr   r   r   r   r   r   Úwarningsr	   Úprawcorer
   Úconstr   Ú
exceptionsr   Úmodelsr   Úutilr   Ú
util.cacher   Úbaser   Úlisting.generatorr   Úreddit.redditorr   Úreddit.subredditr   Úprawr   © r   r   ú<module>rw      sC   ðÙ ß G× GÝ å å Ý *Ý  Ý "Ý 'Ý Ý /Ý %Ý 'áÛôQ5ˆ8õ Q5r   