Skip to main content
Glama

chesscom-mxcp

other_tools.cpython-311.pyc5.43 kB
� ��[h����dZddlmZmZmZddlmZmZddlm Z de dee ee ffd�Z de dee effd �Z de dee effd �Z d S) z* Chess.com titled players and club tools. �)�Dict�Any�List)�make_api_request� get_cache_ttl)�db�title�returnc��pK�gd�}||vrddd�|����iSd|��}td��} t||����d{V��}|�d g��}t jd |t |��|d ���|S#t$r}gt|��d �cYd}~Sd}~wwxYw) z� Get a list of titled players from Chess.com. Args: title: Chess title (GM, WGM, IM, WIM, FM, WFM, NM, WNM, CM, WCM) Returns: Dictionary with 'players' list containing usernames ) �GM�WGM�IM�WIM�FM�WFM�NM�WNM�CM�WCM�errorzInvalid title. Must be one of: z, ztitled/�titled_players�� cache_ttlN�playersa- INSERT INTO titled_players_snapshot (title, player_count, players_list, snapshot_date) VALUES ($title, $count, $players, CURRENT_DATE) ON CONFLICT (title, snapshot_date) DO UPDATE SET player_count = $count, players_list = $players )r �countr)rr) �joinrr�getr�execute�len� Exception�str)r � valid_titles�endpointr�datar�es �+/home/yori/chess-mxcp/python/other_tools.py�get_titled_playersr' s����U�T�T�L� �L� � ��T�4�9�9�\�;R�;R�T�T�U�U� �� � �H��.�/�/�I�0�%�h�)�D�D�D�D�D�D�D�D�D���(�(�9�b�)�)�� � � ����\�\�� � � � � �� �� �0�0�0���A���/�/�/�/�/�/�/�/�����0���s�AB� B5�B0�*B5�0B5�url_idc ��:K�d|��}td��} t||����d{V��}tjd||�dd��|�dd ��d ���|S#t $r}d d t |����icYd}~Sd}~wwxYw) z� Get information about a club on Chess.com. Args: url_id: The URL identifier of the club Returns: Club profile data including name, description, members count, etc. �club/� club_inforNz� INSERT INTO club_statistics (club_id, club_name, member_count, checked_at) VALUES ($id, $name, $members, CURRENT_TIMESTAMP) �name�� members_countr)�idr,�membersrzFailed to fetch club profile: )rrrrrr r!)r(r#rr$r%s r&�get_club_profiler10s����� �v���H��k�*�*�I�D�%�h�)�D�D�D�D�D�D�D�D�D�� � � � ��H�H�V�R�(�(��x�x���3�3� � �  � � �� �� �D�D�D��B�#�a�&�&�B�B�C�C�C�C�C�C�C�����D���s�AA2�2 B�<B�B�Bc��K�d|�d�}td��} t||����d{V��}t��}dD]7}|�|g��}|�d�|D�����8t jd|t|��t|��d ���|S#t$r}d d t|����icYd}~Sd}~wwxYw) z� Get members of a club on Chess.com. Args: url_id: The URL identifier of the club Returns: Dictionary with lists of members by type (weekly, monthly, all_time) r*z/membersr+rN)�weekly�monthly�all_timec3�PK�|]!}t|t���|dV��"dS)�usernameN)� isinstance�dict)�.0�members r&� <genexpr>z#get_club_members.<locals>.<genexpr>ds8����d�d�f�:�V\�^b�Kc�Kc�d�v�j�1�d�d�d�d�d�d�a, INSERT INTO club_member_snapshots (club_id, member_count, members_list, snapshot_date) VALUES ($id, $count, $members, CURRENT_DATE) ON CONFLICT (club_id, snapshot_date) DO UPDATE SET member_count = $count, members_list = $members )r/rr0rzFailed to fetch club members: ) rr�setr�updaterrr�listr r!)r(r#rr$� all_members� member_typer0r%s r&�get_club_membersrCPs5����(�v�'�'�'�H��k�*�*�I�D�%�h�)�D�D�D�D�D�D�D�D�D���e�e� �<� e� e�K��h�h�{�B�/�/�G� � � �d�d��d�d�d� d� d� d� d� � � ����%�%��K�(�(� � � � � �� �� �D�D�D��B�#�a�&�&�B�B�C�C�C�C�C�C�C�����D���s�BB-�- C�7C� C�CN)�__doc__�typingrrr� chess_clientrr� mxcp.runtimerr!r'r1rC�r=r&�<module>rIs�����#�"�"�"�"�"�"�"�"�"�8�8�8�8�8�8�8�8�������$0�C�$0�D��d�3�i��,@�$0�$0�$0�$0�ND�3�D�4��S��>�D�D�D�D�@$D�3�$D�4��S��>�$D�$D�$D�$D�$D�$Dr=

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/datYori/chesscom-mxcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server