wechaty / getting-started

A Starter Project Template for Wechaty works out-of-the-box
https://gitpod.io/#https://github.com/wechaty/wechaty-getting-started
Apache License 2.0
772 stars 342 forks source link

Contact FindAll() API does not work. #299

Open wenzai007 opened 9 months ago

wenzai007 commented 9 months ago

const contactList = await bot.Contact.findAll()

while I am using this API in the demo code, I found it throws below exception. Is it that you did not implement the FindAll() API for PuppetWechat4u? Or it has some bug here? It worked well for pad local protocol as I remembered previously.

"uncaughtException GError [TypeError]: this.wechat4u.contacts.filter is not a function"

23:00:47 VERB PuppetContactMixin contactSearch(query={"name":"Peter"}, ) 23:00:47 VERB PuppetWechat4u contactList() 23:00:47 SILL PuppetLoginMixin get currentUserId() 23:00:47 SILL PuppetLoginMixin get currentUserId() 23:00:47 INFO the type of the from person is 1 23:00:47 SILL Contact find({"name":"Peter"}) 23:00:47 VERB Contact findAll({"name":"Peter"}) 23:00:47 VERB PuppetContactMixin contactSearch(query={"name":"Peter"}, ) 23:00:47 VERB PuppetWechat4u contactList() 23:00:47 SILL PuppetLoginMixin get currentUserId() uncaughtException GError [TypeError]: this.wechat4u.contacts.filter is not a function at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8) at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35) at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65) at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36) at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43) at WechatyImpl.emit (node:events:527:28) at WechatyImpl.emit (node:domain:475:12) at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22) at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22) at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 2, details: 'TypeError: this.wechat4u.contacts.filter is not a function\n' + ' at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8)\n' + ' at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35)\n' + ' at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65)\n' + ' at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36)\n' + ' at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43)\n' + ' at WechatyImpl.emit (node:events:527:28)\n' + ' at WechatyImpl.emit (node:domain:475:12)\n' + ' at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22)\n' + ' at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22)\n' + ' at processTicksAndRejections (node:internal/process/task_queues:96:5)' } uncaughtException GError [TypeError]: this.wechat4u.contacts.filter is not a function at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8) at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35) at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65) at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36) at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43) at WechatyImpl.emit (node:events:527:28) at WechatyImpl.emit (node:domain:475:12) at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22) at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22) at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 2, details: 'TypeError: this.wechat4u.contacts.filter is not a function\n' + ' at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8)\n' + ' at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35)\n' + ' at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65)\n' + ' at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36)\n' + ' at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43)\n' + ' at WechatyImpl.emit (node:events:527:28)\n' + ' at WechatyImpl.emit (node:domain:475:12)\n' + ' at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22)\n' + ' at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22)\n' + ' at processTicksAndRejections (node:internal/process/task_queues:96:5)' } uncaughtException GError [TypeError]: this.wechat4u.contacts.filter is not a function at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8) at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35) at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65) at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36) at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43) at WechatyImpl.emit (node:events:527:28) at WechatyImpl.emit (node:domain:475:12) at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22) at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22) at processTicksAndRejections (node:internal/process/task_queues:96:5) { code: 2, details: 'TypeError: this.wechat4u.contacts.filter is not a function\n' + ' at PuppetWechat4u.contactList (file:///rootfolder/getting-started/node_modules/wechaty-puppet-wechat4u/src/puppet-wechat4u.ts:411:8)\n' + ' at PuppetWechat4u.contactSearch (file:///rootfolder/getting-started/node_modules/wechaty-puppet/src/mixins/contact-mixin.ts:115:35)\n' + ' at Function.findAll (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:176:65)\n' + ' at Function.find (file:///rootfolder/getting-started/node_modules/wechaty/src/user-modules/contact.ts:123:36)\n' + ' at WechatyImpl.onMessage (file:///rootfolder/getting-started/examples/ding-dong-bot.ts:95:43)\n' + ' at WechatyImpl.emit (node:events:527:28)\n' + ' at WechatyImpl.emit (node:domain:475:12)\n' + ' at WechatyImpl.emit (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/gerror-mixin.ts:44:22)\n' + ' at PuppetWechat4u. (file:///rootfolder/getting-started/node_modules/wechaty/src/wechaty-mixins/puppet-mixin.ts:281:22)\n' + ' at processTicksAndRejections (node:internal/process/task_queues:96:5)' } 23:00:47 SILL PuppetWechat4u initHookEvents() wechat4u.on(contacts-updated) new/total contacts.length=101/105 23:00:49 SILL PuppetWechat4u initHookEvents() wechat4u.on(contacts-updated) new/total contacts.length=43/107 23:00:49 SILL PuppetWechat4u initHookEvents() wechat4u.on(contacts-updated) new/total contacts.length=43/107 23:00:49 SILL PuppetWechat4u initHookEvents() wechat4u.on(contacts-updated) new/total contacts.length=43/107 23:00:49 SILL PuppetWechat4u initHookEvents() wechat4u.on(contacts-updated) new/total contacts.length=43/107