From e26f3f6a80c2ea166179a5cf8dc66704b4405a7e Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Tue, 28 Jun 2016 14:49:53 +0800 Subject: [PATCH] init io before other wechaty inittiations --- bin/io-bot.js | 2 +- src/wechaty.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bin/io-bot.js b/bin/io-bot.js index 7723c56f..825a67b5 100644 --- a/bin/io-bot.js +++ b/bin/io-bot.js @@ -26,7 +26,7 @@ const bot = new Wechaty({ profile: 'io-bot' }) bot .on('login' , user => log.info('Bot', `${user.name()} logined`)) .on('logout' , user => log.info('Bot', `${user.name()} logouted`)) -.on('scan' , ({url, code}) => log.info('Bot', `${url}\n[${code}] Scan QR Code in above url to login: `)) +.on('scan' , ({url, code}) => log.info('Bot', `[${code}] Scan QR Code in url to login: ${url}`)) .on('message', m => { m.ready() .then(onMessage) diff --git a/src/wechaty.js b/src/wechaty.js index bb62673b..963fe11d 100644 --- a/src/wechaty.js +++ b/src/wechaty.js @@ -64,16 +64,16 @@ class Wechaty extends EventEmitter { log.verbose('Wechaty', 'port: %d', this.port) } - yield this.initPuppet() - yield this.initEventHook() - yield this.puppet.init() - yield this.initIo() - .catch(e => { + .catch(e => { // fail safe log.error('WechatyIo', 'initIo failed: %s', e.message) this.emit('error', e) }) + yield this.initPuppet() + yield this.initEventHook() + yield this.puppet.init() + this.inited = true return this // for chaining }) -- GitLab