Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]WorkPro: 通过ID load Contact获取不到用户 #167

Closed
Hamlet626 opened this issue Jan 18, 2023 · 5 comments
Closed

[BUG]WorkPro: 通过ID load Contact获取不到用户 #167

Hamlet626 opened this issue Jan 18, 2023 · 5 comments
Assignees
Labels
workpro Wechaty Puppet Service WorkPro

Comments

@Hamlet626
Copy link

Please make sure you have read the Wechaty Puppet Service: WorkPro from Wechaty Official Website before you continue writing this issue.

IMPORTANT

DO NOT post your token in the issue. If we need to investigate the behavior of certain token, we will provide a private contact route.

Describe the bug
通过bot.Contact.load("contact ID") 无法获取contact,返回应该是一个空的Contact,造成后面Contact.say()报错

Info

bot.Contact.load()返回Print出来如下:

WechatifiedContactImpl {
  _events: [Object: null prototype] {},
  _eventsCount: 0,
  _maxListeners: undefined,
  id: undefined,
  payload: undefined,
  [Symbol(kCapture)]: false
}

用的Dependency如下:
"wechaty": "^1.19.10",
"wechaty-plugin-contrib": "^0.14.23",
"wechaty-puppet": "^1.19.6",
"wechaty-puppet-service": "^1.18.2"

code 如下:

let ctc=bot.Contact.load(cid);
console.log(ctc);
//后面ctc.say就会出错了,说
//ERR Config Wechaty unhandledRejection: Error: 13 INTERNAL: Cannot read properties of null (reading 'isFriend')

To Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

通过名字可以找到Contact,但同名时就不好区分。
好像wechaty其他种service也会用ID找到 undefined 的Contact,我不是很确定,不过 [https://wechaty.js.org/docs/api/contact]上还有用Contact.load这样用ID找Contact,所以不知道现在还能这样吗,还是我用错了。
希望能说明解决,谢谢帮助!

@Hamlet626 Hamlet626 added the workpro Wechaty Puppet Service WorkPro label Jan 18, 2023
@hcfw007
Copy link
Member

hcfw007 commented Jan 19, 2023

你好,wechaty 1.x 中的 load 方法已经不对 bot 暴露了,根据 id 查联系人应该使用 bot.Contact.find({ id })

@huan
Copy link
Member

huan commented Jan 19, 2023

A pull request to fix the documentation will be appreciated.

@Hamlet626
Copy link
Author

用 bot.Contact.find({id}) 没问题,然后之前我程序中本身有个小bug,不过现在可以获取contact了。谢谢帮助解决!

@hcfw007
Copy link
Member

hcfw007 commented Jan 20, 2023

你好,wechaty 1.x 中的 load 方法已经不对 bot 暴露了,根据 id 查联系人应该使用 bot.Contact.find({ id })

谢谢告知!然后可以问下Room load也不用了是吗,然后用bot.Room.find({ id }) ?谢了

是的,也是一样的。

@hcfw007
Copy link
Member

hcfw007 commented Jan 30, 2023

wechaty/docusaurus#1512

I'm working on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workpro Wechaty Puppet Service WorkPro
Projects
None yet
Development

No branches or pull requests

4 participants