mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 14:17:11 +08:00
feat: add plugins config
This commit is contained in:
@@ -57,8 +57,8 @@ class WechatChannel(Channel):
|
|||||||
|
|
||||||
# handle_* 系列函数处理收到的消息后构造context,然后调用handle函数处理context
|
# handle_* 系列函数处理收到的消息后构造context,然后调用handle函数处理context
|
||||||
# context是一个字典,包含了消息的所有信息,包括以下key
|
# context是一个字典,包含了消息的所有信息,包括以下key
|
||||||
# type: 消息类型,包括TEXT、VOICE、IMAGE_CREATE
|
# type 消息类型, 包括TEXT、VOICE、IMAGE_CREATE
|
||||||
# content: 消息内容,如果是TEXT类型,content就是文本内容,如果是VOICE类型,content就是语音文件名,如果是IMAGE_CREATE类型,content就是图片生成命令
|
# content 消息内容,如果是TEXT类型,content就是文本内容,如果是VOICE类型,content就是语音文件名,如果是IMAGE_CREATE类型,content就是图片生成命令
|
||||||
# session_id: 会话id
|
# session_id: 会话id
|
||||||
# isgroup: 是否是群聊
|
# isgroup: 是否是群聊
|
||||||
# msg: 原始消息对象
|
# msg: 原始消息对象
|
||||||
|
|||||||
@@ -9,5 +9,6 @@
|
|||||||
"conversation_max_tokens": 1000,
|
"conversation_max_tokens": 1000,
|
||||||
"speech_recognition": false,
|
"speech_recognition": false,
|
||||||
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",
|
"character_desc": "你是ChatGPT, 一个由OpenAI训练的大型语言模型, 你旨在回答并解决人们的任何问题,并且可以使用多种语言与人交流。",
|
||||||
"expires_in_seconds": 3600
|
"expires_in_seconds": 3600,
|
||||||
|
"plugins": ["role", "hello", "sdwebui", "godcmd", "dungeon", "banwords"]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import os
|
|||||||
from common.singleton import singleton
|
from common.singleton import singleton
|
||||||
from common.sorted_dict import SortedDict
|
from common.sorted_dict import SortedDict
|
||||||
from .event import *
|
from .event import *
|
||||||
from .plugin import *
|
|
||||||
from common.log import logger
|
from common.log import logger
|
||||||
|
from config import conf
|
||||||
|
|
||||||
|
|
||||||
@singleton
|
@singleton
|
||||||
@@ -59,7 +59,7 @@ class PluginManager:
|
|||||||
if os.path.isdir(plugin_path):
|
if os.path.isdir(plugin_path):
|
||||||
# 判断插件是否包含同名.py文件
|
# 判断插件是否包含同名.py文件
|
||||||
main_module_path = os.path.join(plugin_path, plugin_name+".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)
|
import_path = "{}.{}.{}".format(plugins_dir, plugin_name, plugin_name)
|
||||||
main_module = importlib.import_module(import_path)
|
main_module = importlib.import_module(import_path)
|
||||||
|
|||||||
Reference in New Issue
Block a user