From 1e5bf76ff35b300cea8bc281f07fad887083537e Mon Sep 17 00:00:00 2001 From: lyz05 <294068487@qq.com> Date: Wed, 13 Dec 2023 11:54:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DOpenAI=E6=9C=BA?= =?UTF-8?q?=E5=99=A8=E4=BA=BA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tgbot/bot/airportsub.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tgbot/bot/airportsub.js b/tgbot/bot/airportsub.js index 6740945..e730fe5 100644 --- a/tgbot/bot/airportsub.js +++ b/tgbot/bot/airportsub.js @@ -63,30 +63,30 @@ module.exports = (TOKEN) => { } }); - // // 智能聊天机器人 - // bot.on("text", (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); - // }); - // } - // }); - - // ChatGPT版智能聊天机器人 - bot.on("text", async (msg) => { + // 智能聊天机器人 + bot.on("text", (msg) => { if (msg.text.indexOf("/") === -1) { bot.sendMessage(msg.chat.id, `you said: ${msg.text}`); - let messages = openai_messages[msg.chat.id] || [], res; - [res, messages] = await openai.chat(msg.text, messages); - const length = (messages.length - 1) / 2; - bot.sendMessage(msg.chat.id, `${res}\n\nPowered by OpenAI 连续对话了${length}次`); - openai_messages[msg.chat.id] = messages; + 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); + }); } }); + // ChatGPT版智能聊天机器人 + // bot.on("text", async (msg) => { + // if (msg.text.indexOf("/") === -1) { + // bot.sendMessage(msg.chat.id, `you said: ${msg.text}`); + // let messages = openai_messages[msg.chat.id] || [], res; + // [res, messages] = await openai.chat(msg.text, messages); + // const length = (messages.length - 1) / 2; + // bot.sendMessage(msg.chat.id, `${res}\n\nPowered by OpenAI 连续对话了${length}次`); + // openai_messages[msg.chat.id] = messages; + // } + // }); + bot.onText(/\/clear/, (msg) => { openai_messages[msg.chat.id] = []; bot.sendMessage(msg.chat.id, "已清空对话记录");