diff --git a/examples/ding-dong-bot.ts b/examples/ding-dong-bot.ts index d6dda96ac00b78faceeabd8f504cdc80aeca304c..4efba04b0a7c51520740eec7ab9d6fb2d581e269 100644 --- a/examples/ding-dong-bot.ts +++ b/examples/ding-dong-bot.ts @@ -72,16 +72,20 @@ bot.start() * */ function onScan (qrcode: string, status: ScanStatus) { - generate(qrcode) - - // Generate a QR Code online via - // http://goqr.me/api/doc/create-qr-code/ - const qrcodeImageUrl = [ - 'https://api.qrserver.com/v1/create-qr-code/?data=', - encodeURIComponent(qrcode), - ].join('') - - console.info('%s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl) + if (status === ScanStatus.Waiting || status === ScanStatus.Timeout) { + generate(qrcode) + + // Generate a QR Code online via + // http://goqr.me/api/doc/create-qr-code/ + const qrcodeImageUrl = [ + 'https://api.qrserver.com/v1/create-qr-code/?data=', + encodeURIComponent(qrcode), + ].join('') + + console.info('onScan: %s(%s) - %s', ScanStatus[status], status, qrcodeImageUrl) + } else { + console.info('onScan: %s(%s)', ScanStatus[status], status) + } // console.info(`[${ScanStatus[status]}(${status})] ${qrcodeImageUrl}\nScan QR Code above to log in: `) } diff --git a/package.json b/package.json index c6921c24321bf6cff97e8a570e2b59e7439b9605..5e6e97263bdc89143efc67223a407e0c98353692 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ }, "dependencies": { "brolog": "^1.8.1", - "clone-class": "^0.6.11", + "clone-class": "^0.7.3", "cuid": "^2.1.1", "hot-import": "^0.2.1", "in-gfw": "^1.2.0", diff --git a/src/accessory.ts b/src/accessory.ts index 839529866d880f6ae1b9a6fae7844617a55a9f18..dde5a94169bd39ed5999aabda6793b3ae55a4ee8 100644 --- a/src/accessory.ts +++ b/src/accessory.ts @@ -9,8 +9,8 @@ import { Wechaty } from './wechaty' // use Symbol to prevent conflicting with the child class properties // This symbol must be exported (for now). // See: https://github.com/Microsoft/TypeScript/issues/20080 -export const SYMBOL_NAME = Symbol('name') -export const SYMBOL_COUNTER = Symbol('counter') +const SYMBOL_NAME = Symbol('name') +const SYMBOL_COUNTER = Symbol('counter') let COUNTER = 0 @@ -155,6 +155,7 @@ export abstract class Accessory extends EventEmitter { * FriendRequest.wechaty * Message.wechaty * Room.wechaty + * ... etc * * So it only need one `wechaty` for all the instances */