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

code clean up

上级 2c8f4d0b
......@@ -29,16 +29,15 @@ let token = Config.token
if (!token) {
log.error('Bot', 'token not found: please set WECHATY_TOKEN in environment before run io-bot')
// process.exit(-1)
token = 'DEMO'
token = 'TEST'
log.warn('Bot', `set token to "${token}" for demo purpose`)
} else {
console.log(welcome)
log.info('Bot', 'Starting for WECHATY_TOKEN: %s', token)
}
console.log(welcome)
log.info('Bot', 'Starting for WECHATY_TOKEN: %s', token)
const ioBot = new IoBot({
profile: Config.profile || Config.DEFAULT_PROFILE
, token
token
, log
})
......
......@@ -6,10 +6,10 @@ Object.assign(Config, {
, head: process.env.WECHATY_HEAD || Config.DEFAULT_HEAD
, puppet: process.env.WECHATY_PUPPET || Config.DEFAULT_PUPPET
, endpoint: process.env.WECHATY_ENDPOINT || Config.ENDPOINT // wechaty.io api endpoint
, port: process.env.WECHATY_PORT || 0 // 0 for disable port
, profile: process.env.WECHATY_PROFILE // DO NOT set to DEFAULT_PROFILE, because sometimes user do not want to save session
, token: process.env.WECHATY_TOKEN // DO NOT set to DEFAULT, because sometimes user do not want to connect to io cloud service
, port: process.env.WECHATY_PORT || 0 // 0 for disable port
, profile: process.env.WECHATY_PROFILE || '' // DO NOT set DEFAULT_PROFILE, because sometimes user do not want to save session
, token: process.env.WECHATY_TOKEN || '' // DO NOT set DEFAULT, because sometimes user do not want to connect to io cloud service
})
module.exports = Config.default = Config.Config = Config
......@@ -9,12 +9,11 @@
* https://github.com/zixia/wechaty
*
*/
const Wechaty = require('./wechaty')
const { Wechaty } = require('./wechaty')
class IoBot {
constructor({
token = 'EPP'
, profile = 'wechaty-epp'
token
, log = Wechaty.log
}) {
if (!log) {
......@@ -30,15 +29,13 @@ class IoBot {
throw e
}
this.token = token
this.profile = profile
}
init() {
this.log.verbose('IoBot', 'init()')
const wechaty = this.wechaty = new Wechaty({
profile: this.profile
profile: Config.DEFAULT_PROFILE
, token: this.token
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册