mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
🎨 省略部分消息段
This commit is contained in:
parent
05deb6404f
commit
0ffaa950c2
@ -1,4 +1,4 @@
|
||||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
from nonebot.log import logger
|
||||
from nonebot.matcher import Matcher
|
||||
@ -14,7 +14,7 @@ get_message = on_message(priority=999)
|
||||
install_core = on_fullmatch('gs一键安装', permission=SUPERUSER, block=True)
|
||||
start_core = on_fullmatch('启动core', permission=SUPERUSER, block=True)
|
||||
driver = get_driver()
|
||||
gsclient: GsClient
|
||||
gsclient: Optional[GsClient] = None
|
||||
|
||||
|
||||
@get_message.handle()
|
||||
@ -36,14 +36,14 @@ async def send_char_adv(ev: Event):
|
||||
return
|
||||
msg = MessageReceive(
|
||||
bot_id=bot_id,
|
||||
user_type='group' if group_id else 'user',
|
||||
user_type='group' if group_id else 'direct',
|
||||
group_id=group_id,
|
||||
user_id=user_id,
|
||||
content=message,
|
||||
)
|
||||
if gsclient is None:
|
||||
await start_client()
|
||||
logger.info(f'【发送】[gsuid-core]: {msg}')
|
||||
return await start_client()
|
||||
logger.info(f'【发送】[gsuid-core]: {msg.bot_id}')
|
||||
await gsclient._input(msg)
|
||||
|
||||
|
||||
@ -55,11 +55,16 @@ async def send_install_msg(matcher: Matcher):
|
||||
|
||||
@start_core.handle()
|
||||
async def send_start_msg(matcher: Matcher):
|
||||
await matcher.send(await start())
|
||||
await start()
|
||||
await start_client()
|
||||
await matcher.send('启动完成...')
|
||||
|
||||
|
||||
@driver.on_bot_connect
|
||||
async def start_client():
|
||||
global gsclient
|
||||
try:
|
||||
gsclient = await GsClient().async_connect()
|
||||
await gsclient.start()
|
||||
except ConnectionRefusedError:
|
||||
logger.error('Core服务器连接失败...请稍后使用[启动core]命令启动...')
|
||||
|
@ -1,5 +1,4 @@
|
||||
import asyncio
|
||||
from base64 import b64encode
|
||||
from typing import Union, Optional
|
||||
|
||||
import websockets.client
|
||||
@ -51,9 +50,7 @@ class GsClient:
|
||||
# 根据bot_id字段发送消息
|
||||
if msg.bot_id == 'onebot':
|
||||
result_image = (
|
||||
f'[CQ:image,file=base64://{b64encode(image).decode()}]'
|
||||
if image
|
||||
else ''
|
||||
f'[CQ:image,file=base64://{image}]' if image else ''
|
||||
)
|
||||
result_msg = content + result_image
|
||||
if msg.target_type == 'group':
|
||||
|
Loading…
x
Reference in New Issue
Block a user