diff --git a/gsuid_core/bot.py b/gsuid_core/bot.py index f756a80..ee083df 100644 --- a/gsuid_core/bot.py +++ b/gsuid_core/bot.py @@ -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, ) diff --git a/gsuid_core/segment.py b/gsuid_core/segment.py index e067180..82adea2 100644 --- a/gsuid_core/segment.py +++ b/gsuid_core/segment.py @@ -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: