mirror of
https://github.com/ClovertaTheTrilobita/SanYeCao-Nonebot.git
synced 2026-04-01 22:04:51 +00:00
refactor(config):重构发信、ai、jm的配置文件
整合至config.yaml
This commit is contained in:
parent
c93453125a
commit
874de4a571
5 changed files with 32 additions and 10 deletions
|
|
@ -53,14 +53,17 @@ ai:
|
|||
|
||||
api:
|
||||
v3:
|
||||
enabled: "False"
|
||||
url: "https://api.vveai.com/v1/chat/completions"
|
||||
key: '<KEY>'
|
||||
|
||||
deepseek:
|
||||
enabled: "False"
|
||||
url: "https://api.deepseek.com"
|
||||
key: '<KEY>'
|
||||
|
||||
silicon_flow:
|
||||
enabled: "True"
|
||||
url: "https://api.siliconflow.cn/v1/chat/completions"
|
||||
model: "Pro/deepseek-ai/DeepSeek-V3"
|
||||
key: '<KEY>'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import yaml
|
|||
import uuid
|
||||
import jmcomic
|
||||
from datetime import datetime
|
||||
from src.configs.api_config import qrserver_url,qrserver_size
|
||||
from src.configs.api_config import qrserver_url,qrserver_size,google_enabled,qq_enabled,server_enabled
|
||||
from src.clover_jm.disguise_pdf import *
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from src.configs.path_config import jm_path,jm_config_path
|
||||
|
|
@ -28,7 +28,17 @@ async def jm_email(album_id: str| None,receiver_email: str| None):
|
|||
await delete_folder(folder_path)
|
||||
return "压缩文件失败"
|
||||
# 发送邮件
|
||||
|
||||
if str(google_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
send_status = await send_email_by_google(receiver_email, zip_path)
|
||||
elif str(qq_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
send_status = await send_email_by_qq(receiver_email,zip_path)
|
||||
elif str(server_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
send_status = await send_email_by_server(receiver_email,zip_path)
|
||||
else:
|
||||
logger.error("您未启用任何一个发信服务,请前往 config.yaml 修改。")
|
||||
send_status = False
|
||||
|
||||
if send_status:
|
||||
# 删除文件
|
||||
await delete_folder(folder_path)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from os import getcwd
|
|||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from src.configs.api_config import wenku8_username, wenku8_password, proxy_api
|
||||
from src.configs.api_config import wenku8_username, wenku8_password, proxy_api, proxy_enabled
|
||||
|
||||
# 登录页面的URL
|
||||
login_url = 'https://www.wenku8.net/login.php?jumpurl=http%3A%2F%2Fwww.wenku8.net%2Findex.php'
|
||||
|
|
@ -29,8 +29,6 @@ def get_proxy(headers):
|
|||
aaa = requests.get(proxy_url, headers=headers).text
|
||||
proxy_host = aaa.splitlines()[0]
|
||||
print('代理IP为:' + proxy_host)
|
||||
# proxy_host='117.35.254.105:22001'
|
||||
# proxy_host='192.168.0.134:1080'
|
||||
proxy = {
|
||||
'http': 'http://' + proxy_host,
|
||||
'https': 'http://' + proxy_host
|
||||
|
|
@ -43,7 +41,10 @@ async def login():
|
|||
with requests.Session() as session:
|
||||
proxy = get_proxy(headers)
|
||||
# 注意:这里使用了Session对象来保持会话状态
|
||||
if str(proxy_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
login_response = session.post(login_url, data=login_data, headers=headers, proxies=proxy)
|
||||
else:
|
||||
login_response = session.post(login_url, data=login_data, headers=headers)
|
||||
|
||||
# 检查登录是否成功(根据实际需求调整)
|
||||
if login_response.status_code == 200:
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from openai import AsyncOpenAI as openai
|
||||
import requests
|
||||
from src.clover_sqlite.models.chat import GroupChatRole
|
||||
from src.configs.api_config import v3url, v3key, deepseek_url, deepseek_key,silicon_flow_key
|
||||
from src.configs.api_config import v3url, v3key, deepseek_url, deepseek_key,silicon_flow_key,silicon_flow_url,silicon_flow_model
|
||||
import aiohttp
|
||||
|
||||
"""
|
||||
|
|
@ -51,9 +51,9 @@ async def deepseek_chat(group_openid,content):
|
|||
async def silicon_flow(group_openid, content):
|
||||
await GroupChatRole.save_chat_history(group_openid, {"role": "user", "content": content})
|
||||
messages = await GroupChatRole.get_chat_history(group_openid)
|
||||
url = "https://api.siliconflow.cn/v1/chat/completions"
|
||||
url = silicon_flow_url
|
||||
payload = {
|
||||
"model": "Pro/deepseek-ai/DeepSeek-V3",
|
||||
"model": silicon_flow_model,
|
||||
"stream": False,
|
||||
"messages": messages
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ from nonebot.adapters.qq import Message, MessageEvent
|
|||
from src.clover_openai import ai_chat
|
||||
from src.clover_sqlite.models.chat import GroupChatRole
|
||||
from src.clover_sqlite.models.user import UserList
|
||||
from src.configs.api_config import v3_enabled, deepseek_enabled, silicon_flow_enabled
|
||||
|
||||
menu = ["/重启","/今日运势","/今日塔罗","/图","/随机图","/搜番","/日报","/点歌","/摸摸头","/群老婆","/今日老婆", "/开启ai","/关闭ai","/角色列表","/添加人设", "/更新人设", "/删除人设", "/切换人设", "/管理员注册",
|
||||
"/待办", "/test","/天气","我喜欢你", "❤", "/待办查询", "/新建待办", "/删除待办" ,"/cf","/B站搜索", "/BV搜索", "/喜报", "/悲报", "/luxun","/鲁迅说",
|
||||
|
|
@ -42,7 +43,14 @@ async def handle_function(message: MessageEvent):
|
|||
member_openid, content = message.author.id, message.get_plaintext()
|
||||
status = await GroupChatRole.is_on(group_openid)
|
||||
if status:
|
||||
if str(v3_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
msg = await ai_chat.v3_chat(group_openid, content)
|
||||
elif str(deepseek_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
msg = await ai_chat.deepseek_chat(group_openid, content)
|
||||
elif str(silicon_flow_enabled).strip().lower() in {"1", "t", "true"}:
|
||||
msg = await ai_chat.silicon_flow(group_openid,content)
|
||||
else:
|
||||
msg = "管理员未配置ai聊天功能"
|
||||
await check.finish(msg)
|
||||
else:
|
||||
await check.finish(message=Message(random.choice(text_list)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue