
    bfU                         d dl Z ddlmZmZmZmZmZmZ ddlm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZ  G d d	e          ZdS )
    N   )_DICT_VERSION_ACCOUNT_DICT_VERSION_STATUS_DICT_VERSION_RELATIONSHIP_DICT_VERSION_LIST _DICT_VERSION_FAMILIAR_FOLLOWERS_DICT_VERSION_HASHTAG)_DEFAULT_SCOPES_SCOPE_SETS)MastodonIllegalArgumentErrorMastodonAPIErrorMastodonNotFoundError)api_version)Mastodonc                      e Zd Z eddd          dddeddfd            Z eddd          d             Z edde          d	             Z edd
e          d             Z	 edd
e          d             Z
 edde          d/d            Z edde          d0d            Z edde          d0d            Z edde          d             Z edde          d1d            Z ed
d
e          d             Z edde          d             Z edde          d             Z edde          d2d            Z edd
e          d             Z edde          d             Z edde          d             Z edde          d              Z edde          d!             Z ed"d#e          d3d$            Z ed"de          d%             Z ed&d'e          	 	 	 	 	 d4d(            Z ed)d)e          d*             Z  ed)d)e          d+             Z! ed,d,e          d-             Z" edde#          d.             Z$dS )5r   z2.7.0z3.4.0FNenc
                 <   |                      t                      ddg          }
| j        |
d<   | j        |
d<   |s|
d= 	 i }d                    |          |d<   | j        |d<   | j        |d<   d|d	<   |                     d
d|d          }|d         }n$# t          $ r}t          d|           d}~ww xY w	 |                     d
d|
d|d          }d|v r|	rd|fS t          d|           |d         | _        | 	                    |
                    d                     |                     t          |
                    dd                               n!# t          $ r}t          d          d}~ww xY w|d                             d          }t          j                    D ]}||v r|t          |         z  }t!          |          t!          |          k    s<t#          dd                    |           dd                    |           d          |ct%          |d          5 }|                    |d         dz              |                    | j        dz              ddd           n# 1 swxY w Y   d| _        |	r
|d         i fS |d         S )a	  
        Creates a new user account with the given username, password and email. "agreement"
        must be set to true (after showing the user the instance's user agreement and having
        them agree to it), "locale" specifies the language for the confirmation email as an
        ISO 639-1 (two letter) or, if a language does not have one, 639-3 (three letter) language
        code. `reason` can be used to specify why a user would like to join if approved-registrations
        mode is on.

        Does not require an access token, but does require a client grant.

        By default, this method is rate-limited by IP to 5 requests per 30 minutes.

        Returns an access token (just like log_in), which it can also persist to to_file,
        and sets it internally so that the user is now logged in. Note that this token
        can only be used after the user has confirmed their email.

        By default, the function will throw if the account could not be created. Alternately,
        when `return_detailed_error` is passed, Mastodon.py will return the detailed error
        response that the API provides (Starting from version 3.4.0 - not checked here) as an dict with
        error details as the second return value and the token returned as `None` in case of error.
        The dict will contain a text `error` values as well as a `details` value which is a dict with
        one optional key for each potential field (`username`, `password`, `email` and `agreement`),
        each if present containing a dict with an `error` category and free text `description`.
        Valid error categories are:

            * ERR_BLOCKED - When e-mail provider is not allowed
            * ERR_UNREACHABLE - When e-mail address does not resolve to any IP via DNS (MX, A, AAAA)
            * ERR_TAKEN - When username or e-mail are already taken
            * ERR_RESERVED - When a username is reserved, e.g. "webmaster" or "admin"
            * ERR_ACCEPTED - When agreement has not been accepted
            * ERR_BLANK - When a required attribute is blank
            * ERR_INVALID - When an attribute is malformed, e.g. wrong characters or invalid e-mail address
            * ERR_TOO_LONG - When an attribute is over the character limit
            * ERR_TOO_SHORT - When an attribute is under the character requirement
            * ERR_INCLUSION - When an attribute is not one of the allowed values, e.g. unsupported locale
        to_filescopes	client_idclient_secret	agreement scopeclient_credentials
grant_typePOSTz/oauth/tokenF)do_ratelimitingaccess_tokenz$Invalid request during oauth phase: Nz/api/v1/accountsT)r   access_token_overrideskip_error_checkerrorzInvalid request: refresh_token
expires_inr   zInvalid requestzGranted scopes "z." do not contain all of the requested scopes "z".w
)_Mastodon__generate_paramslocalsr   r   join_Mastodon__api_request	Exceptionr   r   _Mastodon__set_refresh_tokenget_Mastodon__set_token_expiredintsplitr   keyssetr   openwriteapi_base_url_Mastodon__logged_in_id)selfusernamepasswordemailr   reasonlocaler   r   return_detailed_errorparamsoauth_paramsresponsetemp_access_tokenereceived_scopes	scope_set
token_files                     _/home/feoh/.local/pipx/venvs/mastodon-archive/lib/python3.11/site-packages/mastodon/accounts.pycreate_accountzMastodon.create_account   sx   L ''9h2GHH"n{"&"4 	${#
	[L$'HHV$4$4L!(,L%,0,>L))=L&))&.,`e)ffH ( 8 	[ 	[ 	[./YVW/Y/YZZZ	[
	B))&2Df^c  |M  `d)  e  eH(""( *>)23Jq3J3JKKK ( 8D$$X\\/%B%BCCC$$SlA)F)F%G%GHHHH 	B 	B 	B./@AAA	B #7+11#66$)++ 	: 	:IO++;y#996{{c/2222"T388O#<#< T T?Bxx?O?OT T T  
 gs## ;z  .!9D!@AAA  !2T!9:::; ; ; ; ; ; ; ; ; ; ; ; ; ; ; #  	,N+R//N++sI   AB 
B5B00B59$E A=E 
E:&E55E:0<I88I<?I<c                 2    |                      dd           dS )z
        Requests a re-send of the users confirmation mail for an unconfirmed logged in user.

        Only available to the app that the user originally signed up with.
        r   z/api/v1/emails/confirmationsNr*   r7   s    rF   email_resend_confirmationz"Mastodon.email_resend_confirmationm   s!     	6#ABBBBB    z1.0.0c                 ^    |                      |          }|                     dd|           S )z
        Fetch account information by user `id`.

        Does not require authentication for publicly visible accounts.

        Returns a :ref:`account dict <account dict>`.
        GET/api/v1/accounts/_Mastodon__unpack_idr*   r7   ids     rF   accountzMastodon.accounty   s6     b!!!!%)AR)A)ABBBrL   z2.1.0c                 .    |                      dd          S )z
        Fetch logged-in user's account information.

        Returns a :ref:`account dict <account dict>` (Starting from 2.1.0, with an additional "source" field).
        rN   z#/api/v1/accounts/verify_credentialsrI   rJ   s    rF   account_verify_credentialsz#Mastodon.account_verify_credentials   s     !!%)NOOOrL   c                 *    |                                  S )z
        Get this user's account. Synonym for `account_verify_credentials()`, does exactly
        the same thing, just exists because `account_verify_credentials()` has a confusing
        name.
        )rV   rJ   s    rF   mezMastodon.me   s     ..000rL   z2.8.0c                 f   |                      |          }||                      |d          }||                      |d          }|	|                      |	d          }	|                     t                      dg          }|s|d= |s|d= |s|d= |s|d= |                     d	d
| d|          S )a  
        Fetch statuses by user `id`. Same options as :ref:`timeline() <timeline()>` are permitted.
        Returned toots are from the perspective of the logged-in user, i.e.
        all statuses visible to the logged-in user (including DMs) are
        included.

        If `only_media` is set, return only statuses with media attachments.
        If `pinned` is set, return only statuses that have been pinned. Note that
        as of Mastodon 2.1.0, this only works properly for instance-local users.
        If `exclude_replies` is set, filter out all statuses that are replies.
        If `exclude_reblogs` is set, filter out all statuses that are reblogs.
        If `tagged` is set, return only statuses that are tagged with `tagged`. Only a single tag without a '#' is valid.

        Does not require authentication for Mastodon versions after 2.7.0 (returns
        publicly visible statuses in that case), for publicly visible accounts.

        Returns a list of :ref:`status dicts <status dicts>`.
        NTdateconvrS   pinned
only_mediaexclude_repliesexclude_reblogsrN   rO   z	/statusesrQ   r'   r(   r*   )r7   rS   r]   r\   r^   r_   taggedmax_idmin_idsince_idlimitr>   s               rF   account_statuseszMastodon.account_statuses   s    ( b!!%%ft%<<F%%ft%<<F''4'@@H''4&99 	!x  	%|$ 	*() 	*()!!%)JR)J)J)JFSSSrL   z2.6.0c                 >   |                      |          }||                      |d          }||                      |d          }||                      |d          }|                     t                      dg          }|                     dd| d|          S )z{
        Fetch users the given user is following.

        Returns a list of :ref:`account dicts <account dicts>`.
        NTrZ   rS   rN   rO   z
/followingr`   r7   rS   rb   rc   rd   re   r>   s          rF   account_followingzMastodon.account_following        b!!%%ft%<<F%%ft%<<F''4'@@H''4&99!!%)KR)K)K)KVTTTrL   c                 >   |                      |          }||                      |d          }||                      |d          }||                      |d          }|                     t                      dg          }|                     dd| d|          S )z}
        Fetch users the given user is followed by.

        Returns a list of :ref:`account dicts <account dicts>`.
        NTrZ   rS   rN   rO   z
/followersr`   rh   s          rF   account_followerszMastodon.account_followers   rj   rL   z1.4.0c                     |                      |          }|                     t                                }|                     dd|          S )z
        Fetch relationship (following, followed_by, blocking, follow requested) of
        the logged in user to a given account. `id` can be a list.

        Returns a list of :ref:`relationship dicts <relationship dicts>`.
        rN   z/api/v1/accounts/relationshipsr`   r7   rS   r>   s      rF   account_relationshipszMastodon.account_relationships   sN     b!!''11!!%)I"(* * 	*rL   z2.3.0c                     |                      t                                }|d         dk    r|d= |                     dd|          S )a=  
        Fetch matching accounts. Will lookup an account remotely if the search term is
        in the username@domain format and not yet in the database. Set `following` to
        True to limit the search to users the logged-in user follows.

        Returns a list of :ref:`account dicts <account dicts>`.
        	followingFrN   z/api/v1/accounts/search)r'   r(   r*   )r7   qre   rq   resolver>   s         rF   account_searchzMastodon.account_search   sL     ''11+%''{#!!%)BFKKKrL   c                     |                      |          }|                     t                      dg          }|                     dd| d|          S )z
        Get all of the logged-in user's lists which the specified user is
        a member of.

        Returns a list of :ref:`list dicts <list dicts>`.
        rS   rN   rO   z/listsr`   rn   s      rF   account_listszMastodon.account_lists  sV     b!!''4&99!!%)GR)G)G)GPPPrL   c                 n    |                      dd|                     t                                          S )az  
        Look up an account from user@instance form (@instance allowed but not required for
        local accounts). Will only return accounts that the instance already knows about,
        and not do any webfinger requests. Use `account_search` if you need to resolve users
        through webfinger from remote.

        Returns an :ref:`account dict <account dict>`.
        rN   z/api/v1/accounts/lookup)r*   r'   r(   )r7   accts     rF   account_lookupzMastodon.account_lookup  s2     !!%)BDDZDZ[a[c[cDdDdeeerL   z3.5.0c                     t          |t                    s|g}t          t          |                    D ] }|                     ||                   ||<   !|                     ddd|id          S )z
        Find followers for the account given by id (can be a list) that also follow the
        logged in account.

        Returns a list of :ref:`familiar follower dicts <familiar follower dicts>`
        rN   z#/api/v1/accounts/familiar_followersrS   T)use_json)
isinstancelistrangelenrQ   r*   )r7   rS   is      rF   account_familiar_followersz#Mastodon.account_familiar_followers  s{     "d## 	Bs2ww 	, 	,A$$RU++BqEE!!%)NQUWYPZei!jjjrL   z3.3.0Tc                     |                      |          }|                     t                      dg          }|d         |d= |                     dd| d|          S )a-  
        Follow a user.

        Set `reblogs` to False to hide boosts by the followed user.
        Set `notify` to True to get a notification every time the followed user posts.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        rS   reblogsNr   rO   z/followr`   )r7   rS   r   notifyr>   s        rF   account_followzMastodon.account_follow/  si     b!!''4&99)$y!!!&*Ib*I*I*I6RRRrL   c                     	 |                      |          d         }n#  t          d          xY w|                     |          S )a  
        Follow a remote user with username given in username@domain form.

        Returns a :ref:`account dict <account dict>`.

        Deprecated - avoid using this. Currently uses a backwards compat implementation that may or may not work properly.
        r   zUser not found)rt   r   r   )r7   urirx   s      rF   followszMastodon.followsA  sM    	:&&s++A.DD	:'(8999""4(((s    /c                 `    |                      |          }|                     dd| d          S )z
        Unfollow a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z	/unfollowrP   rR   s     rF   account_unfollowzMastodon.account_unfollowP  s9     b!!!!&*Kb*K*K*KLLLrL   c                 `    |                      |          }|                     dd| d          S )z
        Remove a user from the logged in users followers (i.e. make them unfollow the logged in
        user / "softblock" them).

        Returns a :ref:`relationship dict <relationship dict>` reflecting the updated following status.
        r   rO   z/remove_from_followersrP   rR   s     rF   account_remove_from_followersz&Mastodon.account_remove_from_followersZ  s9     b!!!!&*Xb*X*X*XYYYrL   c                 `    |                      |          }|                     dd| d          S )z
        Block a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z/blockrP   rR   s     rF   account_blockzMastodon.account_blocke  9     b!!!!&*Hb*H*H*HIIIrL   c                 `    |                      |          }|                     dd| d          S )z
        Unblock a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z/unblockrP   rR   s     rF   account_unblockzMastodon.account_unblocko  s9     b!!!!&*Jb*J*J*JKKKrL   z1.1.0z2.4.3c                     |                      |          }|                     t                      dg          }|                     dd| d|          S )ao  
        Mute a user.

        Set `notifications` to False to receive notifications even though the user is
        muted from timelines. Pass a `duration` in seconds to have Mastodon automatically
        lift the mute after that many seconds.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        rS   r   rO   z/muter`   )r7   rS   notificationsdurationr>   s        rF   account_mutezMastodon.account_mutey  sV     b!!''4&99!!&*Gb*G*G*GPPPrL   c                 `    |                      |          }|                     dd| d          S )z
        Unmute a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z/unmuterP   rR   s     rF   account_unmutezMastodon.account_unmute  s9     b!!!!&*Ib*I*I*IJJJrL   z1.1.1z3.1.0c                    t          j        t                                }|
Nt          |
          dk    rt	          d          g }t          |
          D ]\  }\  }}||d| d<   ||d| d<   dD ]	}||v r||= 
i }||                     ||          |d<   ||                     ||          |d	<   |                     |          }|                     d
d||          S )a  
        Update the profile for the currently logged-in user.

        `note` is the user's bio.

        `avatar` and 'header' are images. As with media uploads, it is possible to either
        pass image data and a mime type, or a filename of an image file, for either.

        `locked` specifies whether the user needs to manually approve follow requests.

        `bot` specifies whether the user should be set to a bot.

        `discoverable` specifies whether the user should appear in the user directory.

        `fields` can be a list of up to four name-value pairs (specified as tuples) to
        appear as semi-structured information in the user's profile.

        Returns the updated `account dict` of the logged-in user.
        N   z%A maximum of four fields are allowed.zfields_attributes[z][name]z][value])avataravatar_mime_typeheaderheader_mime_typefieldsr   r   PATCHz#/api/v1/accounts/update_credentials)files)	collectionsOrderedDictr(   r   r   	enumerate_Mastodon__load_media_filer'   r*   )r7   display_namenoter   r   r   r   lockedbotdiscoverabler   params_initialfields_attributesidx
field_namefield_valueparamr   r>   s                      rF   account_update_credentialsz#Mastodon.account_update_credentials  s>   2 %0:: 6{{Q2;= = = !#2;F2C2C Q Q..j+DN@C@@@AEPACAAABB \ 	* 	*E&&"5) "44V=MNNE(O"44V=MNNE(O''77!!'+PRX`e!fffrL   z2.5.0c                 `    |                      |          }|                     dd| d          S )z
        Pin / endorse a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z/pinrP   rR   s     rF   account_pinzMastodon.account_pin  s9     b!!!!&*Fb*F*F*FGGGrL   c                 `    |                      |          }|                     dd| d          S )z
        Unpin / un-endorse a user.

        Returns a :ref:`relationship dict <relationship dict>` containing the updated relationship to the user.
        r   rO   z/unpinrP   rR   s     rF   account_unpinzMastodon.account_unpin  r   rL   z3.2.0c                     |                      |          }|                     t                      dg          }|                     dd| d|          S )z
        Set a note (visible to the logged in user only) for the given account.

        Returns a :ref:`status dict <status dict>` with the `note` updated.
        rS   r   rO   z/noter`   )r7   rS   commentr>   s       rF   account_note_setzMastodon.account_note_set  sV     b!!''4&99!!&*Gb*G*G*GPPPrL   c                 `    |                      |          }|                     dd| d          S )z
        Get an account's featured hashtags.

        Returns a list of :ref:`hashtag dicts <hashtag dicts>` (NOT `featured tag dicts`_).
        rN   rO   z/featured_tagsrP   rR   s     rF   account_featured_tagszMastodon.account_featured_tags  s9     b!!!!%)OR)O)O)OPPPrL   )	FFFFNNNNN)NNNN)NFF)TF)TN)
NNNNNNNNNN)%__name__
__module____qualname__r   r
   rG   rK   r   rT   rV   rX   r   rf   ri   rl   r   ro   rt   r   rv   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r	   r    rL   rF   r   r      s       ['7++BGPT]ajy  DH  `e \, \, \, ,+\,| ['7++C C ,+C ['#899	C 	C :9	C ['#899P P :9P ['#8991 1 :91 ['#788'T 'T 'T 98'TR ['#899U U U :9U& ['#899U U U :9U& ['#=>>
* 
* ?>
* ['#899L L L :9L ['#566	Q 	Q 76	Q ['#899	f 	f :9	f ['#CDDk k EDk  ['#=>>S S S ?>S" ['#899) ) :9) ['#=>>M M ?>M ['#=>>Z Z ?>Z ['#=>>J J ?>J ['#=>>L L ?>L ['#=>>Q Q Q ?>Q ['#=>>K K ?>K ['#899AEAEAE48=A	2g 2g 2g :92gh ['#=>>H H ?>H ['#=>>J J ?>J ['#=>>Q Q ?>Q ['#899Q Q :9Q Q QrL   r   )r   versionsr   r   r   r   r   r	   defaultsr
   r   errorsr   r   r   utilityr   	internalsr   	Internalsr   rL   rF   <module>r      s       k  k  k  k  k  k  k  k  k  k  k  k  k  k  k  k 2 2 2 2 2 2 2 2 Y Y Y Y Y Y Y Y Y Y             , , , , , ,aQ aQ aQ aQ aQy aQ aQ aQ aQ aQrL   