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