Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

未加好友的临时消息不存在 target_id 抛出异常 #41

Open
Cody-Wolf opened this issue Jul 14, 2023 · 0 comments
Open

未加好友的临时消息不存在 target_id 抛出异常 #41

Cody-Wolf opened this issue Jul 14, 2023 · 0 comments

Comments

@Cody-Wolf
Copy link

Cody-Wolf commented Jul 14, 2023

class Private_Message(Message):
    """私聊消息"""

    def __init__(self, cqapi: cqHttpApi, event: Message_Event, message_data: dict[str, Any]) -> None:
        super().__init__(cqapi, event, message_data)

        self.sender: Private_User = Private_User(self._cqapi, message_data["sender"])
        """发送人"""
        
        self.target_id: int = message_data["target_id"] # 抛出异常,target_id 不存在
        """接收者 QQ 号"""

实际接收的 message json

{'post_type': 'message', 'message_type': 'private', 'time': 1689303412, 'self_id': ***, 'sub_type': 'group', 'temp_source': 0, 'message_id': 61502, 'user_id': ***, 'message': '123', 'raw_message': '123', 'font': 0, 'sender': {'age': 0, 'group_id': ***, 'nickname': 'Cody', 'sex': 'unknown', 'user_id': ***}}

貌似没有 target_id 这一项?我理解这里应该是 self_id ?

@Cody-Wolf Cody-Wolf changed the title 未加好友的临时消息抛出异常 未加好友的临时消息不存在 target_id 抛出异常 Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant