mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
♻️ 改进代码 (#591)
* refactor: 改进代码
* 🚨 `pre-commit-ci`修复格式错误
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
44bd8b63b6
commit
5d793c65c4
@ -405,11 +405,12 @@ async def onebot_red_send(
|
|||||||
target_type: Optional[str],
|
target_type: Optional[str],
|
||||||
):
|
):
|
||||||
from nonebot.adapters.red.bot import Bot
|
from nonebot.adapters.red.bot import Bot
|
||||||
|
from nonebot.adapters.red.api.model import ChatType
|
||||||
from nonebot.adapters.red.message import Message, MessageSegment
|
from nonebot.adapters.red.message import Message, MessageSegment
|
||||||
|
|
||||||
assert isinstance(bot, Bot)
|
assert isinstance(bot, Bot)
|
||||||
|
|
||||||
chat_type = 2 if target_type == 'group' else 1
|
chat_type = ChatType.GROUP if target_type == 'group' else ChatType.FRIEND
|
||||||
|
|
||||||
async def _send(content: Optional[str], image: Optional[str]):
|
async def _send(content: Optional[str], image: Optional[str]):
|
||||||
result_msg: Message = Message()
|
result_msg: Message = Message()
|
||||||
@ -431,11 +432,7 @@ async def onebot_red_send(
|
|||||||
result_msg += MessageSegment.file(path)
|
result_msg += MessageSegment.file(path)
|
||||||
|
|
||||||
if target_id:
|
if target_id:
|
||||||
await bot.send_message(
|
await bot.send_message(chat_type, target_id, result_msg)
|
||||||
chat_type, # type: ignore
|
|
||||||
target_id,
|
|
||||||
result_msg,
|
|
||||||
)
|
|
||||||
|
|
||||||
if file:
|
if file:
|
||||||
del_file(path) # type: ignore
|
del_file(path) # type: ignore
|
||||||
|
Loading…
x
Reference in New Issue
Block a user