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

rename method: logonoff() to loginout()

上级 62dfa632
......@@ -113,7 +113,7 @@ bot.start()
bot.on('error', async e => {
log.error('Bot', 'error: %s', e)
if (bot.logonoff()) {
if (bot.loginout()) {
await bot.say('Wechaty error: ' + e.message).catch(console.error)
}
await bot.stop()
......@@ -122,7 +122,7 @@ bot.on('error', async e => {
finis((code, signal) => {
const exitMsg = `Wechaty exit ${code} because of ${signal} `
console.log(exitMsg)
if (bot.logonoff()) {
if (bot.loginout()) {
bot.say(exitMsg).catch(console.error)
}
})
......@@ -269,7 +269,7 @@ export class Io {
break
case 'shutdown':
log.warn('Io', 'on(shutdown): %s', ioEvent.payload)
log.info('Io', 'on(shutdown): %s', ioEvent.payload)
process.exit(0)
break
......@@ -304,7 +304,7 @@ export class Io {
break
case 'logout':
log.warn('Io', 'on(logout): %s', ioEvent.payload)
log.info('Io', 'on(logout): %s', ioEvent.payload)
this.options.wechaty.logout()
break
......
......@@ -63,7 +63,7 @@
hookRecalledMsgProcess()
log('init() scanCode: ' + WechatyBro.vars.scanCode)
checkScan()
setTimeout(() => checkScan(), 1000)
heartBeat(true)
......@@ -258,12 +258,12 @@
// WechatyBro.emit('logout', data)
if (WechatyBro.glue.loginFactory) {
WechatyBro.glue.loginFactory.loginout()
WechatyBro.glue.loginFactory.loginout(0)
} else {
log('logout() WechatyBro.glue.loginFactory NOT found')
}
checkScan()
setTimeout(() => checkScan(), 1000)
}
function ding(data) {
......@@ -540,7 +540,7 @@
}
function getUserName() {
if (!WechatyBro.isLogin()) {
if (!WechatyBro.loginState()) {
return null
}
var accountFactory = WechatyBro.glue.accountFactory
......@@ -844,7 +844,7 @@
// test purpose
isLogin: () => {
log('DEPRECATED. use loginState() instead');
log('isLogin() DEPRECATED. use loginState() instead');
return loginState()
},
loginState,
......
......@@ -120,7 +120,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
/**
* Login / Logout
*/
public abstract logonoff() : boolean
public abstract loginout() : boolean
public abstract reset(reason?: string) : void
public abstract logout() : Promise<void>
public abstract quit() : Promise<void>
......
......@@ -528,17 +528,17 @@ export class Wechaty extends EventEmitter implements Sayable {
*
* @returns {boolean}
* @example
* if (bot.logonoff()) {
* if (bot.loginout()) {
* console.log('Bot logined')
* } else {
* console.log('Bot not logined')
* }
*/
public logonoff(): Boolean {
public loginout(): Boolean {
if (!this.puppet) {
return false
}
return this.puppet.logonoff()
return this.puppet.loginout()
}
/**
......
......@@ -88,8 +88,8 @@ test('WechatyBro.ding()', async t => {
t.is(retDing, 'dong', 'should got dong after execute WechatyBro.ding()')
const retCode = await bridge.proxyWechaty('isLogin')
t.is(typeof retCode, 'boolean', 'should got a boolean after call proxyWechaty(isLogin)')
const retCode = await bridge.proxyWechaty('loginState')
t.is(typeof retCode, 'boolean', 'should got a boolean after call proxyWechaty(loginState)')
await bridge.quit()
t.pass('b.quit()')
......
......@@ -64,13 +64,13 @@ test('login/logout events', sinonTest(async function (t: test.Test) {
await pw.init()
t.pass('should be inited')
t.is(pw.logonoff() , false , 'should be not logined')
t.is(pw.loginout() , false , 'should be not logined')
const EXPECTED_CHIPER = 'loginFired'
const loginPromise = new Promise(r => pw.once('login', _ => r(EXPECTED_CHIPER)))
pw.bridge.emit('login', 'TestPuppetWeb')
t.is(await loginPromise, EXPECTED_CHIPER, 'should fired login event')
t.is(pw.logonoff(), true , 'should be logined')
t.is(pw.loginout(), true , 'should be logined')
t.ok((pw.bridge.getUserName as any).called, 'bridge.getUserName should be called')
t.ok((pw.getContact as any).called, 'pw.getContact should be called')
......@@ -81,7 +81,7 @@ test('login/logout events', sinonTest(async function (t: test.Test) {
const logoutPromise = new Promise((res, rej) => pw.once('logout', _ => res('logoutFired')))
pw.bridge.emit('logout')
t.is(await logoutPromise, 'logoutFired', 'should fire logout event')
t.is(pw.logonoff(), false, 'should be logouted')
t.is(pw.loginout(), false, 'should be logouted')
await pw.quit()
profile.destroy()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册