机器人框架:Graia Framework
1.安装Java运行时(版本必须 >= 11)
2.下载MCL
3.双击运行mcl.cmd
4.配置自动登录信息config/Console/AutoLogin.yml:
5.安装辅助登录插件
mcl --update-package net.mamoe:mirai-login-solver-selenium --channel nightly --type plugin
运行mcl.cmd,拖动滑块验证登录
6.安装mirai-api-http
mcl --update-package net.mamoe:mirai-api-http --channel stable --type plugin
运行mcl.cmd,记录config/net.mamoe.mirai-api-http/setting.yml的authKey
7.编写机器人业务代码
from graia.broadcast import Broadcast from graia.application import GraiaMiraiApplication, Session from graia.application.message.chain import MessageChain import asyncio from graia.application.message.elements.internal import Plain from 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", # 填入 httpapi 服务运行的地址 authKey="graia-mirai-api-http-authkey", # 填入 authKey account=5234120587, # 你的机器人的 qq 号 websocket=True # Graia 已经可以根据所配置的消息接收的方式来保证消息接收部分的正常运作. ) ) @bcc.receiver("FriendMessage") async def friend_message_listener(app: GraiaMiraiApplication, friend: Friend): await app.sendFriendMessage(friend, MessageChain.create([ Plain("Hello, World!") ])) app.launch_blocking()