chatrbot / wechaty-puppet-simplepad-demo

Demo for simplepad
Apache License 2.0
0 stars 0 forks source link

Use FileBox.toQRCode() for easy deal with QR Code #1

Closed huan closed 2 years ago

huan commented 3 years ago

Hi chatrbot,

Thanks for this great demo for Wechaty Puppet SimplePad!

I'd like to suggest that we should improve the QRCode part of the codes for the puppet because the puppet spec needs to use the QR Code value instead of the image to make the Wechaty user experience to be consist.

The FileBox has a great support for this case:

const fileBox = FileBox.fromBase64('BASE64XXX')
const qrCodeValue = await fileBox.toQRCode()
console.log(`QR Code decoded value is: "${qrCodeValue}"`)
// Output: QR Code decoded value is: "https://github.com"

See: https://github.com/huan/file-box#27-toqrcode-promisestring

So my suggestions are to change your puppet implementation and include the above code so that we can expect the Wechaty will be always emitting a QR Code value to the end user.

https://github.com/chatrbot/wechaty-puppet-simplepad-demo/blob/0df2a622bc6799f4d7509a0db7a6feabc09006c0/bot.ts#L36

chatrbot commented 2 years ago

@huan 很抱歉现在才看到你的建议. 非常感谢,我已经测试并且更新了demo代码.根据你的建议精简掉了两个多余的依赖库:)

huan commented 2 years ago

Awesome! Glad to know that we have less dependencies now!