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],
|
target_id: Optional[str],
|
||||||
bot_id: str,
|
bot_id: str,
|
||||||
bot_self_id: str,
|
bot_self_id: str,
|
||||||
msg_id: str,
|
msg_id: str = '',
|
||||||
at_sender: bool = False,
|
at_sender: bool = False,
|
||||||
|
sender_id: str = '',
|
||||||
):
|
):
|
||||||
if isinstance(message, Message):
|
if isinstance(message, Message):
|
||||||
message = [message]
|
message = [message]
|
||||||
@ -38,8 +39,8 @@ class _Bot:
|
|||||||
elif isinstance(message, bytes):
|
elif isinstance(message, bytes):
|
||||||
message = [MessageSegment.image(message)]
|
message = [MessageSegment.image(message)]
|
||||||
|
|
||||||
if at_sender and target_id:
|
if at_sender and sender_id:
|
||||||
message.append(MessageSegment.at(target_id))
|
message.append(MessageSegment.at(sender_id))
|
||||||
|
|
||||||
send = MessageSend(
|
send = MessageSend(
|
||||||
content=message,
|
content=message,
|
||||||
@ -84,6 +85,7 @@ class Bot:
|
|||||||
self.bot_self_id,
|
self.bot_self_id,
|
||||||
self.ev.msg_id,
|
self.ev.msg_id,
|
||||||
at_sender,
|
at_sender,
|
||||||
|
self.ev.user_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
async def target_send(
|
async def target_send(
|
||||||
@ -92,6 +94,7 @@ class Bot:
|
|||||||
target_type: Literal['group', 'direct', 'channel', 'sub_channel'],
|
target_type: Literal['group', 'direct', 'channel', 'sub_channel'],
|
||||||
target_id: Optional[str],
|
target_id: Optional[str],
|
||||||
at_sender: bool = False,
|
at_sender: bool = False,
|
||||||
|
sender_id: str = '',
|
||||||
):
|
):
|
||||||
return await self.bot.target_send(
|
return await self.bot.target_send(
|
||||||
message,
|
message,
|
||||||
@ -101,4 +104,5 @@ class Bot:
|
|||||||
self.ev.bot_self_id,
|
self.ev.bot_self_id,
|
||||||
self.ev.msg_id,
|
self.ev.msg_id,
|
||||||
at_sender,
|
at_sender,
|
||||||
|
sender_id,
|
||||||
)
|
)
|
||||||
|
@ -58,8 +58,18 @@ class MessageSegment:
|
|||||||
return Message(type='node', data=msg_list)
|
return Message(type='node', data=msg_list)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def record(content: str) -> Message:
|
def record(content: Union[str, bytes, Path]) -> Message:
|
||||||
return Message(type='record', data=content)
|
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
|
@staticmethod
|
||||||
def file(content: Union[Path, str, bytes], file_name: str) -> Message:
|
def file(content: Union[Path, str, bytes], file_name: str) -> Message:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user