mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-02 12:05:54 +00:00
feat: 支持指令删除插件 (#286)
This commit is contained in:
@@ -5,6 +5,7 @@ import importlib
|
||||
import os
|
||||
import pkgutil
|
||||
import sys
|
||||
import shutil
|
||||
import traceback
|
||||
|
||||
import pkg.utils.context as context
|
||||
@@ -160,6 +161,22 @@ def install_plugin(repo_url: str):
|
||||
main.reset_logging()
|
||||
|
||||
|
||||
def uninstall_plugin(plugin_name: str) -> str:
|
||||
""" 卸载插件 """
|
||||
if plugin_name not in __plugins__:
|
||||
raise Exception("插件不存在")
|
||||
|
||||
# 获取文件夹路径
|
||||
plugin_path = __plugins__[plugin_name]['path'].replace("\\", "/")
|
||||
|
||||
# 剪切路径为plugins/插件名
|
||||
plugin_path = plugin_path.split("plugins/")[1].split("/")[0]
|
||||
|
||||
# 删除文件夹
|
||||
shutil.rmtree("plugins/"+plugin_path)
|
||||
return "plugins/"+plugin_path
|
||||
|
||||
|
||||
class EventContext:
|
||||
""" 事件上下文 """
|
||||
eid = 0
|
||||
|
||||
Reference in New Issue
Block a user