mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-15 06:50:58 +00:00
feat: 支持更新插件
This commit is contained in:
+17
-1
@@ -106,7 +106,23 @@ def plugin_operation(cmd, params, is_admin):
|
|||||||
|
|
||||||
reply = [reply_str]
|
reply = [reply_str]
|
||||||
elif params[0] == 'update':
|
elif params[0] == 'update':
|
||||||
pass
|
# 更新所有插件
|
||||||
|
if is_admin:
|
||||||
|
def closure():
|
||||||
|
updated = []
|
||||||
|
for key in plugin_list:
|
||||||
|
plugin = plugin_list[key]
|
||||||
|
if updater.is_repo("/".join(plugin['path'].split('/')[:-1])):
|
||||||
|
success = updater.pull_latest("/".join(plugin['path'].split('/')[:-1]))
|
||||||
|
if success:
|
||||||
|
updated.append(plugin['name'])
|
||||||
|
|
||||||
|
pkg.utils.context.get_qqbot_manager().notify_admin("[bot]已更新插件: {}".format(", ".join(updated)))
|
||||||
|
|
||||||
|
threading.Thread(target=closure).start()
|
||||||
|
reply = ["[bot]正在更新所有插件..."]
|
||||||
|
else:
|
||||||
|
reply = ["[bot]err:权限不足"]
|
||||||
elif params[0].startswith("http"):
|
elif params[0].startswith("http"):
|
||||||
if is_admin:
|
if is_admin:
|
||||||
|
|
||||||
|
|||||||
+12
-1
@@ -16,6 +16,18 @@ def check_dulwich_closure():
|
|||||||
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
|
||||||
|
|
||||||
|
|
||||||
|
def pull_latest(repo_path: str) -> bool:
|
||||||
|
"""拉取最新代码"""
|
||||||
|
check_dulwich_closure()
|
||||||
|
|
||||||
|
from dulwich import porcelain
|
||||||
|
|
||||||
|
repo = porcelain.open_repo(repo_path)
|
||||||
|
porcelain.pull(repo)
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def update_all() -> bool:
|
def update_all() -> bool:
|
||||||
"""使用dulwich更新源码"""
|
"""使用dulwich更新源码"""
|
||||||
check_dulwich_closure()
|
check_dulwich_closure()
|
||||||
@@ -58,7 +70,6 @@ def is_repo(path: str) -> bool:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_remote_url(repo_path: str) -> str:
|
def get_remote_url(repo_path: str) -> str:
|
||||||
"""获取远程仓库地址"""
|
"""获取远程仓库地址"""
|
||||||
check_dulwich_closure()
|
check_dulwich_closure()
|
||||||
|
|||||||
Reference in New Issue
Block a user