搭建一个基于ChatGPT的QQ机器人(Yunzai-Bot) For Mac
前言
最近ChatGPT挺火的.网上教程也多.推荐:
- chatgpt-mac ChatGPT Mac客户端
 - chatgpt-api ChatGPT API(node.js)
 - chatgpt-vscode ChatGPT VSCode插件
 - ChatGPT ChatGPT API(Python)
 - chatgpt-twitter-bot Twitter机器人
 - chatgpt-desktop ChatGPT客户端,支持Windows和Mac
 - chatgpt-advanced 可联网ChatGPT Chrome插件
 - summarize.site ChatGPT生成页面内容摘要的浏览器插件,目前似乎仅支持英文页面
 - chatgpt-telegram telegram机器人
 - wechat-chatgpt ChatGPT 的微信 Bot
 - QChatBot-GPT 基于 OpenAI GPT-3 和 Mirai 的 QQ Bot 聊天机器人
 - chatgpt-plugin 云崽qq机器人的chatgpt插件
 - 等等..
 
自己在本机搭建了下,感觉挺简单的,打算又水一篇.😁
如果没openai账号就玩不了.
环境准备
安装:
1  | brew install nodejs  | 
没有安装brew?
方法一:完整版安装脚本
1  | /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"  | 
方法二:精简版安装脚本
1  | /bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" speed  | 
QQ机器人软件及插件的安装
Yunzai-Bot的安装
使用git下载项目
1  | git clone --depth=1 -b main https://github.com/Le-niao/Yunzai-Bot.git  | 
进入Yunzai目录
1  | cd Yunzai-Bot  | 
安装依赖
1  | pnpm install -P  | 
chatgpt-plugin的安装
进入yunzai根目录
1  | cd Yunzai-Bot  | 
安装依赖
1  | pnpm install -w chatgpt undici showdown mathjax-node  | 
克隆项目
1  | git clone https://github.com/ikechan8370/chatgpt-plugin.git ./plugins/chatgpt-plugin  | 
修改配置
编辑plugins/chatgpt/config/index.js文件主要修改其中的SESSION_TOKEN常量
1  | const SESSION_TOKEN = ''  | 
访问https://chat.openai.com/chat右键检查或者F12
在应用中找到**__Secure-next-auth.session-token**

然后复制内容到引号之间.

启动机器人
1  | node app  | 
其他插件
https://github.com/yhArcadia/Yunzai-Bot-plugins-index
(不过目前OpenAI套了CF,访问API变得困难.非官方chatgpt-api)