wechaty / puppet-padlocal

Puppet PadLocal is a Pad Protocol for WeChat
https://wechaty.js.org/docs/puppet-providers/padlocal
Apache License 2.0
642 stars 88 forks source link

docker中运行ready之后立即调bot.Contact.findAll() 获取不到完整的联系人列表 #106

Closed atorber closed 3 years ago

atorber commented 3 years ago

在docker中运行ready之后立即调bot.Contact.findAll() 获取不到完整的联系人列表,只能拿到当前登陆账号自己的信息

    .on("ready", async () => {
            let contactList = await bot.Contact.findAll()
            console.debug(contactList)
        })
vinceyyy commented 2 years ago

@atorber 想请问一下这个问题你解决了吗?我也遇到了很类似的问题。

atorber commented 2 years ago

需要padlocal在服务端操作一下,只有第一次登录可以算量获得联系人,之后登录是增量,频繁bot.Contact.findAll()可能出发微信风控,不建议每次ready都全量请求,需要本地或数据库缓存 之前咨询了官方的总结

vinceyyy commented 2 years ago

需要padlocal在服务端操作一下,只有第一次登录可以算量获得联系人,之后登录是增量,频繁bot.Contact.findAll()可能出发微信风控,不建议每次ready都全量请求,需要本地或数据库缓存 之前咨询了官方的总结

@atorber 谢谢回答。是需要联系padlocal的客服来操作吗? 我遇到的情况是直接node运行代码没有任何问题,build成docker镜像就会获取不到好友列表,在所有的机器上都是一样的问题。不知道padlocal是怎么判断第一次登陆和之后登陆的。

vinceyyy commented 2 years ago

经过作者回复已经解决了问题🙏

解决方法是在调用Wechaty.Contact.findAll()之前先调用wechaty-puppet-padlocal.syncContact(),等同步结束后就可以正常获取联系人了

huan commented 2 years ago

It seems that the ready event should not emit until the syncContact() has been returned.

atorber commented 2 years ago

wechaty-puppet-padlocal.syncContact()

@huan I wonder if we can automatically call wechaty-puppet-padlocal.syncContact() in onScan event when it is called in puppet-padlocal?

huan commented 2 years ago

Wechaty should not know anything from the PadLocal except the Puppet Interface.

This logic should belong to the PadLocal and deal I side it.

atorber commented 2 years ago

Yes, I mean to implement the above operations in the onScan event of puppet-padlocal, @padlocal do you think this is reasonable?