o
    jj                     @   s   d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ d dl	m
Z
 d dlmZ e jejdZdeddfd	d
ZeG dd deZdS )    N)apicontext)Plugin)text)register_pluginzlast_update_head.txthexshareturnc                 C   sV   t jtjdd ttddd}||  d  W d    d S 1 s$w   Y  d S )NT)exist_okwzutf-8)encoding
)osmakedirsr   python_data_pathopen_LAST_UPDATE_HEAD_FILEwritestrip)r   f r   4/home/dore/onebot/Bot_Ero/plugins/update/__init__.py_write_last_update_head   s   "r   c                   @   s$   e Zd ZdZdZdd Zdd ZdS )UpdatePlugin
update_botu'   拉取远程更新并重启机器人。c                 C   s   |   o| dS )Nu   /更新)
super_useron_full_match)selfmessage_typer   r   r   match   s   zUpdatePlugin.matchc                 C   s   | j td td}|jjj}|jj	}|
  |jjj}||krU| d| }t||}t| | j tdt| d td ttjdgtj  d S | j td d S )	Nu   正在检测更新喵~z./z..u
   更新了 u     个 补丁，5s后重启了喵~   python3u(   小埃同学已经是最新版本了喵~)r   send_msgr   gitRepoheadcommitr   remotesoriginpulllistiter_commitsr   lentimesleepr   execvsys
executableargv)r   repo
old_commitr'   
new_commitcommit_rangecommitsr   r   r   handle   s   



zUpdatePlugin.handleN)__name__
__module____qualname__namedescriptionr   r7   r   r   r   r   r      s
    r   )r   r/   r,   r"   corer   r   	core.baser   core.cqr   
core.utilsr   pathjoinr   r   strr   r   r   r   r   r   <module>   s    