    def get_puid(self, chat):
        """
        获取指定聊天对象的 puid

        :param chat: 指定的聊天对象
        :return: puid
        :rtype: str
        """

        with self._thread_lock:

            if not (chat.user_name and chat.nick_name):
                return

            chat_attrs = (
                chat.user_name,
                chat.wxid,
                getattr(chat, 'remark_name', None),
            )

            chat_caption = get_caption(chat)

            puid = None

            for i in range(3):
                puid = self.attr_dicts[i].get(chat_attrs[i])
                if puid:
                    break
            else:
                if PY2:
                    captions = self.captions.keys()
                else:
                    captions = self.captions
                for caption in captions:
                    if match_captions(caption, chat_caption):
                        puid = self.captions[caption]
                        break

            if puid:
                new_caption = merge_captions(self.captions.get_key(puid), chat_caption)
            else:
                puid = chat.user_name[-8:]
                new_caption = get_caption(chat)

            for i in range(3):
                chat_attr = chat_attrs[i]
                if chat_attr:
                    self.attr_dicts[i][chat_attr] = puid

            self.captions[new_caption] = puid

            return puid
获取指定聊天对象的 puid

:param chat: 指定的聊天对象
:return: puid
:rtype: str
wxpy/utils/puid_map.py