🐛 修复不正确的链接方式

This commit is contained in:
Wuyi无疑 2023-04-18 02:45:58 +08:00
parent 7c44c6cba5
commit 2a4af236b5
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,7 @@
from typing import List, Literal, Optional
from hoshino import priv
from websockets.exceptions import ConnectionClosed
from hoshino.typing import CQEvent, HoshinoBot, NoticeSession
from .client import GsClient
@ -15,12 +16,18 @@ async def connect():
global gsclient
try:
gsclient = await GsClient().async_connect()
await gsclient.start()
except ConnectionRefusedError:
logger.error('Core服务器连接失败...请稍后使用[启动core]命令启动...')
async def get_gs_msg(ev):
if gsclient is None or not gsclient.is_alive:
if gsclient is None:
return await connect()
try:
await gsclient.ws.ping()
except ConnectionClosed:
await connect()
# 通用字段获取

View File

@ -33,7 +33,6 @@ class GsClient:
logger.info(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):
@ -118,6 +117,7 @@ class GsClient:
await asyncio.sleep(5)
try:
await self.async_connect()
await self.start()
break
except: # noqa
logger.debug('自动连接core服务器失败...五秒后重新连接...')