mirai QQ机器人环境安装 step1 安装 mirai-console 通过mcl-installer安装
github: https://github.com/iTXTech/mcl-installer
下载linux版本
也可以通过MiraiOk进行安装
github: https://github.com/LXY1226/MiraiOK
step2 安装 mirai-http-api 将jar包放到2中项目里的plugins文件夹下,配置config\MiraiApiHttp\setting.yml
文件里的authKey
,自己随便填写。
step3 启动mirai-console登录QQ号 mcl的话直接运行./mcl即可
出现滑动认证时 1 ./mcl --update-package net.mamoe:mirai-login-solver-selenium --channel nightly --type plugin
ref: https://github.com/project-mirai/mirai-login-solver-selenium
step 4安装graia模块 github: https://github.com/GraiaProject/Application
1 2 pip3 install graia-application-mirai pip3 install graia-broadcast --upgrade
1 2 3 4 version: graia-application-mirai==0.19.2 graia-broadcast==0.8.11 graia.scheduler==0.0.4
step 5编写qq机器人脚本 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 from graia.broadcast import Broadcastfrom graia.application import GraiaMiraiApplication, Sessionfrom graia.application.message.chain import MessageChainimport asynciofrom graia.application.message.elements.internal import Plainfrom graia.application.friend import Friend loop = asyncio.get_event_loop() bcc = Broadcast(loop=loop) app = GraiaMiraiApplication( broadcast=bcc, connect_info=Session( host="http://localhost:8080" , authKey="0123456789" , account=88888888 , websocket=True ) )@bcc.receiver("FriendMessage" ) async def friend_message_listener (message: MessageChain, friend: Friend, app: GraiaMiraiApplication ): msg = message.asDisplay() if msg.startswith(".help" ): await app.sendFriendMessage(friend, MessageChain(__root__=[Plain(".help\t显示帮助指令\r\n.copy\t复读" )])) elif msg.startswith(".copy " ): msg = msg[6 :] await app.sendFriendMessage(friend, MessageChain(__root__=[Plain(msg)])) else : await app.sendFriendMessage(friend, MessageChain(__root__=[Plain("收到!" )])) app.launch_blocking()
运行即可