mirror of
https://github.com/lyz05/danmaku.git
synced 2026-02-02 17:59:53 +08:00
fix: 修复聊天机器人错误
This commit is contained in:
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user