bot.Friendship.search 判断结果是否已经是好友
Created by: dchaofei
Important:Please file the issue follow the template, or we won't be able to help you to solve the problem.
0. Report Issue Guide
-
Please run the following command and check whether the problem has been fixed:
rm -rf package-lock.json rm -rf node_modules npm install
-
Please search in FAQ List first, and make sure your problem has not been solved before.
-
Please search in the issue first, and make sure your problem had not been reported before
1. Versions
What is your wechaty version?
Answer: 0.48.3
Which puppet are you using for wechaty? (hostie/puppeteer/padchat/...)
Answer: hostie
What is your wechaty-puppet-XXX(padchat/puppeteer/) version?
Answer: 0.10.1
What is your node version? (run
node --version
)
Answer: v12.16.1
What os are you using
Answer: mac
2. Describe the bug
Friendship.search() 返回的联系人不能用 friend() 判断是否是朋友.
3. To Reproduce
This part is very important: if you can not provide any reproduce steps, then the problem will be very hard to be recognized.
How to create a Minimal, Reproducible Example
如下代码:
const a = await bot.Friendship.search({weixin: "xxx"})
if (!a) {
return
}
if (!a.friend()) {
await bot.Friendship.add(a, "hi")
console.log("已经发送好友请求.")
} else {
console.log("已经是您的好友.")
}
4. Expected behavior
预期第一次执行程序会输出:
已经发送好友请求.
预期同意好友请求后,每次执行都输出:已经是您的好友.
5. Actual behavior
真实的结果,每次都会输出
已经发送好友请求.
6. Full Output Logs
Set env
WECHATY_LOG=silly
in order to set log level to silly, then we can get the full log (If you dosen't set log env, log level is info as default, we cannot get the full log)
We need full log instead of log screenshot or log fragments!
Show Logs
17:54:21 VERB Friendship static search("{"weixin":"xxx"}")
17:54:21 VERB Puppet friendshipSearch("{"weixin":"xxx"}")
17:54:21 VERB PuppetHostie friendshipSearchWeixin(xxx)
17:54:21 VERB Contact load(xxx) init pool
17:54:21 SILL Contact constructor(dingchaofei123)
17:54:21 SILL Contact ready() @ Puppet#0<PuppetHostie>(ding-dong-bot) with id="xxx"
17:54:21 SILL Puppet contactPayload(xxx) cache MISS
17:54:21 VERB PuppetHostie contactRawPayload(xxx)
17:54:21 SILL Puppet contactPayload(xxx) cache SET
17:54:21 VERB Contact friend()
17:54:21 VERB Friendship static add(xxx, hi)
17:54:21 VERB PuppetHostie friendshipAdd(xxx, hi)
已经发送好友请求.
7. Additional context
是不是 hostie 服务端存了一份缓存?当好友同意申请时也没有清除?