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

print a url that can show the qrcode image for convenience

上级 f3e48b9d
......@@ -32,7 +32,8 @@ import { FileBox } from 'file-box'
import {
Wechaty,
log,
} from '../src/'
qrcodeValueToImageUrl,
} from '../src/'
const BOT_QR_CODE_IMAGE_FILE = path.resolve(
__dirname,
......@@ -78,7 +79,9 @@ bot
if (data) {
console.log(data)
}
console.log(`[${status}] Scan QR Code above url to log in: `)
console.log(qrcodeValueToImageUrl(qrcode))
console.log('^^^ Online QR Code Image URL ^^^ ')
console.log(`[${status}] ${qrcode} Scan QR Code above url to log in: `)
})
.on('message', async msg => {
try {
......
......@@ -218,6 +218,14 @@ export interface Sayable {
// String.fromCharCode(8197)
export const FOUR_PER_EM_SPACE = String.fromCharCode(0x2005)
export function qrcodeValueToImageUrl(qrcodeValue: string): string {
return [
'https://api.qrserver.com/v1/create-qr-code/?data=',
encodeURIComponent(qrcodeValue),
'&size=220x220&margin=0',
].join('')
}
export {
log,
Raven,
......
......@@ -5,8 +5,9 @@ export {
export {
config,
log,
qrcodeValueToImageUrl,
VERSION,
} from './config'
} from './config'
/**
* We need to put `Wechaty` at the beginning of this file for import
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册