GraiaProject / Application

一个设计精巧, 协议实现完备的, 基于 mirai-api-http 的即时聊天软件自动化框架.
https://graia-document.vercel.app/
GNU Affero General Public License v3.0
438 stars 63 forks source link

示例运行错误 #100

Closed RF-Tar-Railt closed 3 years ago

RF-Tar-Railt commented 3 years ago

描述你遇到的问题: 文档示例运行失败

复现步骤: 该 BUG 会在进行以下操作后出现:

  1. 使用文档中 历史性的第一次对话 的代码运行
  2. 报错 graia.application.exceptions.InvaildAuthkey

发生错误的代码 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=258***, # 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()

控制台日志输出截图: mirai-console 控制台无额外输出 [2021-03-09 23:03:33,243][INFO]: initializing app... Traceback (most recent call last): File "D:/Download/mcl-1.0.5/plugins/test_bot.py", line 28, in app.launch_blocking() File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\site-packages\graia\application__init.py", line 1578, in launch_blocking loop.run_until_complete(self.initialize()) File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\asyncio\base_events.py", line 616, in run_until_complete return future.result() File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\site-packages\graia\application\init.py", line 1468, in initialize await self.authenticate() File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\site-packages\graia\application\utilles.py", line 27, in wrapper return await func(self, *args, **kwargs) File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\site-packages\graia\application\init__.py", line 310, in authenticate raise_for_return_code(data) File "C:\Users\TR\AppData\Local\Programs\Python\Python38\lib\site-packages\graia\application\utilles.py", line 114, in raise_for_return_code raise exception_code graia.application.exceptions.InvaildAuthkey

运行环境:

额外信息:

karakoo commented 3 years ago

最后一行graia.application.exceptions.InvaildAuthkey已经说明了问题了 你的authkey错误