wechaty / python-wechaty-puppet

Python Puppet Provider Abstraction for Wechaty
https://pypi.org/project/wechaty-puppet/
Apache License 2.0
12 stars 11 forks source link

之前能够获取新好友的微信号,现在经常出现userstate异常获取不到。 #44

Closed Hyfred closed 2 years ago

Hyfred commented 2 years ago

同样的代码几个月前能够在被加好友时,在申请通过后获取该好友的微信号,现在经常出现userstate异常获取不到。偶尔可以获取到,不知道是否为版本原因。

这是我的源代码: async def on_friendship(self, friendship: Friendship) -> None: """when receive a new friendship application, or accept a new friendship Args: friendship (Friendship): contains the status and friendship info, eg: hello text, friend contact object """ MAX_ROOM_MEMBER_COUNT = 500

1. receive a new friendship from someone

    if friendship.type() == FriendshipType.FRIENDSHIP_TYPE_RECEIVE:
        hello_text: str = friendship.hello()
        # friend: Contact = friendship.contact()
        # await friend.ready()
        # fri_name = friend.name

        # accept friendship when there is a keyword in hello text
        # if 'wechaty' in hello_text.lower():
        await friendship.accept()

    # 2. you have a new friend to your contact list
    elif friendship.type() == FriendshipType.FRIENDSHIP_TYPE_CONFIRM:
        # 2.1 invite the user to wechaty group
        # find the topic of room which contains Wechaty keyword
        friend: Contact = friendship.contact()
        await friend.ready()
        fri_wxid = friend.weixin() #get wxid
        fri_contact_id = friend.contact_id
        print(fri_wxid)

这是报错: image 2022-06-21 19:33:56,246 - Wechaty - INFO - receive event <EventFriendshipPayload(friendship_id='5913457775617322356')> 2022-06-21 19:33:56,246 - FriendShip - INFO - Friendship constructor 5913457775617322356 2022-06-21 19:33:56,246 - FriendShip - INFO - ready() sync the friendship payload 2022-06-21 19:33:56,297 - FriendShip - INFO - get hello message <申请> of friendship <<wechaty_grpc.wechaty.puppet.FriendshipPayloadResponse object at 0x7fc8528f7460>> 2022-06-21 19:33:56,297 - FriendShip - INFO - get hello message <申请> of friendship <<wechaty_grpc.wechaty.puppet.FriendshipPayloadResponse object at 0x7fc8528f7460>> 2022-06-21 19:33:56,297 - FriendShip - INFO - accept friendship, friendship_id: <5913457775617322356> 2022-06-21 19:33:56,297 - FriendShip - INFO - friendship accept to wxid_20qh1k68nuon 2022-06-21 19:33:57,344 - Wechaty - INFO - receive event <EventFriendshipPayload(friendship_id='4943574653437041188')> 2022-06-21 19:33:57,345 - FriendShip - INFO - Friendship constructor 4943574653437041188 2022-06-21 19:33:57,345 - FriendShip - INFO - ready() sync the friendship payload 2022-06-21 19:33:57,394 - FriendShip - INFO - get hello message <> of friendship <<wechaty_grpc.wechaty.puppet.FriendshipPayloadResponse object at 0x7fc8528f7880>> 2022-06-21 19:33:57,441 - Contact - INFO - load contact <Contact >

2022-06-21 19:33:59,702 - Wechaty - ERROR - internal error <'userStatus'> 2022-06-21 19:33:59,751 - Wechaty - INFO - receive message <Message#message_type_text[🗣 Contact 申请> already get wechat id: already get contact_id id:wxid_20qh1k68nuon 2022-06-21 19:33:59,751 - Wechaty - INFO - receive message <Message#message_type_unspecified[🗣 Contact > already get wechat id: already get contact_id id:wxid_20qh1k68nuon

这是我版本: wechaty 0.8.35 wechaty-grpc 0.20.19 wechaty-puppet 0.4.19 wechaty-puppet-service 0.8.8

wj-Mcat commented 2 years ago

why do you close this issue ? have this problem been fixed ? if it is, can you share your solution for us ?