删除xyit平台,修复代码在ncatbot 4.x时报错的bug #1
This commit is contained in:
31
config.toml
31
config.toml
@@ -1,18 +1,25 @@
|
|||||||
#napcat配置
|
# ncatbot 配置
|
||||||
|
|
||||||
|
# 此处仅提供ncatbot部分配置项,其余配置项请在ncatbot.yaml中修改
|
||||||
|
# 此处配置优先级高于ncatbot.yaml
|
||||||
|
# 请务必保证bot_qq及root_qq配置正确
|
||||||
|
# 在ws监听IP为0.0.0.0时要求ws_token为强密码,启用web_ui(enable_webui_interaction = True)检查时要求webui_token为强密码
|
||||||
|
# 强密码要求: 1,至少 12 位字符 2,包含数字、字母和特殊符号(特殊符号包括:!@#$%^&*()_+-=[]{}|;:,.<>?)
|
||||||
|
|
||||||
bot_qq = 123456 #机器人q号
|
bot_qq = 123456 #机器人q号
|
||||||
root_qq = 1234567 # 管理员q号
|
root_qq = 1234567 # 管理员q号
|
||||||
ws_uri = "loacalhost:3001" # ws 地址, 可自定义端口, 默认 3001
|
ws_uri = "localhost:3001" # ws 地址, 可自定义端口, 默认 3001
|
||||||
webui_uri = "loacalhost:6099" # webui 地址, 可自定义端口, 默认 6099
|
webui_uri = "localhost:6099" # webui 地址, 可自定义端口, 默认 6099
|
||||||
webui_token = "napcat" # webui 令牌, 默认 napcat
|
webui_token = "napcat" # webui 令牌, 默认 napcat
|
||||||
ws_token = "" # ws_uri 令牌, 默认留空
|
ws_token = "" # ws_uri 令牌, 默认留空
|
||||||
ws_listen_ip = "localhost" # ws_uri 监听 ip, 默认 localhost 监听本机,监听全部则配置 0.0.0.0
|
ws_listen_ip = "localhost" # ws_uri 监听 ip, 默认 localhost 监听本机,监听全部则配置 0.0.0.0
|
||||||
remote_mode = false # 是否远程模式, 即 NapCat 服务不在本机运行 ps:ncatbot官方已废弃该参数
|
enable_webui_interaction = true # 是否启用webui交互,默认启用
|
||||||
|
|
||||||
# 功能配置
|
# 功能配置
|
||||||
allowed_groups = "all" # 授权群聊,all为全部,eg:[123456789, 987654321]
|
allowed_groups = "all" # 授权群聊,all为全部,eg:[123456789, 987654321]
|
||||||
allowed_users = "all" # 授权用户,all为全部,eg:[123456789, 987654321]
|
allowed_users = "all" # 授权用户,all为全部,eg:[123456789, 987654321]
|
||||||
ai_service = "xyit" # ai平台 支持 "dify" "mcunc" "xyit" "aliyun"
|
ai_service = "" # ai平台 支持 "dify" "mcunc" "aliyun"
|
||||||
friend_auto = false # 好友自动同意
|
friend_auto = false # 好友自动同意,实验性功能
|
||||||
group_auto = true
|
group_auto = true
|
||||||
group_welcome = false # 入群欢迎
|
group_welcome = false # 入群欢迎
|
||||||
group_leave = false # 退群提醒
|
group_leave = false # 退群提醒
|
||||||
@@ -22,14 +29,14 @@ group_welcome_message = "!at 欢迎加入本群,使用@bot /help获取此bot
|
|||||||
group_leave_message = "用户{userid}退群了" # 退群消息 ,{userid}为退群用户id
|
group_leave_message = "用户{userid}退群了" # 退群消息 ,{userid}为退群用户id
|
||||||
error_message = "服务器繁忙,请稍后再逝"
|
error_message = "服务器繁忙,请稍后再逝"
|
||||||
permission_denied_message = "此bot未在该群启用"
|
permission_denied_message = "此bot未在该群启用"
|
||||||
status_message = "---猫娘 QBOT---\n Q bot 运行正常 \n 版本: 2.0 pre \n © 无尽创意MCUNC"
|
status_message = "---chatbot ncapcat---\n Q bot 运行正常 \n 版本: 2.0 pre \n © 无尽创意MCUNC"
|
||||||
help_message = "直接输入聊天内容即可 \n /help -- 获取帮助 \n /clear [群号 / private:Q号] (all 为全部,不填为本 群/用户) \n /status -- 查看bot状态"
|
help_message = "直接输入聊天内容即可 \n /help -- 获取帮助 \n /clear [群号 / private:Q号] (all 为全部,不填为本 群/用户) \n /status -- 查看bot状态"
|
||||||
command_isnone_message = "你似乎没有提供想和我聊的内容喵~ \n 直接输入聊天内容即可"
|
command_isnone_message = "你似乎没有提供想和我聊的内容喵~ \n 直接输入聊天内容即可"
|
||||||
command_notfound_message = "指令不存在,输入/help查看帮助"
|
command_notfound_message = "指令不存在,输入/help查看帮助"
|
||||||
chatmessage_isnone_message = "你似乎没有提供想和我聊的内容喵~ \n 格式:/cat <提问内容>"
|
chatmessage_isnone_message = "你似乎没有提供想和我聊的内容喵~ \n 格式:/cat <提问内容>"
|
||||||
clean_all_success_message = "✅ 已清空所有群组数据"
|
clean_all_success_message = "✅ 已清空所有群组数据"
|
||||||
clean_one_success_message = "✅ 已成功删除 group_id = {group_id} 的数据"
|
clean_one_success_message = "✅ 已成功删除 group_id = {group_id} 的数据" # {group_id}为群组id
|
||||||
clean_one_notfound_message = "⚠️ 没有找到 group_id = {group_id} 的数据"
|
clean_one_notfound_message = "⚠️ 没有找到 group_id = {group_id} 的数据" # {group_id}为群组id
|
||||||
clean_nopermissoin_message = "你不是管理员哦喵~"
|
clean_nopermissoin_message = "你不是管理员哦喵~"
|
||||||
clean_fail_message = "❌ 数据库操作失败"
|
clean_fail_message = "❌ 数据库操作失败"
|
||||||
|
|
||||||
@@ -51,12 +58,6 @@ mcunc_appID = "" # appID
|
|||||||
mcunc_appKEY = "" # appKEY
|
mcunc_appKEY = "" # appKEY
|
||||||
mcunc_model = "maoniang" # 模型名称名称
|
mcunc_model = "maoniang" # 模型名称名称
|
||||||
|
|
||||||
# xyit配置 ai_service选择xyit时需配置
|
|
||||||
xyit_ip = "https://ai.openapi.xyit.net" # ip 此项一般不需用修改
|
|
||||||
xyit_appID = "" # appID
|
|
||||||
xyit_appKEY = "" # appKEY
|
|
||||||
xyit_model = "maoniang" # 模型名称
|
|
||||||
|
|
||||||
# 阿里云百炼配置 ai_service选择aliyun时需配置
|
# 阿里云百炼配置 ai_service选择aliyun时需配置
|
||||||
aliyun_app_id = ""
|
aliyun_app_id = ""
|
||||||
aliyun_api_key = ""
|
aliyun_api_key = ""
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import logging
|
from ncatbot.core.event.message_segment import At, Text
|
||||||
from model import ai_model
|
from model import ai_model
|
||||||
from model.Clear import Clear
|
from model.Clear import Clear
|
||||||
import toml
|
import toml
|
||||||
@@ -7,6 +7,7 @@ from model.logger import setup_logger
|
|||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
class group:
|
class group:
|
||||||
def __init__(self, msg):
|
def __init__(self, msg):
|
||||||
|
self.self_id = msg.self_id
|
||||||
self.user_id = msg.user_id
|
self.user_id = msg.user_id
|
||||||
self.group_id = msg.group_id
|
self.group_id = msg.group_id
|
||||||
self.message_id = msg.message_id
|
self.message_id = msg.message_id
|
||||||
@@ -14,8 +15,6 @@ class group:
|
|||||||
self.raw_message = msg.raw_message
|
self.raw_message = msg.raw_message
|
||||||
self.sender = msg.sender
|
self.sender = msg.sender
|
||||||
self.message = msg.message
|
self.message = msg.message
|
||||||
self.self_id = msg.self_id
|
|
||||||
self.time = msg.time
|
|
||||||
try:
|
try:
|
||||||
with open("config.toml", "r", encoding="utf-8") as f:
|
with open("config.toml", "r", encoding="utf-8") as f:
|
||||||
config = toml.load(f)
|
config = toml.load(f)
|
||||||
@@ -44,8 +43,8 @@ class group:
|
|||||||
|
|
||||||
def is_at(self):
|
def is_at(self):
|
||||||
for seg in self.message:
|
for seg in self.message:
|
||||||
if seg['type'] == 'at' and seg['data'].get('qq') == str(self.self_id):
|
if isinstance(seg, At) and seg.qq == str(self.self_id):
|
||||||
texts = [s['data']['text'].strip() for s in self.message if s['type'] == 'text']
|
texts = [s.text.strip() for s in self.message if isinstance(s, Text)]
|
||||||
full_text = ' '.join(texts).strip()
|
full_text = ' '.join(texts).strip()
|
||||||
return full_text
|
return full_text
|
||||||
|
|
||||||
|
|||||||
@@ -5,18 +5,11 @@ from model.logger import setup_logger
|
|||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
class notice:
|
class notice:
|
||||||
def __init__(self,msg):
|
def __init__(self,msg):
|
||||||
print(msg)
|
self.time = msg.time
|
||||||
if msg["notice_type"] == "group_increase" or msg["notice_type"] == "group_decrease":
|
self.notice_type = msg.notice_type
|
||||||
self.time = msg["time"]
|
self.group_id = msg.group_id
|
||||||
self.self_id = msg["self_id"]
|
self.operator_id = msg.operator_id
|
||||||
self.post_type = msg["post_type"]
|
self.user_id = msg.user_id
|
||||||
self.notice_type = msg["notice_type"]
|
|
||||||
self.sub_type = msg["sub_type"]
|
|
||||||
self.group_id = msg["group_id"]
|
|
||||||
self.operator_id = msg["operator_id"]
|
|
||||||
self.user_id = msg["user_id"]
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
if self.notice_type == "group_increase":
|
if self.notice_type == "group_increase":
|
||||||
@@ -27,7 +20,6 @@ class notice:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
def group_increase(self):
|
def group_increase(self):
|
||||||
print(1)
|
|
||||||
try:
|
try:
|
||||||
with open("./config.toml", "r", encoding="utf-8") as f:
|
with open("./config.toml", "r", encoding="utf-8") as f:
|
||||||
config = toml.load(f)
|
config = toml.load(f)
|
||||||
@@ -52,7 +44,6 @@ class notice:
|
|||||||
config = toml.load(f)
|
config = toml.load(f)
|
||||||
group_leave = config.get("group_leave")
|
group_leave = config.get("group_leave")
|
||||||
group_leave_message = config.get("group_leave_message")
|
group_leave_message = config.get("group_leave_message")
|
||||||
print(group_leave_message)
|
|
||||||
if group_leave:
|
if group_leave:
|
||||||
if "{userid}" in group_leave_message:
|
if "{userid}" in group_leave_message:
|
||||||
return group_leave_message.replace("{userid}", str(self.user_id))
|
return group_leave_message.replace("{userid}", str(self.user_id))
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
from ncatbot.core.event.message_segment import Text
|
||||||
from model.logger import setup_logger
|
from model.logger import setup_logger
|
||||||
from model.Clear import Clear
|
from model.Clear import Clear
|
||||||
from model import ai_model
|
from model import ai_model
|
||||||
@@ -30,7 +31,7 @@ class private:
|
|||||||
logger.error(f"读取配置文件出现错误{e}")
|
logger.error(f"读取配置文件出现错误{e}")
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
texts = [seg['data']['text'].strip() for seg in self.message if seg['type'] == 'text']
|
texts = [seg.text.strip() for seg in self.message if isinstance(seg, Text)]
|
||||||
full_text = ' '.join(texts).strip()
|
full_text = ' '.join(texts).strip()
|
||||||
permission = self.check_permission()
|
permission = self.check_permission()
|
||||||
if permission is None:
|
if permission is None:
|
||||||
|
|||||||
@@ -5,12 +5,9 @@ import toml
|
|||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
class request:
|
class request:
|
||||||
def __init__(self,msg):
|
def __init__(self,msg):
|
||||||
self.time = msg.time
|
|
||||||
self.self_id = msg.self_id
|
self.self_id = msg.self_id
|
||||||
self.request_type = msg.request_type
|
self.request_type = msg.request_type
|
||||||
self.sub_type = msg.sub_type
|
self.post_type = msg.post_type
|
||||||
self.group_id = msg.group_id
|
|
||||||
self.user_id = msg.user_id
|
|
||||||
self.comment = msg.comment
|
self.comment = msg.comment
|
||||||
self.flag = msg.flag
|
self.flag = msg.flag
|
||||||
|
|
||||||
@@ -31,14 +28,4 @@ class request:
|
|||||||
return friend_auto
|
return friend_auto
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"读取配置文件错误:{e}")
|
logger.error(f"读取配置文件错误:{e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_allow_group(self):
|
|
||||||
try:
|
|
||||||
with open("./config.toml", "r", encoding="utf-8") as f:
|
|
||||||
config = toml.load(f)
|
|
||||||
allow_group = config.get("allowed_groups")
|
|
||||||
return allow_group
|
|
||||||
except Exception as e:
|
|
||||||
logger.error(f"读取配置文件错误:{e}")
|
|
||||||
return []
|
|
||||||
62
main.py
62
main.py
@@ -1,15 +1,17 @@
|
|||||||
from ncatbot.core.notice import NoticeMessage
|
import os
|
||||||
from ncatbot.core import BotClient, Request
|
os.environ['NCATBOT_CONFIG_PATH'] = 'ncatbot.yaml'
|
||||||
|
import toml
|
||||||
|
from ncatbot.core.event import PrivateMessageEvent, GroupMessageEvent, NoticeEvent, RequestEvent
|
||||||
|
from ncatbot.utils import ncatbot_config
|
||||||
|
from ncatbot.core import BotClient
|
||||||
from model.logger import setup_logger
|
from model.logger import setup_logger
|
||||||
import asyncio
|
|
||||||
from control.group import group
|
from control.group import group
|
||||||
from control.private import private
|
from control.private import private
|
||||||
from control.request import request
|
from control.request import request
|
||||||
from control.notice import notice
|
from control.notice import notice
|
||||||
import toml
|
|
||||||
|
|
||||||
|
|
||||||
logger = setup_logger()
|
logger = setup_logger()
|
||||||
|
|
||||||
with open("./config.toml", "r", encoding="utf-8") as f:
|
with open("./config.toml", "r", encoding="utf-8") as f:
|
||||||
config = toml.load(f)
|
config = toml.load(f)
|
||||||
bt_uin = config.get("bot_qq")
|
bt_uin = config.get("bot_qq")
|
||||||
@@ -19,13 +21,21 @@ with open("./config.toml", "r", encoding="utf-8") as f:
|
|||||||
webui_token = config.get("webui_token")
|
webui_token = config.get("webui_token")
|
||||||
ws_token = config.get("ws_token")
|
ws_token = config.get("ws_token")
|
||||||
ws_listen_ip = config.get("ws_listen_ip")
|
ws_listen_ip = config.get("ws_listen_ip")
|
||||||
remote_mode = config.get("remote_mode")
|
enable_webui_interaction = config.get("enable_webui_interaction")
|
||||||
|
|
||||||
|
ncatbot_config.set_bot_uin(bt_uin)
|
||||||
|
ncatbot_config.set_root(root)
|
||||||
|
ncatbot_config.set_webui_uri(webui_uri)
|
||||||
|
ncatbot_config.set_webui_token(webui_token)
|
||||||
|
ncatbot_config.set_ws_uri(ws_uri)
|
||||||
|
ncatbot_config.set_ws_token(ws_token)
|
||||||
|
ncatbot_config.set_ws_listen_ip(ws_listen_ip)
|
||||||
|
ncatbot_config.enable_webui_interaction = enable_webui_interaction
|
||||||
|
|
||||||
bot = BotClient()
|
bot = BotClient()
|
||||||
api = bot.run_blocking(bt_uin=bt_uin, root=root, ws_uri=ws_uri, webui_uri=webui_uri, webui_token=webui_token, ws_token=ws_token, ws_listen_ip=ws_listen_ip, remote_mode=remote_mode)
|
|
||||||
|
|
||||||
@bot.group_event()
|
@bot.on_group_message()
|
||||||
async def on_group_message(msg):
|
async def on_group_message(msg: GroupMessageEvent):
|
||||||
logger.info(f"收到消息:{msg.raw_message},来自{msg.group_id}群聊{msg.user_id}用户")
|
logger.info(f"收到消息:{msg.raw_message},来自{msg.group_id}群聊{msg.user_id}用户")
|
||||||
if msg.user_id == 2854196310: # qq管家,防止刷屏。bot大战请看
|
if msg.user_id == 2854196310: # qq管家,防止刷屏。bot大战请看
|
||||||
pass
|
pass
|
||||||
@@ -35,11 +45,11 @@ async def on_group_message(msg):
|
|||||||
if return_message is None:
|
if return_message is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
logger.info(f"返回消息:{return_message}")
|
# logger.info(f"返回消息:{return_message}")
|
||||||
await bot.api.post_group_msg(group_id=msg.group_id, text=return_message, reply=msg.message_id)
|
await msg.reply(text=return_message)
|
||||||
|
|
||||||
@bot.private_event()
|
@bot.on_private_message()
|
||||||
async def on_private_message(msg):
|
async def on_private_message(msg: PrivateMessageEvent):
|
||||||
logger.info(f"收到消息:{msg.raw_message},来自{msg.user_id}用户")
|
logger.info(f"收到消息:{msg.raw_message},来自{msg.user_id}用户")
|
||||||
if msg.user_id == 2854196310: # qq管家,防止刷屏。
|
if msg.user_id == 2854196310: # qq管家,防止刷屏。
|
||||||
pass
|
pass
|
||||||
@@ -49,36 +59,36 @@ async def on_private_message(msg):
|
|||||||
if return_message is None:
|
if return_message is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
logger.info(f"返回消息:{return_message}")
|
# logger.info(f"返回消息:{return_message}")
|
||||||
await bot.api.post_private_msg(user_id=msg.user_id, text=return_message, reply=msg.message_id)
|
await msg.reply(text=return_message)
|
||||||
|
|
||||||
|
|
||||||
@bot.request_event()
|
@bot.on_request(filter='friend')
|
||||||
async def on_request_event(msg: Request):
|
async def on_request_event(msg: RequestEvent):
|
||||||
logger.info(f"收到request事件:{msg.request_type},来自{msg.group_id}群聊,{msg.user_id}用户,验证消息:{msg.comment}")
|
logger.info(f"收到request事件:{msg.request_type},来自{msg.group_id}群聊,{msg.user_id}用户,验证消息:{msg.comment}")
|
||||||
|
logger.info(f"收到request请求,来自{msg.self_id}")
|
||||||
ctrl = request(msg)
|
ctrl = request(msg)
|
||||||
accept_friend_application = ctrl.main()
|
accept_friend_application = ctrl.main()
|
||||||
if accept_friend_application is True:
|
if accept_friend_application is True:
|
||||||
await msg.reply(True, comment="请求已通过")
|
await msg.reply(True)
|
||||||
logger.info("请求已通过")
|
# logger.info("请求已通过")
|
||||||
else:
|
else:
|
||||||
await msg.reply(False, comment="请求被拒绝")
|
await msg.reply(False)
|
||||||
logger.info("请求被拒绝")
|
# logger.info("请求被拒绝")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@bot.notice_event()
|
@bot.on_notice()
|
||||||
async def on_notice_event(msg: NoticeMessage):
|
async def on_notice_event(msg: NoticeEvent):
|
||||||
logger.info(f"收到notice事件:{msg['notice_type']},来自{msg['user_id']}用户")
|
logger.info(f"收到notice事件:{msg['notice_type']},来自{msg['user_id']}用户")
|
||||||
ctrl = notice(msg)
|
ctrl = notice(msg)
|
||||||
return_message = ctrl.main()
|
return_message = ctrl.main()
|
||||||
if return_message is None:
|
if return_message is None:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
logger.info(f"返回消息:{return_message}")
|
# logger.info(f"返回消息:{return_message}")
|
||||||
await bot.api.post_group_msg(group_id=msg["group_id"], text=return_message)
|
await bot.api.post_group_msg(group_id=msg["group_id"], text=return_message)
|
||||||
|
|
||||||
|
|
||||||
|
bot.run_frontend()
|
||||||
|
|
||||||
|
|
||||||
asyncio.get_event_loop().run_forever()
|
|
||||||
@@ -24,9 +24,6 @@ def main(message,qid,group_openid):
|
|||||||
elif ai_service == "mcunc":
|
elif ai_service == "mcunc":
|
||||||
from model.ai_models import mcunc
|
from model.ai_models import mcunc
|
||||||
return mcunc.main(message, group_openid)
|
return mcunc.main(message, group_openid)
|
||||||
elif ai_service == "xyit":
|
|
||||||
from model.ai_models import xyit
|
|
||||||
return xyit.main(message, group_openid)
|
|
||||||
elif ai_service == "aliyun":
|
elif ai_service == "aliyun":
|
||||||
from model.ai_models import aliyun
|
from model.ai_models import aliyun
|
||||||
return aliyun.main(message, group_openid)
|
return aliyun.main(message, group_openid)
|
||||||
|
|||||||
@@ -1,76 +0,0 @@
|
|||||||
import requests
|
|
||||||
import json
|
|
||||||
from model.logger import setup_logger
|
|
||||||
import toml
|
|
||||||
from model.sql_tools import init_db
|
|
||||||
from model.sql_tools import get_uuid
|
|
||||||
from model.sql_tools import add_uuid
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
logger = setup_logger()
|
|
||||||
def main(message, group_openid):
|
|
||||||
with open('./config.toml', 'r', encoding='utf-8') as f:
|
|
||||||
config = toml.load(f)
|
|
||||||
|
|
||||||
error_message = config.get("error_message")
|
|
||||||
|
|
||||||
# xyit
|
|
||||||
xyit_ip = config.get("xyit_ip")
|
|
||||||
xyit_appID = config.get("xyit_appID")
|
|
||||||
xyit_appKEY = config.get("xyit_appKEY")
|
|
||||||
xyit_model = config.get("xyit_model")
|
|
||||||
|
|
||||||
init_db()
|
|
||||||
|
|
||||||
uuid = get_uuid(group_openid)
|
|
||||||
|
|
||||||
if uuid == "":
|
|
||||||
logger.info("未找到 UUID")
|
|
||||||
else:
|
|
||||||
logger.info(f"找到 UUID: {uuid}")
|
|
||||||
|
|
||||||
url = f"{xyit_ip}/models/{xyit_model}/" # 替换为实际的 API 地址
|
|
||||||
|
|
||||||
# 请求头
|
|
||||||
headers = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"appID": xyit_appID, # 替换为你的 API 密钥
|
|
||||||
"appKEY": xyit_appKEY
|
|
||||||
}
|
|
||||||
|
|
||||||
# 请求体
|
|
||||||
payload = {
|
|
||||||
"query": message, # 用户输入/提问内容
|
|
||||||
"conversation_id": uuid, # (选填)会话 ID,继续对话时需要传入
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("请求平台:xyit")
|
|
||||||
|
|
||||||
|
|
||||||
# 发送 POST 请求
|
|
||||||
try:
|
|
||||||
response = requests.post(url, headers=headers, data=json.dumps(payload))
|
|
||||||
|
|
||||||
# 检查响应状态码
|
|
||||||
if response.status_code == 200:
|
|
||||||
logger.info("请求成功!返回结果:")
|
|
||||||
response_data = response.json()
|
|
||||||
print(response_data) # test
|
|
||||||
# 存储uuid
|
|
||||||
if uuid == "":
|
|
||||||
uuid = response_data.get("conversation_id")
|
|
||||||
add_uuid(group_openid, uuid)
|
|
||||||
|
|
||||||
# 提取 answer 值
|
|
||||||
answer = response_data.get("answer", error_message)
|
|
||||||
return answer
|
|
||||||
else:
|
|
||||||
logger.info(f"请求失败!状态码: {response.status_code}")
|
|
||||||
logger.info(f"错误信息: {response.text}") # 打印错误信息
|
|
||||||
return error_message
|
|
||||||
|
|
||||||
except Exception as e:
|
|
||||||
logger.info(f"请求过程中出现异常: {e}")
|
|
||||||
return error_message
|
|
||||||
|
|
||||||
25
ncatbot.yaml
Normal file
25
ncatbot.yaml
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
root: '1453599706'
|
||||||
|
bt_uin: '3917995084'
|
||||||
|
enable_webui_interaction: null
|
||||||
|
debug: false
|
||||||
|
github_proxy: null
|
||||||
|
check_ncatbot_update: true
|
||||||
|
skip_ncatbot_install_check: false
|
||||||
|
websocket_timeout: 15
|
||||||
|
napcat:
|
||||||
|
ws_uri: ws://sz.mcunc.site:13001
|
||||||
|
ws_token: 79_t&_e@WJ#HgXXp
|
||||||
|
ws_listen_ip: 0.0.0.0
|
||||||
|
webui_uri: http://sz.mcunc.site:26099
|
||||||
|
webui_token: U16z8RnYNls]W[N|
|
||||||
|
enable_webui: true
|
||||||
|
check_napcat_update: false
|
||||||
|
stop_napcat: false
|
||||||
|
remote_mode: false
|
||||||
|
report_self_message: false
|
||||||
|
report_forward_message_detail: true
|
||||||
|
plugin:
|
||||||
|
plugins_dir: plugins
|
||||||
|
plugin_whitelist: []
|
||||||
|
plugin_blacklist: []
|
||||||
|
skip_plugin_load: false
|
||||||
Reference in New Issue
Block a user