a
    bg                     @  sl   d Z ddlmZ ddlZddlZddlmZ er<ddlmZ e	e
Zddddd	Zd
dddZdZdS )zO365 tool utils.    )annotationsN)TYPE_CHECKINGAccountstr)bodyreturnc                 C  s   zlddl m} z>|t| d}| } d|  } d|  } t| W W S  tyh   t|  Y W S 0 W n ty   t|  Y S 0 dS )z!Clean body of a message or event.r   )BeautifulSoupzhtml.parser  N)	Zbs4r	   r   Zget_textjoin
splitlinessplit	ExceptionImportError)r   r	   Zsoup r   w/var/www/html/cobodadashboardai.evdpl.com/venv/lib/python3.9/site-packages/langchain_community/tools/office365/utils.py
clean_body   s    r   r   )r   c               
   C  s   zddl m}  W n. ty> } ztd|W Y d}~n
d}~0 0 dtjv rrdtjv rrtjd }tjd }||f}ntd dS | |}|jdu r|jg d	d
st	d dS |S n|S dS )z*Authenticate using the Microsoft Graph APIr   r   zGCannot import 0365. Please install the package with `pip install O365`.NZ	CLIENT_IDZCLIENT_SECRETzError: The CLIENT_ID and CLIENT_SECRET environmental variables have not been set. Visit the following link on how to acquire these authorization tokens: https://learn.microsoft.com/en-us/graph/auth/F)z*https://graph.microsoft.com/Mail.ReadWritez%https://graph.microsoft.com/Mail.Sendz/https://graph.microsoft.com/Calendars.ReadWritez5https://graph.microsoft.com/MailboxSettings.ReadWrite)ZscopeszError: Could not authenticate)
O365r   r   osenvironloggererroris_authenticatedauthenticateprint)r   eZ	client_idZclient_secretcredentialsaccountr   r   r   r   &   s2    



r   z%Y-%m-%dT%H:%M:%S%z)__doc__
__future__r   loggingr   typingr   r   r   	getLogger__name__r   r   r   Z
UTC_FORMATr   r   r   r   <module>   s   
(