diff --git a/GenshinUID/__init__.py b/GenshinUID/__init__.py index 6b9259ea..fd3a0021 100644 --- a/GenshinUID/__init__.py +++ b/GenshinUID/__init__.py @@ -27,6 +27,7 @@ async def get_gs_msg(ev): user_id = str(ev.user_id) msg_id = str(ev.message_id) group_id = str(ev.group_id) + self_id = str(ev.self_id) messages = ev.message message: List[Message] = [] msg_id = '' @@ -65,6 +66,7 @@ async def get_gs_msg(ev): user_type = 'group' if group_id else 'direct' msg = MessageReceive( bot_id=bot_id, + bot_self_id=self_id, user_type=sp_user_type if sp_user_type else user_type, group_id=group_id, user_id=user_id, diff --git a/GenshinUID/client.py b/GenshinUID/client.py index 4998eea3..261ac617 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -43,7 +43,10 @@ class GsClient: # 解析消息 if msg.bot_id == 'NoneBot2': continue + bot = hoshino_bot + # self_ids = hoshino.get_self_ids() + content = '' image: Optional[str] = None node = [] @@ -74,11 +77,14 @@ class GsClient: image, node, file, + msg.bot_self_id, msg.target_id, msg.target_type, ) except Exception as e: logger.error(e) + except RuntimeError: + pass except ConnectionClosedError: logger.warning(f'与[gsuid-core]断开连接! Bot_ID: {BOT_ID}') self.is_alive = False @@ -127,6 +133,7 @@ async def onebot_send( image: Optional[str], node: Optional[List[Dict]], file: Optional[str], + bot_self_id: Optional[str], target_id: Optional[str], target_type: Optional[str], ): @@ -156,14 +163,14 @@ async def onebot_send( del_file(path) else: if target_type == 'group': - await bot.call_action( - 'send_group_msg', + await bot.send_group_msg( + self_id=bot_self_id, group_id=target_id, message=result_msg, ) else: - await bot.call_action( - 'send_private_msg', + await bot.send_private_msg( + self_id=bot_self_id, user_id=target_id, message=result_msg, ) diff --git a/GenshinUID/models.py b/GenshinUID/models.py index dc312814..2c037d45 100644 --- a/GenshinUID/models.py +++ b/GenshinUID/models.py @@ -10,6 +10,7 @@ class Message(Struct): class MessageReceive(Struct): bot_id: str = 'Bot' + bot_self_id: str = '' msg_id: str = '' user_type: Literal['group', 'direct', 'channel', 'sub_channel'] = 'group' group_id: Optional[str] = None @@ -31,6 +32,7 @@ class MessageContent(Struct): class MessageSend(Struct): bot_id: str = 'Bot' + bot_self_id: str = '' msg_id: str = '' target_type: Optional[str] = None target_id: Optional[str] = None