提交 07008dff 编写于 作者: Huan (李卓桓)'s avatar Huan (李卓桓)

use qrCode data for `scan` event (#1262)

上级 be1bedba
...@@ -71,13 +71,12 @@ bot ...@@ -71,13 +71,12 @@ bot
log.info('Bot', `${user.name()} login`) log.info('Bot', `${user.name()} login`)
bot.say('Wechaty login').catch(console.error) bot.say('Wechaty login').catch(console.error)
}) })
.on('scan', (url, code) => { .on('scan', (qrCode, statusCode) => {
if (!/201|200/.test(String(code))) { if (!/201|200/.test(String(statusCode))) {
const loginUrl = url.replace(/\/qrcode\//, '/l/') QrcodeTerminal.generate(qrCode, { small: true }, (qrcode: string) => {
QrcodeTerminal.generate(loginUrl, { small: true }, (qrcode: string) => {
console.log(qrcode) console.log(qrcode)
console.log(url) console.log(qrCode)
console.log(`[${code}] Scan QR Code above url to log in: `) console.log(`[${statusCode}] Scan QR Code above url to log in: `)
}) })
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册