wechaty / wechaty

Conversational RPA SDK for Chatbot Makers. Join our Discord: https://discord.gg/7q8NBZbQzt
https://wechaty.js.org
Apache License 2.0
20.11k stars 2.59k forks source link

Unable to receive messages from official accounts #1906

Closed quantumFlame closed 10 months ago

quantumFlame commented 4 years ago

Important:Please file the issue follow the template, or we won't help you to solve the problem.

0. Report Issue Guide

  1. Please run the following command and check whether the problem has been fixed:

    rm -rf package-lock.json
    rm -rf node_modules
    npm install

    No. Wechaty itself is running well.

  2. Please search in FAQ List first, and make sure your problem has not been solved before. No similar issues found.

  3. Please search in the issue first, and make sure your problem had not been reported before No similar issues found.

1. Versions

2. Describe the bug

Give a clear and concise description of what the bug is. Wechaty does not receive message from official accounts. Instead, it detects the message from itself when communicating with official accounts.

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.

Steps to reproduce the behavior:

  1. run a example script from wechaty starter repo to print every message received.
  2. use phone and the bot account to send a message 'hi' to an official account which can reply 'wo shi ting hao de' automatically.
  3. wechaty print the message from itself, 'hi', but not the message from the official account, 'wo shi ting hao de'. The problem does not happen when communicating with personal accounts.

4. Expected behavior

Give a clear and concise description of what you expected to happen. In step 3, wechaty should be activated by the message from the official account and print message 'wo shi ting hao de'.

5. Actual behavior

If applicable, add screenshots to help explain your problem. But do not paste log screenshots here. image The fromId 'wxid_ofaw2d...' is the robot itself. The toId 'gh_3015...' is the official account.

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 ```shell $ WECHATY_LOG=silly node yourbot.js Question: Paste your FULL(DO NOT ONLY PROVIDE FRAGMENTS) log messages Answer: 06:39:41 SILL Config WECHATY_LOG set level to silly 06:39:41 INFO Config registering process.on("unhandledRejection") for development/debug 06:39:41 VERB Config constructor() 06:39:43 VERB Puppet constructor({"token":"puppet_padplus_3f688727dcb631f7"}) #0 06:39:43 VERB StateSwitch constructor(name=PuppetPadplus) 06:39:43 VERB MemoryCard constructor(undefined) 06:39:43 VERB MemoryCard getStorage() for storage type: N/A 06:39:43 VERB MemoryCard load() from storage: N/A 06:39:43 VERB MemoryCard load() no storage 06:39:43 VERB Puppet constructor() watchdog timeout set to 60 seconds 06:39:43 VERB HotImport callerResolve(., /home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty-puppet/dist/src/puppet.js) 06:39:43 SILL HotImport callerResolve() callsites() file=/home/tanjin/MetaPuppetForPython/socket_client/node_modules/hot-import/dist/src/hot-import.js, type=Object 06:39:43 SILL HotImport callerResolve() callsites() file=/home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty-puppet/dist/src/puppet.js, type=null 06:39:43 SILL HotImport callerResolve() callsites() file=/home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js, type=null 06:39:43 SILL HotImport callerResolve() callerFile=/home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty-puppet-padplus/dist/src/puppet-padplus.js 06:39:43 VERB Puppet constructor() childClassPath=/home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty-puppet-padplus/dist/src 06:39:43 VERB PadplusManager constructor() 06:39:43 SILL PadplusManager : StateSwitch { _name: 'PadplusManager', log: { silly: [Function: silly], verbose: [Function: verbose], warn: [Function: warn], error: [Function: error] }, _on: false, _pending: false, offPromise: Promise { undefined }, onResolver: [Function], onPromise: Promise { }, offResolver: [Function: nop] } 06:39:43 SILL Accessory #0 constructor() 06:39:43 VERB Wechaty contructor() 06:39:43 VERB StateSwitch constructor(name=Wechaty) 06:39:43 VERB StateSwitch constructor(name=WechatyReady) 06:39:43 VERB Wechaty on(scan, function) registered 06:39:43 VERB Wechaty addListenerFunction(scan) 06:39:43 VERB Wechaty on(message, function) registered 06:39:43 VERB Wechaty addListenerFunction(message) 06:39:43 SILL Wechaty version() form development environment is not availble: ENOENT: no such file or directory, stat '/home/tanjin/MetaPuppetForPython/socket_client/node_modules/wechaty/dist/.git' 06:39:43 INFO Wechaty ()>(bot-padplus) start() v0.29.42 is starting... 06:39:43 VERB Wechaty puppet: Puppet#0() 06:39:43 VERB Wechaty name: bot-padplus 06:39:43 VERB Wechaty id: ck68xzdp900006gqd928w2kge 06:39:43 SILL StateSwitch on() is false 06:39:43 SILL StateSwitch off() is true 06:39:43 VERB StateSwitch off(true) <- (true) 06:39:43 SILL StateSwitch on() is false 06:39:43 VERB StateSwitch on(pending) <- (false) 06:39:43 VERB MemoryCard constructor("bot-padplus") 06:39:43 VERB MemoryCard getStorage() for storage type: N/A 06:39:43 VERB getStorage name: bot-padplus, options: {"type":"file"} 06:39:43 VERB StorageFile constructor(bot-padplus, ...) 06:39:43 VERB StorageBackend constructor(bot-padplus, { type: file }) 06:39:43 VERB MemoryCard load() from storage: StorageFile 06:39:43 VERB StorageFile load() from /home/tanjin/MetaPuppetForPython/socket_client/bot-padplus.memory-card.json 06:39:43 VERB Puppet constructor() memory.load() done 06:39:43 VERB Wechaty initPuppet() Puppet#0() 06:39:43 VERB MemoryCard multiplex(puppet) 06:39:43 VERB MemoryCard static multiplex(MemoryCard, puppet) 06:39:43 VERB MemoryCard constructor({"name":"bot-padplus","multiplex":{"name":"puppet","parent":{"options":{"name":"bot-padplus"},"name":"bot-padplus","payload":{"\rpuppet\nWECHATY_PUPPET_PADPLUS":{"qrcodeId":"","uin":"2742282658","userName":"wxid_ofaw2dtumw5922"}},"multiplexNameList":[],"storage":{"name":"bot-padplus","options":{"type":"file"},"absFileName":"/home/tanjin/MetaPuppetForPython/socket_client/bot-padplus.memory-card.json"}}}}) 06:39:43 VERB PuppetManager resolve({puppet: Puppet#0(), puppetOptions: undefined}) 06:39:43 VERB PuppetManager resolveInstance(Puppet#0()) 06:39:43 VERB Puppet setMemory() 06:39:43 VERB Wechaty initPuppetEventBridge(Puppet#0(bot-padplus)) 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(login) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(logout) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(message) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(scan) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(dong) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(error) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(ready) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(reset) registered 06:39:43 VERB Wechaty initPuppetEventBridge() puppet.on(watchdog) registered 06:39:43 VERB Wechaty initAccessory(Puppet#0(bot-padplus)) 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set wechaty = "Wechaty#ck68xzdp900006gqd928w2kge(bot-padplus)>(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory static set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL Accessory set puppet = "Puppet#0(bot-padplus)" 06:39:43 SILL PuppetPadplus start() 06:39:43 SILL StateSwitch on() is false 06:39:43 VERB StateSwitch on(pending) <- (false) 06:39:43 VERB PadplusManager on(scan, function) registered 06:39:43 VERB PadplusManager on(login, function) registered 06:39:43 VERB PadplusManager on(message, function) registered 06:39:43 VERB PadplusManager on(ready, function) registered 06:39:43 VERB PadplusManager on(reset, function) registered 06:39:43 VERB PadplusManager on(heartbeat, function) registered 06:39:43 VERB PadplusManager on(logout, function) registered 06:39:43 VERB PadplusManager on(error, function) registered 06:39:43 SILL PadplusManager start() 06:39:43 SILL GRPC_GATEWAY initGrpcGateway() 06:39:44 VERB MemoryCard get(WECHATY_PUPPET_PADPLUS) 06:39:44 SILL PadplusManager uin : 2742282658 06:39:45 SILL PadplusUser initInstance() 06:39:45 SILL RequestClient request() 06:39:45 SILL DedupeApi dedupe() no need to dedupe api 3. 06:39:45 SILL GRPC_GATEWAY GRPC Request ApiType: 3 06:39:54 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== 06:39:54 SILL GRPC_GATEWAY responseType: 15, data : {"uin":2742282658,"online":true,"wechatUser":{"headImgUrl":"http://wx.qlogo.cn/mmhead/A7sq8BD8oexU2gnlXMk6hxXic8hjLvEoem2KShESgkGNiaVpIttIERqg/0","nickName":"本宝宝","uin":2742282658,"userName":"wxid_ofaw2dtumw5922","alias":"DuPhDYongZheGe","verifyFlag":0}} 06:39:54 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== 06:39:54 SILL GRPC_GATEWAY throttleQueue emit heartbeat. 06:39:54 SILL PadplusManager setContactAndRoomData() 06:39:54 VERB PadplusManager setContactAndRoomData() can not proceed due to no cache. 06:39:54 SILL PadplusManager user name : { uin: 2742282658, online: true, wechatUser: { headImgUrl: 'http://wx.qlogo.cn/mmhead/A7sq8BD8oexU2gnlXMk6hxXic8hjLvEoem2KShESgkGNiaVpIttIERqg/0', nickName: '本宝宝', uin: 2742282658, userName: 'wxid_ofaw2dtumw5922', alias: 'DuPhDYongZheGe', verifyFlag: 0 } } 06:39:54 VERB PadplusManager init cache manager 06:39:54 VERB CacheManager init() 06:39:54 VERB CacheManager initCache(wxid_ofaw2dtumw5922) 06:39:54 VERB CacheManager initCache() inited [object Promise] Contacts, cachedir="/home/tanjin/.wechaty/puppet-padplus-cache/flash-store-v0.14/wxid_ofaw2dtumw5922" 06:39:55 SILL PuppetPadplus login success : { headImgUrl: 'http://wx.qlogo.cn/mmhead/A7sq8BD8oexU2gnlXMk6hxXic8hjLvEoem2KShESgkGNiaVpIttIERqg/0', nickName: '本宝宝', uin: 2742282658, userName: 'wxid_ofaw2dtumw5922', alias: 'DuPhDYongZheGe', verifyFlag: 0 } 06:39:55 VERB Puppet login(wxid_ofaw2dtumw5922) 06:39:55 VERB Contact load(wxid_ofaw2dtumw5922) init pool 06:39:55 SILL Accessory #1 constructor() 06:39:55 SILL Contact constructor(wxid_ofaw2dtumw5922) 06:39:55 SILL Contact ready() @ Puppet#0(bot-padplus) 06:39:55 SILL Puppet contactPayload(wxid_ofaw2dtumw5922) cache MISS 06:39:55 SILL PadplusManager contactSelfInfo() 06:39:55 VERB PadplusContact getContactSelfInfo() 06:39:55 SILL RequestClient request() 06:39:55 SILL DedupeApi dedupe() no need to dedupe api 17. 06:39:55 SILL GRPC_GATEWAY GRPC Request ApiType: 17 06:39:55 SILL PadplusManager sync all contacts 06:39:55 VERB PadplusContact syncContacts() 06:39:55 SILL RequestClient request() 06:39:55 SILL DedupeApi dedupe() no need to dedupe api 14. 06:39:55 SILL GRPC_GATEWAY GRPC Request ApiType: 14 06:39:55 VERB PuppetPadplus contactRawPayloadParser() 06:39:55 SILL Puppet contactPayload(wxid_ofaw2dtumw5922) cache SET 06:39:55 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== 06:39:55 SILL GRPC_GATEWAY responseType: 30, data : {"Status":3,"CreateTime":1580884791393,"NewMsgId":4074086865811218931,"msgSourceCd":2,"ToUserName":"gh_30153216d602","MsgType":1,"L1MsgType":5,"ImgStatus":1,"wechatUserName":"wxid_ofaw2dtumw5922","MsgId":"4074086865811218931","MsgSource":"","PushContent":"","ImgBuf":"","Content":"hi","FromUserName":"wxid_ofaw2dtumw5922","Uin":"2742282658"} 06:39:55 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== 06:39:55 VERB PuppetPadplus onPadplusMessageFriendshipEvent({id=4074086865811218931}) 06:39:55 VERB Message static load(4074086865811218931) 06:39:55 SILL Accessory #2 constructor() 06:39:55 VERB Message constructor(4074086865811218931) for class Message 06:39:55 VERB Message ready() 06:39:55 VERB Puppet messagePayload(4074086865811218931) 06:39:55 SILL Puppet messagePayloadCache(4074086865811218931) cache MISS 06:39:55 VERB PuppetPadplus messageRawPayload(4074086865811218931) 06:39:55 VERB PuppetPadplus messageRawPayloadParser() 06:39:55 SILL messageRawPayloadParser messageType 7 06:39:55 SILL Puppet messagePayload(4074086865811218931) cache SET 06:39:55 VERB Contact load(wxid_ofaw2dtumw5922) init pool 06:39:55 SILL Accessory #3 constructor() 06:39:55 SILL Contact constructor(wxid_ofaw2dtumw5922) 06:39:55 SILL Contact ready() @ Puppet#0(bot-padplus) 06:39:55 SILL Accessory #4 constructor() 06:39:55 SILL Contact constructor(gh_30153216d602) 06:39:55 SILL Contact ready() @ Puppet#0(bot-padplus) 06:39:55 SILL Puppet contactPayload(gh_30153216d602) cache MISS 06:39:55 VERB PuppetPadplus contactRawPayloadParser() 06:39:55 SILL Puppet contactPayload(gh_30153216d602) cache SET process_wx_message object Message { _events: [Object: null prototype] {}, _eventsCount: 0, _maxListeners: undefined, id: '4074086865811218931', payload: { id: '4074086865811218931', timestamp: 1580884791.393, type: 7, fromId: 'wxid_ofaw2dtumw5922', mentionIdList: undefined, roomId: undefined, text: 'hi', toId: 'gh_30153216d602' }, [Symbol(name)]: 'Message', [Symbol(counter)]: 2 } 06:39:56 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== 06:39:56 SILL GRPC_GATEWAY responseType: 17, data : {"status":0,"message":"","loginer":"puppet_padplus_3f688727dcb631f7","uin":"2742282658","userName":"wxid_ofaw2dtumw5922","queueName":"queue.getContactSelfInfo.prod","bindEmail":"","country":"CN","smallHeadImg":"http://wx.qlogo.cn/mmhead/A7sq8BD8oexU2gnlXMk6hxXic8hjLvEoem2KShESgkGNiaVpIttIERqg/132","bigHeadImg":"http://wx.qlogo.cn/mmhead/A7sq8BD8oexU2gnlXMk6hxXic8hjLvEoem2KShESgkGNiaVpIttIERqg/0","city":"Haidian","signature":"Discovering the world!","nickName":"本宝宝","sex":1,"bindQQ":0,"bindMobile":"+17345319728","snsBGImg":"","province":"Beijing","bytes":"CL4BEhUKE3d4aWRfb2ZhdzJkdHVtdzU5MjIaCwoJ5pys5a6d5a6dIAAqADIOCgwrMTczNDUzMTk3Mjg4paCeEEAAUAFaB0JlaWppbmdiB0hhaWRpYW5qFkRpc2NvdmVyaW5nIHRoZSB3b3JsZCFwAXoQCAASBAgAEAAYACIECAAQAIAB8bGJAYgBAJgBAqABzgKoAQKwAckBuAH0A8gBgMAC0gECCADaAQ5EdVBoRFlvbmdaaGVHZegBAPABAPgBAIgCAJACAKACALICAkNO","alias":"DuPhDYongZheGe"} 06:39:56 SILL ==P==A==D==P==L==U==S====P==A==D==P==L==U==S== ```

7. Additional context

Add any other context about the problem here. I suspect that in current code there is a logic that in the communication official accounts are always robots, thus only being activated by messages from the other side. However, this assumption is not always true. The other side could be robots, too.

[bug]

dosubot[bot] commented 10 months ago

Hi, @quantumFlame! I'm Dosu, and I'm helping the wechaty team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you reported an issue where Wechaty is not receiving messages from official accounts. Currently, there haven't been any updates or comments on this issue.

Before we close this issue, we wanted to check with you if it is still relevant to the latest version of the wechaty repository. If it is, please let us know by commenting on the issue. Otherwise, feel free to close the issue yourself, or it will be automatically closed in 7 days.

Thank you for your understanding and contribution to the wechaty community!