puppet-padchat-patch
TypeScript icon, indicating that this package has built-in type declarations

0.1.11 • Public • Published

puppet-padchat-patch

What's this for

This is a temporary solution for the current -106 issue which blocks new users to login with wechaty-puppet-padchat

Please notice:

  • You need to upgrade your wechaty-puppet-padcaht to v0.17.5 or later to use this patch

  • The second parameter is name(or called profile in the past), you need to change it to the one same as your bot

  • Currently you need to restart your application when the auth data get picked, so wechaty could pick up the auth data and use it to login to wechat. reset does not work for this case now, if you reset wechaty when the finish event emitted, you will still get -106 error.

  • With this sulotion, when the user haven't logged in with wechaty before, there could be 3 times qrcode scan, which is not a great experience, but this is just a temporary solution, we are still working on fixing the issue and make everything back to before. If this solution doesn't work for you, please wait paitiently, we will publish new fix later

How to use

Please take a look at /test/dev-test.ts file for a complete example.

/**
 * Hook the -106 failure status here, try to get auth data from separate server
 */
process.on('unhandledRejection', (error) => {
  const { message } = error
  if (message && message.indexOf('unknown status: -106') !== -1) {
    
    const wxid = (message as string).split(' ').slice(-1)[0]
    const padchatPatch = new PadchatPatch(token, name, wxid)
    padchatPatch
    .on('scan', (qrcode, status) => {
      // You need to let the user scan the qrcode again here
      generate(qrcode, { small: true })
 
      const qrcodeImageUrl = [
        'https://api.qrserver.com/v1/create-qr-code/?data=',
        encodeURIComponent(qrcode),
      ].join('')
      console.log(`[${status}${qrcodeImageUrl}\nScan QR Code above to log in: `)
    })
    .on('finish', async () => {
      // restart your application here
    })
    .start()
    return
  }
})

Package Sidebar

Install

npm i puppet-padchat-patch

Weekly Downloads

11

Version

0.1.11

License

Apache-2.0

Unpacked Size

30.8 kB

Total Files

21

Last publish

Collaborators

  • windmemory