Skip to content

Commit

Permalink
Merge pull request #12 from ieew/dev
Browse files Browse the repository at this point in the history
处理一个bug
  • Loading branch information
ieew committed Mar 6, 2022
2 parents 3ab9aa3 + 3b9af7d commit bf28859
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions nonebot/adapters/mirai2/adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ def setup(self) -> None:
async def start_ws_client(self):
for qq in self.mirai_config.mirai_qq:
self.tasks.append(asyncio.create_task(self._client(qq)))
else:
await asyncio.wait(self.tasks)

async def stop_ws_client(self):
for task in self.tasks:
if not task.done():
task.cancel()
pass

async def _client(self, self_qq: int):
request = Request(
Expand Down Expand Up @@ -92,16 +92,18 @@ async def _client(self, self_qq: int):
except ConnectionRefusedError as e:
log.warn(f"connection error ({self_qq}):{e} ")
break
except:
log.error(traceback.format_exc())
await asyncio.sleep(3)

async def ws_event(self, ws: WebSocket, self_qq: int, data: dict):
bot = Bot(self, str(self_qq))
self.bot_connect(bot)
self.connections[str(self_qq)] = ws

while True:
data = await ws.receive()
json_data = json.loads(data)
print(data)
if int(json_data.get("syncId") or "0") >= 0:
SyncIDStore.add_response(json_data)
continue
Expand Down
2 changes: 1 addition & 1 deletion nonebot/adapters/mirai2/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def Dice(cls, value: int):
:说明:
掷骰子消息
:参数:
* ``value: int``: 骰子的值
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "nonebot_adapter_mirai2"
version = "0.0.8"
version = "0.0.9"
description = "兼容 MiraiApiHttp2.x 的 nonebot2_adapter"
authors = ["ieew <i@ieew.cc>"]
license = "AGPL-3.0"
Expand Down

0 comments on commit bf28859

Please sign in to comment.