Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
8f788890
W
wechaty
项目概览
.Veneno.
/
wechaty
与 Fork 源项目一致
Fork自
wechaty / wechaty
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8f788890
编写于
10月 28, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename method: logonoff() to loginout()
上级
62dfa632
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
18 addition
and
18 deletion
+18
-18
example/ding-dong-bot.ts
example/ding-dong-bot.ts
+2
-2
src/io.ts
src/io.ts
+2
-2
src/puppet-web/wechaty-bro.js
src/puppet-web/wechaty-bro.js
+5
-5
src/puppet.ts
src/puppet.ts
+1
-1
src/wechaty.ts
src/wechaty.ts
+3
-3
test/puppet-web/bridge.spec.ts
test/puppet-web/bridge.spec.ts
+2
-2
test/puppet-web/puppet-web.spec.ts
test/puppet-web/puppet-web.spec.ts
+3
-3
未找到文件。
example/ding-dong-bot.ts
浏览文件 @
8f788890
...
...
@@ -113,7 +113,7 @@ bot.start()
bot
.
on
(
'
error
'
,
async
e
=>
{
log
.
error
(
'
Bot
'
,
'
error: %s
'
,
e
)
if
(
bot
.
log
onoff
())
{
if
(
bot
.
log
inout
())
{
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
.
log
onoff
())
{
if
(
bot
.
log
inout
())
{
bot
.
say
(
exitMsg
).
catch
(
console
.
error
)
}
})
src/io.ts
浏览文件 @
8f788890
...
...
@@ -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
...
...
src/puppet-web/wechaty-bro.js
浏览文件 @
8f788890
...
...
@@ -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
,
...
...
src/puppet.ts
浏览文件 @
8f788890
...
...
@@ -120,7 +120,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
/**
* Login / Logout
*/
public
abstract
log
onoff
()
:
boolean
public
abstract
log
inout
()
:
boolean
public
abstract
reset
(
reason
?:
string
)
:
void
public
abstract
logout
()
:
Promise
<
void
>
public
abstract
quit
()
:
Promise
<
void
>
...
...
src/wechaty.ts
浏览文件 @
8f788890
...
...
@@ -528,17 +528,17 @@ export class Wechaty extends EventEmitter implements Sayable {
*
* @returns {boolean}
* @example
* if (bot.log
onoff
()) {
* if (bot.log
inout
()) {
* console.log('Bot logined')
* } else {
* console.log('Bot not logined')
* }
*/
public
log
onoff
():
Boolean
{
public
log
inout
():
Boolean
{
if
(
!
this
.
puppet
)
{
return
false
}
return
this
.
puppet
.
log
onoff
()
return
this
.
puppet
.
log
inout
()
}
/**
...
...
test/puppet-web/bridge.spec.ts
浏览文件 @
8f788890
...
...
@@ -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()
'
)
...
...
test/puppet-web/puppet-web.spec.ts
浏览文件 @
8f788890
...
...
@@ -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
.
log
onoff
()
,
false
,
'
should be not logined
'
)
t
.
is
(
pw
.
log
inout
()
,
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
.
log
onoff
(),
true
,
'
should be logined
'
)
t
.
is
(
pw
.
log
inout
(),
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
.
log
onoff
(),
false
,
'
should be logouted
'
)
t
.
is
(
pw
.
log
inout
(),
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录