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

加好友报错 #2565

Closed
Qyokizzzz opened this issue Jul 22, 2023 · 1 comment
Closed

加好友报错 #2565

Qyokizzzz opened this issue Jul 22, 2023 · 1 comment

Comments

@Qyokizzzz
Copy link

环境信息:
win10
node 18.12.1
wechaty 1.20.2
typescript 5.1.6
ts-node-dev 2.0.0

我的代码:

import { WechatyBuilder, Wechaty } from 'wechaty'

async function addFriend(bot: Wechaty, phone: string, hello: string) {
  const contact = await bot.Friendship.search({ phone })
  if (!contact) {
    console.log('User-%d is not exist', phone)
    return
  }
  await bot.Friendship.add(contact, { hello })
  console.log('Done')
}

const wechaty = WechatyBuilder.build()
wechaty
  .on('scan', (qrcode, status) => console.log(`Scan QR Code to login: ${status}\nhttps://wechaty.js.org/qrcode/${encodeURIComponent(qrcode)}`))
  .on('login', user => { 
    console.log(`User ${user} logged in`)
    setTimeout(() => {
      addFriend(wechaty, '18941659897', '你好')
    }, 5000)
  })
  .on('message', message => console.log(`Message: ${message}`))
wechaty.start()

扫码登录后,addFriend中的const contact = await bot.Friendship.search({ phone })报错

错误信息:
[ERROR] 16:13:51 Error: Wechaty Puppet Unsupported API Error. Learn More At https://github.com/wechaty/wechaty-puppet/wiki/Compatibility
uncaughtException Error: Wechaty Puppet Unsupported API Error. Learn More At https://github.com/wechaty/wechaty-puppet/wiki/Compatibility
at Object.throwUnsupportedError (D:\workspace\wechat-assistance\node_modules\wechaty-puppet\src\throw-unsupported-error.ts:4:9)
at PuppetWechat4u.friendshipSearchPhone (D:\workspace\wechat-assistance\node_modules\wechaty-puppet-wechat4u\src\puppet-wechat4u.ts:1027:19)
at PuppetWechat4u.friendshipSearch (D:\workspace\wechat-assistance\node_modules\wechaty-puppet\src\mixins\friendship-mixin.ts:69:21)
at Function.search (D:\workspace\wechat-assistance\node_modules\wechaty\src\user-modules\friendship.ts:103:49)
at addFriend (D:\workspace\wechat-assistance\bot.ts:4:40)
at Timeout._onTimeout (D:\workspace\wechat-assistance\bot.ts:20:7)
at listOnTimeout (node:internal/timers:564:17)
at processTimers (node:internal/timers:507:7)

麻烦大佬帮忙看一下

@zhihuifanqiechaodan
Copy link

错误很明显了,puppet不支持功能,更换其他支持的puppet

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

No branches or pull requests

2 participants