当前位置:网站首页>基于NoneBot2的qq机器人配置记录
基于NoneBot2的qq机器人配置记录
2022-07-28 12:56:00 【我叫辰辰啦】
基于NoneBot2的qq机器人配置记录
项目参考地址:https://github.com/nonebot/nonebot2
nonebot2说明文档:https://v2.nonebot.dev/docs/start/installation
1.venv创建虚拟环境
创建环境:
python3 -m venv nonebot2_env
进入环境:
source ~/nonebot2_env/bin/activate
可以看到,进入虚拟环境后命令行的提示符前面会出现括号,里面是虚拟环境名称。
2.安装nonebot2,驱动器与协议适配器
安装nb-cli:
pip install nb-cli
安装驱动器:
查看所有驱动:
nb driver list
nb driver install
安装协议适配器:
nb adapter list
nb adapter install
3.创建项目
nb create
依次选择:
In a “nonebot2” folder
echo
OneBot V11
4.安装go-cqhttp
项目地址:https://github.com/Mrs4s/go-cqhttp
下载:(注意可以更换为最新的下载链接)
wget https://github.com/Mrs4s/go-cqhttp/releases/download/v1.0.0-rc3/go-cqhttp_linux_386.tar.gz
解压:
tar -xzvf go-cqhttp_linux_386.tar.gz
输入 ./go-cqhttp, Enter运行 , 此时将提示
选择反向websocket通信
打开config.yml文件:
1)将uin修改为bot账号
2)在config.yml文件中将
universal: ws://your_websocket_universal.server
修改为
universal: ws://127.0.0.1:8080/onebot/v11/ws/
然后需要在本地上下载windows版本的go-cqhttp配置时输入账号密码然后登陆成功,再将此时本地的device.json复制替换掉云端的,这样才可以在服务器上登陆qq成功。
5.配置nonebot2
在.env.prod中配置:
HOST=127.0.0.1 # 配置 NoneBot 监听的 IP/主机名
PORT=8080 # 配置 NoneBot 监听的端口
SUPERUSERS=["123456"] # qq号
NICKNAME=["chenchen_bot"] # 配置机器人的昵称
COMMAND_START=["/", ""] # 配置命令起始字符
之后同时启动nonebot2与go-cqhttp
此时在qq中对机器人输入对话
/echo test
qq机器人返回test即测试成功!
6.安装插件
在nonebot2文件夹下输入命令安装:
nb plugin install nonebot_plugin_petpet
并在bot.py中加载插件:
nonebot.load_builtin_plugins("echo") #这是nonebot2自带的echo功能
nonebot.load_builtin_plugins("nonebot-plugin-petpet") #加载的插件
边栏推荐
- R语言ggplot2可视化:使用ggpubr包的ggviolin函数可视化小提琴图、设置draw_quantiles参数添加指定分位数横线(例如,50%分位数、中位数)
- R language ggplot2 visualization: use ggviolin function of ggpubr package to visualize violin diagram and set draw_ The quantiles parameter adds a specified quantile horizontal line (for example, 50%
- vite在项目中配置路径别名
- Uva11175 digraph D and E from D to e and back
- Better and more modern terminal tools than xshell!
- Istio四之故障注入和链路追踪
- 性能超群!牛津&上海AI Lab&港大&商汤&清华强强联手,提出用于引用图像分割的语言感知视觉Transformer!代码已开源...
- Li Kou sword finger offer 51. reverse order pairs in the array
- What if the server cannot be connected (the original server cannot find the target resource)
- I miss the year of "losing" Li Ziqi
猜你喜欢
JWT 登录认证 + Token 自动续期方案,写得太好了!

Cool operation preheating! Code to achieve small planet effect

Better and more modern terminal tools than xshell!

第六章 支持向量机

SLAM论文合集

Countdown 2 days! 2022 China Computing Conference: Mobile cloud invites you to meet with computing network for innovative development

Use non recursive method to realize layer traversal, preorder traversal, middle order traversal and post order traversal in binary tree

Deploy application delivery services in kubernetes (Part 1)

DXF reading and writing: align the calculation of the position of the dimension text in the middle and above

30 day question brushing plan (II)
随机推荐
UVA11175有向图D和E From D to E and Back题解
彻底掌握二分查找
JWT 登录认证 + Token 自动续期方案,写得太好了!
DXF reading and writing: Chinese description of dimension style group codes
strcmp、strstr、memcpy、memmove的实现
Humiliation, resistance, reversal, 30 years, China should win Microsoft once
R语言检验样本比例:使用prop.test函数执行单样本比例检验计算总体中成功样本比例p值的置信区间(设置conf.level参数指定置信水平、置信区间的大小)
Poj1860 currency exchange solution
Analyzing the principle of DNS resolution in kubernetes cluster
vite在项目中配置路径别名
Vite configuring path aliases in the project
Merge table rows - three levels of for loop traversal data
R语言使用dpois函数生成泊松分布密度数据、使用plot函数可视化泊松分布密度数据(Poisson distribution)
要想组建敏捷团队,这些方法不可少
算法---不同路径(Kotlin)
Socket class understanding and learning about TCP character stream programming
SAP ui5 fileuploader control realizes local file upload, and trial version of cross domain access error encountered when receiving server-side response
第六章 支持向量机
面经整理,助力秋招,祝你称为offer收割机
【LVGL事件(Events)】事件代码