mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
🐛 修复不正确的链接方式
This commit is contained in:
parent
7c44c6cba5
commit
2a4af236b5
@ -1,6 +1,7 @@
|
|||||||
from typing import List, Literal, Optional
|
from typing import List, Literal, Optional
|
||||||
|
|
||||||
from hoshino import priv
|
from hoshino import priv
|
||||||
|
from websockets.exceptions import ConnectionClosed
|
||||||
from hoshino.typing import CQEvent, HoshinoBot, NoticeSession
|
from hoshino.typing import CQEvent, HoshinoBot, NoticeSession
|
||||||
|
|
||||||
from .client import GsClient
|
from .client import GsClient
|
||||||
@ -15,12 +16,18 @@ async def connect():
|
|||||||
global gsclient
|
global gsclient
|
||||||
try:
|
try:
|
||||||
gsclient = await GsClient().async_connect()
|
gsclient = await GsClient().async_connect()
|
||||||
|
await gsclient.start()
|
||||||
except ConnectionRefusedError:
|
except ConnectionRefusedError:
|
||||||
logger.error('Core服务器连接失败...请稍后使用[启动core]命令启动...')
|
logger.error('Core服务器连接失败...请稍后使用[启动core]命令启动...')
|
||||||
|
|
||||||
|
|
||||||
async def get_gs_msg(ev):
|
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()
|
await connect()
|
||||||
|
|
||||||
# 通用字段获取
|
# 通用字段获取
|
||||||
|
@ -33,7 +33,6 @@ class GsClient:
|
|||||||
logger.info(f'与[gsuid-core]成功连接! Bot_ID: {BOT_ID}')
|
logger.info(f'与[gsuid-core]成功连接! Bot_ID: {BOT_ID}')
|
||||||
cls.msg_list = asyncio.queues.Queue()
|
cls.msg_list = asyncio.queues.Queue()
|
||||||
cls.pending = []
|
cls.pending = []
|
||||||
await self.start()
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def __new__(cls, *args, **kwargs):
|
def __new__(cls, *args, **kwargs):
|
||||||
@ -118,6 +117,7 @@ class GsClient:
|
|||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
try:
|
try:
|
||||||
await self.async_connect()
|
await self.async_connect()
|
||||||
|
await self.start()
|
||||||
break
|
break
|
||||||
except: # noqa
|
except: # noqa
|
||||||
logger.debug('自动连接core服务器失败...五秒后重新连接...')
|
logger.debug('自动连接core服务器失败...五秒后重新连接...')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user