← back to Zendesk Chat Analyzer

__pycache__/recent.cpython-314.pyc

33 lines

+
�F{j����Rt^RIt^RIt^RIt^RIt^RIt^RIt^RIt]PPR4t]!R]
!R]!]PP!RR4444tRtRtR	tR
t]R8Xd
]!4R#R#)z�Fetch RECENT chats (last N hours) from Zendesk Chat and print JSON to stdout.
Used by the server's /api/recent for the Live feed. Token stays server-side.Nz~/Projects/secrets-manager/.envg�?ge@�HOURS�8z.https://www.zopim.com/api/v2/incremental/chatsc��\PPR4'd&\PR,P4#\	\
4FapVP
R4'gKVPR^4^,P4PR4PR4u#	\R4h \dLi;i)�ZENDESK_CHAT_ACCESS_TOKENzZENDESK_CHAT_ACCESS_TOKEN=�=�"�'zno token)
�os�environ�get�strip�open�ENV�
startswith�split�	Exception�
SystemExit)�lines �	recent.py�tokenrs���	�z�z�~�~�1�2�2��z�z�5�6�<�<�>�>�
���I�D����;�<�<��z�z�#�q�)�!�,�2�2�4�:�:�3�?�E�E�c�J�J��
�Z�
 � ���
��
�s�&C�7AC�>C�C�Cc��V'gR#\P!RR\P!RV4^,4P4#)�z\s+� u![–\-|]\s*Designer Wallcoverings)�re�subrr)�ts&r�clean_titlers6����
�6�6�&�#�r�x�x�(L�a�P�QR�S�T�Z�Z�\�\�c$��	aa�\4p\\P!4\R,,
4p\R,\
PPRRRV/4,p.^rCV'Ed[V^8EdS\
PPVRRV,/R7p\P!\
PPV^R74pT^,
pTP#R
.4EF�pTP#R4;'g/p	TP#R
4;'g.p
T
Uu.uFvp\%T\&4'gK\!TP#RR44P)4R8XgKKTP#R4'gKdTP#RR4NKx	ppT'g*TP#R4'dTP#R4.pTP+RTP#R4RTP#R4RTP#R4RT	P#R4;'gRRT	P#R4;'gRRT	P#R4;'gRRT	P#R4;'gRRT	P#R4;'gRRTP#R 4;'g.R!\-TP#R!44R"TP#R"4;'gRRR#P/T4R$,R%TP#R&4;'g.U
u.uF5q�P#R'4'gK\1T
P#R'44NK7	up
R(,/
4EK�	TP#R)4q�P#R*4pTP#R
4'd	T'gMT'dTMRpEKc^RIo\P!4\R,,
oVV3R+lpVUu.uFpV!V4'gKVNK	ppVP5R,R-R.7\\P!R/\\P!44R0\R1\7V4R
VR2,/44R# \d8p\\P!R	\!T4R
./44Rp?R#Rp?ii;iuupiuup
iuupi)3i�?�fieldszchats(*)�
start_time�
AuthorizationzBearer )�headers)�timeout�error�chatsN�session�history�sender_typer�visitor�msg�comment�id�ts�	timestamp�type�country�country_name�Unknown�country_codez??�city�region�platform�agents�agent_names�missed�ratingu · :N��N�browsed�webpath�title:N�N�end_time�	next_pagec�<�SP\P!VR,R44S8�# \dR#i;i)r.z%Y-%m-%dT%H:%M:%SZF)�timegm�time�strptimer)�r�calendar�cutoffs&��r�started�main.<locals>.started?s?���	��?�?�4�=�=��4��:N�#O�P�TZ�Z�Z���	��	�s�/3�A�Ac�8�VPR4;'gR#)r.r)r)rGs&r�<lambda>�main.<locals>.<lambda>Es��A�E�E�$�K�-�-�2�-rT)�key�reverse�now�hours�count:N�<N)r�intrEr�BASE�urllib�parse�	urlencode�request�Request�json�load�urlopenr�print�dumps�strr�
isinstance�dict�lower�append�bool�joinrrH�sort�len)�tok�start�url�rows�pages�req�d�e�c�s�hist�h�vmsgs�w�end�nxtrJrGrHrIs                  @@r�mainrzs����
�'�C���	�	��e�d�l�*�+�E�
��*�v�|�|�-�-�x��\�SX�.Y�Z�
Z�C��a�%�

�#�%�"�*��n�n�$�$�S�?�I�PS�O�2T�$�U��	F��	�	�&�.�.�0�0��b�0�A�B�A�	��
�����w��#�A����i� �&�&�B�A��5�5��#�)�)�r�D�/3�u�t�!�"�1�d�+�&�03�A�E�E�-��4L�0M�0S�0S�0U�Yb�0b�&�gh�gl�gl�mr�gs�&�Q�U�U�5�"�%�t�E�u��Q�U�U�9�-�-����y�)�*���K�K��a�e�e�D�k�4����{�);�V�Q�U�U�6�]��1�5�5��0�=�=�I�~�q�u�u�Uc�Od�Ol�Ol�hl�����f�
�+�+��X�q�u�u�X��7L�7L�"�j�Z[�Z_�Z_�`j�Zk�Zq�Zq�oq��!�%�%�
�.�4�4�"�h��Q�U�U�8�_�@U��!�%�%��/�/�/�R�����E�8J�4�8P��!�%�%�	�BR�BX�BX�VX�BX�l�BX�A�]b�]b�cj�]k�7�K����g��7�BX�l�mo�p�
�
�$��e�e�J���u�u�[�'9���u�u�W�~�~�S���c�d���
�Y�Y�[�5�4�<�
'�F��
�*�t�!�w�q�z�A�A�t�D�*��I�I�-�t�I�<�	�$�*�*�e�S�����-�w��w��D�	�SZ�\`�ad�\e�f�
g�h��A�	F��$�*�*�g�s�1�v�w��;�<�=�v��	F��u��m��+sH�15R�?S�+S�S�%S�9S"<�S"<�S'�#S'�S�#,S�S�__main__)�__doc__r\r	r�sysrE�urllib.requestrW�urllib.parse�path�
expanduserr�max�min�floatr
rrrVrrrz�__name__�rr�<module>r�s~��P�<�<�<�<��g�g���:�;���C��U�E�"�*�*�.�.��#�">�?�@�A��7��	!�]�)i�X�z���F�r