feat: add plugins config

This commit is contained in:
zhayujie
2023-03-24 00:22:09 +08:00
parent 4f5f65086f
commit c1d1e923cd
3 changed files with 6 additions and 5 deletions

View File

@@ -57,8 +57,8 @@ class WechatChannel(Channel):
# handle_* 系列函数处理收到的消息后构造context然后调用handle函数处理context
# context是一个字典包含了消息的所有信息包括以下key
# type: 消息类型包括TEXT、VOICE、IMAGE_CREATE
# content: 消息内容如果是TEXT类型content就是文本内容如果是VOICE类型content就是语音文件名如果是IMAGE_CREATE类型content就是图片生成命令
# type 消息类型, 包括TEXT、VOICE、IMAGE_CREATE
# content 消息内容如果是TEXT类型content就是文本内容如果是VOICE类型content就是语音文件名如果是IMAGE_CREATE类型content就是图片生成命令
# session_id: 会话id
# isgroup: 是否是群聊
# msg: 原始消息对象

View File

@@ -9,5 +9,6 @@
"conversation_max_tokens": 1000,
"speech_recognition": false,
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",
"expires_in_seconds": 3600
"expires_in_seconds": 3600,
"plugins": ["role", "hello", "sdwebui", "godcmd", "dungeon", "banwords"]
}

View File

@@ -6,8 +6,8 @@ import os
from common.singleton import singleton
from common.sorted_dict import SortedDict
from .event import *
from .plugin import *
from common.log import logger
from config import conf
@singleton
@@ -59,7 +59,7 @@ class PluginManager:
if os.path.isdir(plugin_path):
# 判断插件是否包含同名.py文件
main_module_path = os.path.join(plugin_path, plugin_name+".py")
if os.path.isfile(main_module_path):
if os.path.isfile(main_module_path) and conf().get("plugins") and plugin_name in conf().get("plugins"):
# 导入插件
import_path = "{}.{}.{}".format(plugins_dir, plugin_name, plugin_name)
main_module = importlib.import_module(import_path)