403Webshell
Server IP : 157.230.181.24  /  Your IP : 216.73.217.11
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux conductive 6.8.0-117-generic #117-Ubuntu SMP PREEMPT_DYNAMIC Tue May 5 19:26:24 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/smarterchild/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/smarterchild/__pycache__/user_store.cpython-312.pyc
�

G=`j����dZddlmZddlZddlZddlZddlmZmZddlm	Z	ddl
mZed�Zejdd�	�dd
�Zdd�ZGd�d
�Zy)z>Per-buddy profile, survey answers, notes, and long-term facts.�)�annotationsN)�datetime�timezone)�SequenceMatcher)�Pathz/opt/smarterchild/dataT��parents�exist_okc��tjtj�j	d��j�S)Nr)�microsecond)r�nowr�utc�replace�	isoformat���/opt/smarterchild/user_store.py�_now_isors,���<�<����%�-�-�!�-�<�F�F�H�Hrc
�2�|ddddddddd�iggdddd�ddd�S)N���name�age�city�zip�band�movie�color�foodr)�score�asked�streak)�buddy�profile�survey�notes�facts�quiz�flow�
updated_atr)r#s r�
_default_userr+sG�����������	
�����a�1�5���#�rc��eZdZefdd�Zdd�Zdd�Zdd�Zedd��Z	ddd�Z
ddd�Zdd�Zdd	�Z
dd
�Zdd�Zdd�Zdd
�Zy)�	UserStorec��||_|jjdd��tj�|_i|_y)NTr)�root�mkdir�	threading�Lock�_lock�_cache)�selfr/s  r�__init__zUserStore.__init__+s2����	��	�	����t��4��^�^�%��
�')��rc�x�tjdd|j��xsd}|j|�d�zS)Nz[^\w.-]rr#z.json)�re�sub�lowerr/)r5r#�safes   r�_pathzUserStore._path1s4���v�v�j�"�e�k�k�m�4�?����y�y�d�V�5�>�)�)rc�t�|j�}|j5||jvr|j|cddd�S|j|�}|j	�r$tj|j��}nt|�}||j|<|cddd�S#1swYyxYw)N)	r:r3r4r<�exists�json�loads�	read_textr+)r5r#�key�path�datas     r�loadzUserStore.load5s����k�k�m��
�Z�Z�		��d�k�k�!��{�{�3�'�		�		��:�:�e�$�D��{�{�}��z�z�$�.�.�"2�3��$�U�+��#�D�K�K����		�		�		�s�B.�A B.�.B7c���|j�}t�|d<|j|�jt	j
|d��dz�||j|<y)Nr*�)�indent�
)r:rr<�
write_textr?�dumpsr4)r5r#rDrBs    r�savezUserStore.saveBsN���k�k�m��%�Z��\���
�
�5��$�$�T�Z�Z��Q�%?�$�%F�G�����C�rc��td|j�j�|j�j��j�dk\S)Ng=
ףp=�?)rr:�strip�ratio)�a�bs  r�_similarzUserStore._similarHs:���t�Q�W�W�Y�_�_�%6����	���8I�J�P�P�R�VZ�Z�Zrc	�:�|j�}t|�dkry|j5|j|�}t	|jdg��}|D]s}|j
||jdd��s�&||d<t�|d<|xs|jdd�|d<|dd|d<|j||�ddd�y|j|t�|d��|dd|d<|j||�ddd�y#1swYyxYw)	N�r'�textr�
learned_at�sourcei����)rUrVrW)
rN�lenr3rE�list�getrRrrL�append)r5r#rUrWrDr'�fs       r�add_factzUserStore.add_factLs
���z�z�|���t�9�q�=��
�Z�Z�
	#��9�9�U�#�D� $�T�X�X�g�r�%:� ;�E��
���=�=��q�u�u�V�R�'8�9� $�A�f�I�&.�j�A�l�O�"(�"?�A�E�E�(�B�,?�A�h�K�$)�#�$�K�D��M��I�I�e�T�*��
	#�
	#�
�
�L�L�$�h�j�F�S�T�!�#�$�K�D��M��I�I�e�T�"�
	#�
	#�
	#�s�AD�AD�8D�Dc�:�|D]}|j|||���y)N)rW)r])r5r#�	new_factsrW�facts     r�	add_factszUserStore.add_facts_s#���	6�D��M�M�%��f�M�5�	6rc�0�|j�}|sy|j5|j|�}t|j	dg��}|j|t
�d��|dd|d<|j||�ddd�y#1swYyxYw)Nr&)rU�ati��)rNr3rErYrZr[rrL)r5r#rUrDr&s     r�add_notezUserStore.add_notecs����z�z�|����
�Z�Z�	#��9�9�U�#�D�����'�2�.�/�E��L�L�$�h�j�9�:�!�#�$�K�D��M��I�I�e�T�"�	#�	#�	#�s�A#B�Bc��|j5|j|�}||d<|j||�ddd�y#1swYyxYw�Nr))r3rErL)r5r#r)rDs    r�set_flowzUserStore.set_flownsC��
�Z�Z�	#��9�9�U�#�D��D��L��I�I�e�T�"�	#�	#�	#�s	�)?�Ac�B�|j|�jd�Srf)rErZ)r5r#s  r�get_flowzUserStore.get_flowts���y�y���#�#�F�+�+rc�l�|j5|j|�}t|jd�xsi�}||vr|j	�||<||d<t|jd�xsi�}|j	�||<||d<|j||�ddd�y#1swYyxYw)Nr$r%)r3rE�dictrZrNrL)r5r#�field�valuerD�profr%s       r�set_profile_fieldzUserStore.set_profile_fieldws���
�Z�Z�		#��9�9�U�#�D������+�1�r�2�D���}�#�k�k�m��U��"�D��O��$�(�(�8�,�2��3�F�!�K�K�M�F�5�M�#�D��N��I�I�e�T�"�		#�		#�		#�s�BB*�*B3c��|j|�}g}|jd�xsi}|j�D��cic]\}}|s�	||��
}}}|r:djd�|j�D��}|j	d|���|jd�xsi}	|	r8|j	ddjd�|	j�D��z�|jd�xsg}
|
d	dD]9}|jd
d�j�}|s�&|j	d|����;|syd
dj|�zScc}}w)Nr$z, c3�0K�|]\}}|�d|�����y�w��=Nr��.0�k�vs   r�	<genexpr>z.UserStore.format_for_prompt.<locals>.<genexpr>�s����C�D�A�q��s�!�A�3�Z�C���zProfile you already know: r%zSurvey answers: c3�0K�|]\}}|�d|�����y�wrrrrts   rrxz.UserStore.format_for_prompt.<locals>.<genexpr>�s����7^�t�q�!�1�#�Q�q�c�
�7^�ryr'i��rUr�- ujWHAT YOU REMEMBER ABOUT THIS USER (SmarterChild-style — use naturally, don't say 'stored in database'):
rI)rErZ�items�joinr[rN)
r5r#rD�linesrnrvrw�filled�bitsr%r'�item�ts
             r�format_for_promptzUserStore.format_for_prompt�s5���y�y�������x�x�	�"�(�b��#'�:�:�<�5�4�1�a�1�!�Q�$�5��5���9�9�C�F�L�L�N�C�C�D��L�L�5�d�V�<�=����(�#�)�r����L�L�+�d�i�i�7^�v�|�|�~�7^�.^�^�_�����!�'�R���#�$�K�	'�D������$�*�*�,�A�����r�!��X�&�	'���y��i�i���
�	
��6s�
E�Ec	��|j|�}|jd�xsi}dg}ddddddd	d
d�}d}|j�D]D\}}|j|�xsd
j�}	|	s�,d}|j	d|�d|	����F|jd�xsg}
|
rTd}|j	d�|
ddD]9}|jdd
�j�}|s�&|j	d|����;|jd�xsg}
|
r d}|j	dt|
��d��|s	y|j	d�dj
|�S)Nr$zHere's what I know about you:�Name�Age�City�Zipz
Favorite bandzFavorite moviezFavorite colorz
Favorite foodrFrTr{z: r'z- Other stuff you told me:i����rUu  · r&z- Saved notes: z (type notes to list)ztI don't know much about you yet! Type survey to answer a few fun questions, or just tell me stuff and I'll remember.zJType survey anytime to update, or profile setup to walk through questions.� )rErZr|rNr[rXr})r5r#rDrnr~�labels�any_setrB�label�valr'r�r�r&s              r�format_profile_displayz UserStore.format_profile_display�st���y�y�����x�x�	�"�(�b��0�1������#�%�%�#�	
���� �,�,�.�	2�J�C���8�8�C�=�&�B�-�-�/�C�������r�%���3�%�0�1�		2�
����!�'�R����G��L�L�5�6��b�c�
�
.���H�H�V�R�(�.�.�0����L�L�5����-�
.�����!�'�R����G��L�L�?�3�u�:�,�6K�L�M��;�
�	���a�b��x�x���rN)r/r�return�None)r#�strr�r�r#r�r�rk)r#r�rDrkr�r�)rPr�rQr�r��bool)r)r#r�rUr�rWr�r�r�)r#r�r_z	list[str]rWr�r�r�)r#r�rUr�r�r�)r#r�r)�dict | Noner�r�)r#r�r�r�)r#r�rlr�rmr�r�r�)r#r�r�z
str | None)r#r�r�r�)�__name__�
__module__�__qualname__�ROOTr6r<rErL�staticmethodrRr]rardrgriror�r�rrrr-r-*sW��$(�*�*�� ��[��[�#�&6�	#�#�,�
#�
�.&rr-)r�r�r�)�__doc__�
__future__rr?r8r1rr�difflibr�pathlibrr�r0rr+r-rrr�<module>r�sO��D�"��	��'�#���$�%���
�
�4�$�
�'�I��,V�Vr

Youez - 2016 - github.com/yon3zu
LinuXploit