From 8b0473c331dc82715c93ecd0ade3f6f96d8e054a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wuyi=E6=97=A0=E7=96=91?= <444835641@qq.com> Date: Tue, 18 Apr 2023 02:43:03 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E5=8F=AF=E4=BB=A5=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E6=8E=A5=E6=94=B6=E9=A2=91=E9=81=93=E7=9A=84=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E4=BA=8B=E4=BB=B6=20(#505)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/__init__.py | 12 +++++++++++- GenshinUID/client.py | 1 - pyproject.toml | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/GenshinUID/__init__.py b/GenshinUID/__init__.py index 29864c60..2b948709 100644 --- a/GenshinUID/__init__.py +++ b/GenshinUID/__init__.py @@ -107,7 +107,12 @@ async def get_notice_message(bot: Bot, ev: Event): @get_message.handle() async def get_all_message(bot: Bot, ev: Event): - if gsclient is None or not gsclient.is_alive: + if gsclient is None: + return await connect() + + try: + await gsclient.ws.ping() + except ConnectionClosed: return await connect() # 通用字段获取 @@ -150,6 +155,10 @@ async def get_all_message(bot: Bot, ev: Event): else: logger.debug('[gsuid] 不支持该 QQ Guild 事件...') return + + if ev.message_reference: + reply_msg_id = ev.message_reference.message_id + message.append(Message('reply', reply_msg_id)) # telegram elif bot.adapter.get_name() == 'Telegram': from nonebot.adapters.telegram.event import ( @@ -391,6 +400,7 @@ async def connect(): global gsclient try: gsclient = await GsClient().async_connect() + await gsclient.start() except ConnectionRefusedError: logger.error('Core服务器连接失败...请稍后使用[启动core]命令启动...') diff --git a/GenshinUID/client.py b/GenshinUID/client.py index c60ff2f1..b5d95a74 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -68,7 +68,6 @@ class GsClient: logger.success(f'与[gsuid-core]成功连接! Bot_ID: {BOT_ID}') cls.msg_list = asyncio.queues.Queue() cls.pending = [] - await self.start() return self def __new__(cls, *args, **kwargs): diff --git a/pyproject.toml b/pyproject.toml index 768c9695..ce089722 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "nonebot-plugin-genshinuid" -version = "4.0.3" +version = "4.0.4" description = "支持OneBot(QQ)、OneBotV12、QQ频道、微信、KOOK(开黑啦)、Telegram(电报)、FeiShu(飞书)的全功能NoneBot2原神插件" authors = ["KimigaiiWuyi <444835641@qq.com>"] license = "GPL-3.0-or-later"