bot.Friendship.add() 总是报错
Created by: yiouyou
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.47.24 or 0.48.10
Which puppet are you using for wechaty? (hostie/puppeteer/padchat/...)
Answer: wechaty-puppet-padplus
What is your wechaty-puppet-XXX(padchat/puppeteer/) version?
Answer: 0.7.40 or 0.6.6
What is your node version? (run
node --version
)
Answer: v12.18.1
What os are you using
Answer: ubuntu 18.04 (wsl2) linux in windows
2. Describe the bug
Give a clear and concise description of what the bug is.
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
Steps to reproduce the behavior:
- run 'node app.js'
- app.js 里的 onRoomJoin function:
async function onRoomJoin (room, inviteeList, inviter) {
const topic = await room.topic()
const config = await hotImport('./config.js')
for (let i=0; i<inviteeList.length; i++) {
let i_invitee = inviteeList[i]
log.info('Bot', `onRoomJoin: [${topic}] got new member <${i_invitee.id}(${i_invitee.name()})>, invited by <${inviter.id}(${inviter.name()})>`)
room.say(`欢迎加入'${topic}' 👫`, i_invitee)
log.info('Bot', `onRoomJoin: adding (${i_invitee.name()}) as friend from room [${topic}]`)
if (i_invitee.friend()) {
log.info('Bot', `onRoomJoin: <${i_invitee.id}(${i_invitee.name()})> joined [${topic}], is a friend already`)
} else {
let bot_name = bot.userSelf().payload.name
let i_hello = `嗨,我是群助手${bot_name},查询课表地址请加我`
console.log(i_invitee)
await bot.Friendship.add(i_invitee, i_hello)
log.info('Bot', `onRoomJoin: ask <${i_invitee.id}(${i_invitee.name()})> for friendship with hello '${i_hello}'`)
}
}
}
- 每次运行 await bot.Friendship.add(i_invitee, i_hello) 都报错
4. Expected behavior
当群里添加新成员时,bot自动加新成员为好友
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
$ WECHATY_LOG=silly node app.js
15:59:15 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
15:59:15 SILL GRPC_GATEWAY responseType: CONTACT_SEARCH, data : {"avatar":"","v1":"","v2":"","searchId":"wxid_julj9sttk3e122","nickName":"","wxid":"","message":"\u003ce\u003e\n\u003cShowType\u003e1\u003c/ShowType\u003e\n\u003cContent\u003e\u003c![CDATA[No related account or content found.]]\u003e\u003c/Content\u003e\n\u003cUrl\u003e\u003c![CDATA[]]\u003e\u003c/Url\u003e\n\u003cDispSec\u003e30\u003c/DispSec\u003e\n\u003cTitle\u003e\u003c![CDATA[]]\u003e\u003c/Title\u003e\n\u003cAction\u003e2\u003c/Action\u003e\n\u003cDelayConnSec\u003e0\u003c/DelayConnSec\u003e\n\u003cCountdown\u003e0\u003c/Countdown\u003e\n\u003cOk\u003e\u003c![CDATA[]]\u003e\u003c/Ok\u003e\n\u003cCancel\u003e\u003c![CDATA[]]\u003e\u003c/Cancel\u003e\n\u003c/e\u003e\n","status":"-24"}
15:59:15 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
15:59:15 ERR Config ###########################
15:59:15 ERR Config unhandledRejection: Error: Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
at PadplusManager.<anonymous> (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.7.40@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:1042:27)
at Generator.next (<anonymous>)
at fulfilled (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.7.40@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5) [object Promise]
15:59:15 ERR Config ###########################
15:59:15 ERR Config process.on(unhandledRejection) promise.catch(Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
)
Config Error: Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
at PadplusManager.<anonymous> (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.7.40@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:1042:27)
at Generator.next (<anonymous>)
at fulfilled (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.7.40@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:5:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:7673) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 3)
15:59:15 VERB Puppet selfId()
15:59:15 VERB Message static load(1145832254916168049)
15:59:15 VERB Message constructor(1145832254916168049) for class WechatifiedMessage
15:59:15 VERB Message ready()
15:59:15 VERB Puppet messagePayload(1145832254916168049)
15:59:15 SILL Puppet messagePayloadCache(1145832254916168049) cache MISS
15:59:15 SILL PuppetPadplus messageRawPayload(1145832254916168049)
15:59:15 SILL PuppetPadplus messageRawPayloadParser()
15:59:15 SILL messageRawPayloadParser messageType 7
15:59:15 SILL Puppet messagePayload(1145832254916168049) cache SET
15:59:15 VERB Room ready()
15:59:15 SILL Contact ready() @ Puppet#0<PuppetPadplus>(wx-bot) with id="wxid_oay6kx3dtf1m22"
15:59:15 SILL Contact ready() isReady() true
15:59:18 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
15:59:18 SILL GRPC_GATEWAY responseType: ROOM_MEMBER_LIST, data : {"roomId":"18508510831@chatroom","membersJson":"[{\"InvitedBy\":\"qq26048067\",\"UserName\":\"wxid_oay6kx3dtf1m22\",\"HeadImgUrl\":\"http://wx.qlogo.cn/mmhead/ver_1/eAbCOc3agiaHo3FSdABHKJZ9Rf9MolcBsaZfmCtm7WfyW0EG0H1P1Xhuph0Vx3F8gFXP16er0MwbVMS4uZUAYtu99OR7PnSvjq6MXQQnPFTI/132\",\"DisplayName\":\"\",\"RemarkName\":\"\",\"Tag8\":0,\"MemberContactFlag\":1,\"NickName\":\"丁丁\"},{\"InvitedBy\":\"wxid_oay6kx3dtf1m22\",\"UserName\":\"qq26048067\",\"HeadImgUrl\":\"http://wx.qlogo.cn/mmhead/ver_1/2BSpwj9ZDoWJssxxZj0BjEfN2icxaaTh6CJLAqr1eXojiatZDGbLG3ZrZYGxCdHbRLpibj2JFCwSJ0wQ7srHvd3Vg/132\",\"DisplayName\":\"\",\"RemarkName\":\"\",\"Tag8\":0,\"MemberContactFlag\":0,\"NickName\":\"sz\"},{\"InvitedBy\":\"qq26048067\",\"UserName\":\"wxid_julj9sttk3e122\",\"HeadImgUrl\":\"https://wx.qlogo.cn/mmhead/ver_1/Bnd4CibAYFsl2Qy9NObjjg6TRulQnxnib0y76OG9juqJZzXvdmmqeCxy7eKRnJP7lvyoJxKdb431TorLjesUiaf3bTicXb2GJSeYAOtlMjjBh1s/132\",\"DisplayName\":\"\",\"RemarkName\":\"\",\"Tag8\":0,\"MemberContactFlag\":0,\"NickName\":\"ʏɪɪᴍ\"}]"}
15:59:18 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
7. Additional context
pacadge.json
"dependencies": {
"cheerio": "^1.0.0-rc.3",
"file-box": "^0.12.8",
"finis": "^0.4.4",
"hot-import": "^0.2.14",
"node-fetch": "^2.6.1",
"node-schedule": "^1.3.2",
"qrcode-terminal": "^0.12.0",
"superagent": "^6.1.0",
"urlencode": "^1.1.0",
"wechaty": "^0.47.24",
"wechaty-puppet-padplus": "^0.7.40"
}
测试了 padplus 0.6.6,wechaty 0.48.10 等多个版本都有这个问题。也测试了4个月前更早期的版本,也有问题,只是报错不一样,比如 wechaty 0.38.2, padplus 0.6.2,好像是 ![CDATA 问题,找不到 contact
17:01:37 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
17:01:37 SILL GRPC_GATEWAY responseType: CONTACT_SEARCH, data : {"avatar":"","v1":"","v2":"","searchId":"wxid_julj9sttk3e122","nickName":"","wxid":"","message":"\u003ce\u003e\n\u003cShowType\u003e1\u003c/ShowType\u003e\n\u003cContent\u003e\u003c![CDATA[No related account or content found.]]\u003e\u003c/Content\u003e\n\u003cUrl\u003e\u003c![CDATA[]]\u003e\u003c/Url\u003e\n\u003cDispSec\u003e30\u003c/DispSec\u003e\n\u003cTitle\u003e\u003c![CDATA[]]\u003e\u003c/Title\u003e\n\u003cAction\u003e2\u003c/Action\u003e\n\u003cDelayConnSec\u003e0\u003c/DelayConnSec\u003e\n\u003cCountdown\u003e0\u003c/Countdown\u003e\n\u003cOk\u003e\u003c![CDATA[]]\u003e\u003c/Ok\u003e\n\u003cCancel\u003e\u003c![CDATA[]]\u003e\u003c/Cancel\u003e\n\u003c/e\u003e\n","status":"-24"}
17:01:37 SILL ==P==A==D==P==L==U==S==<GRPC DATA>==P==A==D==P==L==U==S==
17:01:37 ERR Config ###########################
17:01:37 ERR Config unhandledRejection: Error: Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
at PadplusManager.<anonymous> (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.6.6@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:1042:27)
at Generator.next (<anonymous>)
at fulfilled (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.6.6@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:5:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5) [object Promise]
17:01:37 ERR Config ###########################
17:01:37 ERR Config process.on(unhandledRejection) promise.catch(Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
)
Config Error: Can not search contact by wxid_julj9sttk3e122, status: -24 reason: <e>
<ShowType>1</ShowType>
<Content><![CDATA[No related account or content found.]]></Content>
<Url><![CDATA[]]></Url>
<DispSec>30</DispSec>
<Title><![CDATA[]]></Title>
<Action>2</Action>
<DelayConnSec>0</DelayConnSec>
<Countdown>0</Countdown>
<Ok><![CDATA[]]></Ok>
<Cancel><![CDATA[]]></Cancel>
</e>
at PadplusManager.<anonymous> (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.6.6@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:1042:27)
at Generator.next (<anonymous>)
at fulfilled (/mnt/d/_PROJECT_wechaty/wxBot-jz/node_modules/_wechaty-puppet-padplus@0.6.6@wechaty-puppet-padplus/dist/src/padplus-manager/padplus-manager.js:5:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:7986) PromiseRejectionHandledWarning: Promise rejection was handled asynchronously (rejection id: 6)