fix: 修复聊天机器人错误

This commit is contained in:
lyz05
2023-12-13 22:43:15 +08:00
parent 7c8ce307f7
commit fb1725dc94

View File

@@ -6,6 +6,7 @@ const axios = require("axios");
const oss = require("../../utils/oss");
const goindex = require("../api/goindex");
const openai = require("../api/openai");
const https = require('https');
async function finduserbychatid(chatid) {
const database = await oss.get("SUB/database.yaml");
@@ -64,14 +65,15 @@ module.exports = (TOKEN) => {
});
// 智能聊天机器人
bot.on("text", (msg) => {
bot.on("text",async (msg) => {
if (msg.text.indexOf("/") === -1) {
bot.sendMessage(msg.chat.id, `you said: ${msg.text}`);
axios.get(`https://api.qingyunke.com/api.php?key=free&appid=0&msg=${encodeURI(msg.text)}`)
.then((res) => {
console.log(res.data);
bot.sendMessage(msg.chat.id, res.data.content);
});
const agent = new https.Agent({
rejectUnauthorized: false
});
const res = await axios.get(`https://api.qingyunke.com/api.php?key=free&appid=0&msg=${encodeURI(msg.text)}`, { httpsAgent: agent })
console.log(res.data);
bot.sendMessage(msg.chat.id, res.data.content);
}
});