Skip to content

Commit

Permalink
refactor: 改进代码
Browse files Browse the repository at this point in the history
  • Loading branch information
qianxuu committed Oct 12, 2023
1 parent 44bd8b6 commit 6887ceb
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions GenshinUID/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,11 @@ async def onebot_red_send(
):
from nonebot.adapters.red.bot import Bot
from nonebot.adapters.red.message import Message, MessageSegment
from nonebot.adapters.red.api.model import ChatType

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]):
result_msg: Message = Message()
Expand All @@ -431,11 +432,7 @@ async def _send(content: Optional[str], image: Optional[str]):
result_msg += MessageSegment.file(path)

if target_id:
await bot.send_message(
chat_type, # type: ignore
target_id,
result_msg,
)
await bot.send_message(chat_type, target_id, result_msg)

if file:
del_file(path) # type: ignore
Expand Down

0 comments on commit 6887ceb

Please sign in to comment.