    def _get_chat_by_user_name(self, user_name):
        """
        通过 user_name 找到对应的聊天对象

        :param user_name: user_name
        :return: 找到的对应聊天对象
        """

        def match_in_chats(_chats):
            for c in _chats:
                if c.user_name == user_name:
                    return c

        _chat = None

        if user_name.startswith('@@'):
            _chat = match_in_chats(self.bot.groups())
        elif user_name:
            _chat = match_in_chats(self.bot.friends())
            if not _chat:
                _chat = match_in_chats(self.bot.mps())

        if not _chat:
            _chat = Chat(wrap_user_name(user_name), self.bot)

        return _chat
通过 user_name 找到对应的聊天对象

:param user_name: user_name
:return: 找到的对应聊天对象
wxpy/api/messages/message.py