o
    `h                     @   sN   d dl Z d dlZd dlZd dlmZ d dlmZ d dlZg i ddfddZdS )    N)platform_config)get_all_platformFc                    sD  | D ]}t |}z|d|d }|d}|d}t|  }	tj|||	d|dd}
|
jdkr|
	 d	}|d
 |d}|d}|d}|d}t
||d|d d}tt fdd|d }|d}|d|d d|  }dddd| d} ||dd|sdnddddd	}tj|||d}|jdkrt| d |d| d|sdnd d   d!|s| d"| nd# d$|s| d"| nd# d%|j dI d H  ntd&|j  t|j W q ty } z|d'| d(I d H  td)|  W Y d }~qd }~ww d S )*NAPI_URLLOGINlogin_accountlogin_password)accountpasswordheaders)urljsonr
      tokenplatforms_dates_timee_datee_timeMAINTAIN)
auth_tokenapi_urlc                    s   | d  kS )Nr    )xmaintain_targetr   (/var/www/html/tg_maintain_bot/api/api.py<lambda>(   s    z#call_maintain_api.<locals>.<lambda>uid/zapplication/jsonTWDzBearer )zContent-TypeCurrencyExchange_codeAuthorization   r   )	r   maintenance_start_timemaintenance_end_timestatus_frontstatus_backendis_under_maintenanceis_scheduledis_exclusive_brandenable_buffer_walletu   維護流程已確認z
                        z
                        
u   維護流程已取消u)   
                        
維護平台：u/   
                        
開始維護時間： -u/   
                        
結束維護時間：u,   
                        
API回應代碼：zError: u#   
                API呼叫失敗：z
                z&Error occurred while calling the API: )r   gethashlibmd5encode	hexdigestrequestspoststatus_coder   r   nextfilterputprintreplytext	Exception)maintain_platformfmt_datacancel_maintainbotr   config	login_apir   r	   md5_password	login_resr   r   r   r   r   all_platformplatform_dataplatform_uidmaintain_apir
   dataresponseer   r   r   call_maintain_api
   s   




	










rL   )	ossysr3   config.platform_configr   utils.get_all_platformr   r/   rL   r   r   r   r   <module>   s    