
    bf                     r    d dl mZmZmZmZmZ d dlmZmZ d dl	m
Z
 d dlmZ d dlmZ  G d de          ZdS )	   )_DICT_VERSION_INSTANCE_DICT_VERSION_ACTIVITY_DICT_VERSION_ACCOUNT_DICT_VERSION_EMOJI_DICT_VERSION_ANNOUNCEMENT)MastodonIllegalArgumentErrorMastodonNotFoundError)api_version)urlparse)Mastodonc                   (   e Zd Z edde          d             Zd Z edde          d             Z eddd          d             Z	 eddd          d	             Z
 eddd          dd            Z edde          d             Z edde          dd            Z edde          d             Z edde          d             Z eddd          d             Z eddd          d             Z eddd          d             ZdS )r   z1.1.0z2.3.0c                 *    |                                  S )a   
        Retrieve basic information about the instance, including the URI and administrative contact email.

        Does not require authentication unless locked down by the administrator.

        Returns an :ref:`instance dict <instance dict>`.
        )_Mastodon__instanceselfs    _/home/feoh/.local/pipx/venvs/mastodon-archive/lib/python3.11/site-packages/mastodon/instance.pyinstancezMastodon.instance   s            c                 2    |                      dd          }|S )zX
        Internal, non-version-checking helper that does the same as instance()
        GETz/api/v1/instance/_Mastodon__api_request)r   r   s     r   
__instancezMastodon.__instance   s     %%e-@AAr   z2.1.2c                 .    |                      dd          S )a2  
        Retrieve activity stats about the instance. May be disabled by the instance administrator - throws
        a MastodonNotFoundError in that case.

        Activity is returned for 12 weeks going back from the current week.

        Returns a list of :ref:`activity dicts <activity dicts>`.
        r   z/api/v1/instance/activityr   r   s    r   instance_activityzMastodon.instance_activity!   s     !!%)DEEEr   c                 .    |                      dd          S )z
        Retrieve the instances that this instance knows about. May be disabled by the instance administrator - throws
        a MastodonNotFoundError in that case.

        Returns a list of URL strings.
        r   z/api/v1/instance/peersr   r   s    r   instance_peerszMastodon.instance_peers-   s     !!%)ABBBr   z3.0.0c                 `    |                      ddd                              d          }|dv S )zL
        Basic health check. Returns True if healthy, False if not.
        r   z/healthF)parsezutf-8)OKsuccess)r   decode)r   statuss     r   instance_healthzMastodon.instance_health7   s8    
 ##E9E#BBII'RR***r   /http://nodeinfo.diaspora.software/ns/schema/2.0c                 d   |                      dd          d         }d}|D ]}|j        |k    r|j        }|t          d          	 |                      d|d          S # t          $ rE t          |          }|                      d|j        |j        z   |j        z   |j	        z             cY S w xY w)a~  
        Retrieves the instance's nodeinfo information.

        For information on what the nodeinfo can contain, see the nodeinfo
        specification: https://github.com/jhass/nodeinfo . By default,
        Mastodon.py will try to retrieve the version 2.0 schema nodeinfo.

        To override the schema, specify the desired schema with the `schema`
        parameter.
        r   z/.well-known/nodeinfolinksNz+Requested nodeinfo schema is not available. )base_url_override)
r   relhrefr   r	   r   pathparamsqueryfragment)r   schemar'   
schema_urlavailable_schemar   s         r   instance_nodeinfozMastodon.instance_nodeinfo?   s     ""5*ABB7K
 % 	3 	3#v---2
.=? ? ?	g%%eZ2%NNN$ 	g 	g 	gZ((E%%eUZ%,-F-TW\We-efffff	gs   A   AB/.B/z3.4.0c                 .    |                      dd          S )z
        Retrieve instance rules.

        Returns a list of `id` + `text` dicts, same as the `rules` field in the :ref:`instance dicts <instance dicts>`.
        r   z/api/v1/instance/rulesr   r   s    r   instance_ruleszMastodon.instance_rules\   s     !!%)ABBBr   Nc                 r    |                      t                                }|                     dd|          S )a  
        Fetch the contents of the profile directory, if enabled on the server.

        `offset` how many accounts to skip before returning results. Default 0.

        `limit` how many accounts to load. Default 40.

        `order` "active" to sort by most recently posted statuses (default) or
                "new" to sort by most recently created profiles.

        `local` True to return only local accounts.

        Returns a list of :ref:`account dicts <account dicts>`.

        r   z/api/v1/directory)_Mastodon__generate_paramslocalsr   )r   offsetlimitorderlocalr-   s         r   	directoryzMastodon.directoryh   s4    " ''11!!%)<fEEEr   z2.1.0c                 .    |                      dd          S )z
        Fetch the list of custom emoji the instance has installed.

        Does not require authentication unless locked down by the administrator.

        Returns a list of :ref:`emoji dicts <emoji dicts>`.
        r   z/api/v1/custom_emojisr   r   s    r   custom_emojiszMastodon.custom_emojis   s     !!%)@AAAr   z3.1.0c                 .    |                      dd          S )z
        Fetch currently active announcements.

        Returns a list of :ref:`announcement dicts <announcement dicts>`.
        r   z/api/v1/announcementsr   r   s    r   announcementszMastodon.announcements   s     !!%)@AAAr   c                 d    |                      |          }|                     dd| d           dS )z4
        Set the given annoucement to read.
        POST/api/v1/announcements/z/dismissN_Mastodon__unpack_idr   )r   ids     r   announcement_dismisszMastodon.announcement_dismiss   s?    
 b!!6#HB#H#H#HIIIIIr   c                 h    |                      |          }|                     dd| d|            dS )a  
        Add a reaction to an announcement. `reaction` can either be a unicode emoji
        or the name of one of the instances custom emoji.

        Will throw an API error if the reaction name is not one of the allowed things
        or when trying to add a reaction that the user has already added (adding a
        reaction that a different user added is legal and increments the count).
        PUTrD   /reactions/NrE   r   rG   reactions      r   announcement_reaction_createz%Mastodon.announcement_reaction_create   sD     b!!5"T2"T"T("T"TUUUUUr   c                 h    |                      |          }|                     dd| d|            dS )zx
        Remove a reaction to an announcement.

        Will throw an API error if the reaction does not exist.
        DELETErD   rK   NrE   rL   s      r   announcement_reaction_deletez%Mastodon.announcement_reaction_delete   sD     b!!8%Wb%W%WX%W%WXXXXXr   )r%   )NNNN)__name__
__module____qualname__r
   r   r   r   r   r   r   r$   r3   r5   r   r=   r   r?   r   rA   rH   rN   rQ    r   r   r   r      sM        ['#9::! ! ;:!   ['#9::	F 	F ;:	F ['7++C C ,+C ['7+++ + ,++ ['7++g g g ,+g8 ['#9::C C ;:C ['#899F F F :9F, ['#677B B 87B ['#=>>B B ?>B ['7++J J ,+J ['7++V V ,+V ['7++Y Y ,+Y Y Yr   r   N)versionsr   r   r   r   r   errorsr   r	   utilityr
   compatr   	internalsr   	InternalsrU   r   r   <module>r\      s    M  M  M  M  M  M  M  M  M  M  M  M  M  M G G G G G G G G                   , , , , , ,nY nY nY nY nYy nY nY nY nY nYr   