feat: 基本插件指令

This commit is contained in:
Rock Chin
2023-01-17 00:11:07 +08:00
parent 2c9e7f70f2
commit 6af55d8a1d
2 changed files with 53 additions and 0 deletions

View File

@@ -92,6 +92,25 @@ def unload_plugins():
logging.error("插件{}卸载时发生错误: {}".format(plugin['name'], sys.exc_info()))
def install_plugin(repo_url: str):
""" 安装插件从git储存库获取并解决依赖 """
try:
import pkg.utils.pkgmgr
pkg.utils.pkgmgr.ensure_dulwich()
except:
pass
try:
import dulwich
except ModuleNotFoundError:
raise Exception("dulwich模块未安装,请查看 https://github.com/RockChinQ/QChatGPT/issues/77")
from dulwich import porcelain
logging.info("克隆插件储存库: {}".format(repo_url))
repo = porcelain.clone(repo_url, "plugins", checkout=True)
class EventContext:
""" 事件上下文 """
eid = 0