mirror of
https://github.com/Genshin-bots/gsuid_core.git
synced 2025-05-12 06:55:49 +08:00
🐛 修复at_sender
的问题
This commit is contained in:
parent
1edf3b8bb6
commit
7dfce8f96e
@ -25,8 +25,9 @@ class _Bot:
|
||||
target_id: Optional[str],
|
||||
bot_id: str,
|
||||
bot_self_id: str,
|
||||
msg_id: str,
|
||||
msg_id: str = '',
|
||||
at_sender: bool = False,
|
||||
sender_id: str = '',
|
||||
):
|
||||
if isinstance(message, Message):
|
||||
message = [message]
|
||||
@ -38,8 +39,8 @@ class _Bot:
|
||||
elif isinstance(message, bytes):
|
||||
message = [MessageSegment.image(message)]
|
||||
|
||||
if at_sender and target_id:
|
||||
message.append(MessageSegment.at(target_id))
|
||||
if at_sender and sender_id:
|
||||
message.append(MessageSegment.at(sender_id))
|
||||
|
||||
send = MessageSend(
|
||||
content=message,
|
||||
@ -84,6 +85,7 @@ class Bot:
|
||||
self.bot_self_id,
|
||||
self.ev.msg_id,
|
||||
at_sender,
|
||||
self.ev.user_id,
|
||||
)
|
||||
|
||||
async def target_send(
|
||||
@ -92,6 +94,7 @@ class Bot:
|
||||
target_type: Literal['group', 'direct', 'channel', 'sub_channel'],
|
||||
target_id: Optional[str],
|
||||
at_sender: bool = False,
|
||||
sender_id: str = '',
|
||||
):
|
||||
return await self.bot.target_send(
|
||||
message,
|
||||
@ -101,4 +104,5 @@ class Bot:
|
||||
self.ev.bot_self_id,
|
||||
self.ev.msg_id,
|
||||
at_sender,
|
||||
sender_id,
|
||||
)
|
||||
|
@ -58,8 +58,18 @@ class MessageSegment:
|
||||
return Message(type='node', data=msg_list)
|
||||
|
||||
@staticmethod
|
||||
def record(content: str) -> Message:
|
||||
return Message(type='record', data=content)
|
||||
def record(content: Union[str, bytes, Path]) -> Message:
|
||||
if isinstance(content, bytes):
|
||||
pass
|
||||
elif isinstance(content, Path):
|
||||
with open(str(content), 'rb') as fp:
|
||||
content = fp.read()
|
||||
else:
|
||||
if content.startswith('base64://'):
|
||||
return Message(type='image', data=content)
|
||||
with open(content, 'rb') as fp:
|
||||
content = fp.read()
|
||||
return Message(type='record', data=f'base64://{content}')
|
||||
|
||||
@staticmethod
|
||||
def file(content: Union[Path, str, bytes], file_name: str) -> Message:
|
||||
|
Loading…
x
Reference in New Issue
Block a user