Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
a3195954
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,发现更多精彩内容 >>
提交
a3195954
编写于
6月 10, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:zixia/wechaty
上级
74c4625f
3cfbeaa4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
32 addition
and
14 deletion
+32
-14
src/puppet-web-browser.js
src/puppet-web-browser.js
+2
-2
src/puppet-web.js
src/puppet-web.js
+17
-4
src/room.js
src/room.js
+1
-2
src/wechaty.js
src/wechaty.js
+12
-6
未找到文件。
src/puppet-web-browser.js
浏览文件 @
a3195954
...
...
@@ -260,9 +260,9 @@ class Browser extends EventEmitter{
cleanSession
(
session
)
{
log
.
verbose
(
'
Browser
'
,
`cleanSession(
${
session
}
)`
)
if
(
this
.
dead
())
{
return
Promise
.
reject
(
'
cleanSession() - browser dead
'
)}
if
(
this
.
dead
())
{
return
Promise
.
reject
(
'
cleanSession() - browser dead
'
)}
if
(
!
session
)
{
return
Promise
.
reject
(
'
cleanSession() no session
'
)
}
if
(
!
session
)
{
return
Promise
.
reject
(
'
cleanSession() no session
'
)
}
const
filename
=
session
return
new
Promise
((
resolve
,
reject
)
=>
{
require
(
'
fs
'
).
unlink
(
filename
,
err
=>
{
...
...
src/puppet-web.js
浏览文件 @
a3195954
...
...
@@ -211,7 +211,11 @@ class PuppetWeb extends Puppet {
onServerScan
(
data
)
{
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerScan: %s
'
,
Object
.
keys
(
data
).
join
(
'
,
'
))
this
.
browser
.
cleanSession
().
catch
(()
=>
{
/* fall safe */
})
if
(
this
.
session
)
{
this
.
browser
.
cleanSession
(
this
.
session
)
.
catch
(()
=>
{
/* fall safe */
})
}
this
.
emit
(
'
scan
'
,
data
)
}
...
...
@@ -272,14 +276,23 @@ class PuppetWeb extends Puppet {
log
.
warn
(
'
PuppetWeb
'
,
'
server received unload event
'
)
// this.onServerLogout(data) // XXX: should emit event[logout] from browser
if
(
!
this
.
browser
||
!
this
.
bridge
)
{
log
.
verbose
(
'
PuppetWeb
'
,
'
bridge
gone, should be quiting now
'
)
if
(
!
this
.
browser
)
{
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerUnload() found browser
gone, should be quiting now
'
)
return
}
if
(
this
.
browser
.
dead
())
{
log
.
warn
(
'
PuppetWeb
'
,
'
onServerUnload() found browser dead. wait deadguard to restore
'
)
return
}
if
(
!
this
.
bridge
)
{
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerUnload() found bridge gone, should be quiting now
'
)
return
}
return
process
.
nextTick
(()
=>
{
this
.
bridge
.
init
()
.
then
(
r
=>
log
.
verbose
(
'
PuppetWeb
'
,
'
bridge.re-init()ed:
'
+
r
))
.
then
(
r
=>
log
.
verbose
(
'
PuppetWeb
'
,
'
onServerUnload()
bridge.re-init()ed:
'
+
r
))
.
catch
(
e
=>
log
.
error
(
'
PuppetWeb
'
,
'
onServerUnload() err:
'
+
e
.
message
))
})
...
...
src/room.js
浏览文件 @
a3195954
...
...
@@ -7,7 +7,6 @@
*
*/
const
log
=
require
(
'
./npmlog-env
'
)
const
Contact
=
require
(
'
./contact
'
)
class
Room
{
constructor
(
id
)
{
...
...
@@ -61,7 +60,7 @@ class Room {
}
return
memberList
.
map
(
m
=>
{
return
{
contact
:
Contact
.
load
(
m
.
UserName
)
id
:
m
.
UserName
,
name
:
m
.
DisplayName
}
})
...
...
src/wechaty.js
浏览文件 @
a3195954
...
...
@@ -9,6 +9,7 @@
*
*/
const
EventEmitter
=
require
(
'
events
'
)
const
co
=
require
(
'
co
'
)
const
log
=
require
(
'
./npmlog-env
'
)
...
...
@@ -25,7 +26,7 @@ class Wechaty extends EventEmitter {
this
.
options
=
options
||
{}
this
.
options
.
puppet
=
this
.
options
.
puppet
||
process
.
env
.
WECHATY_PUPPET
||
'
web
'
this
.
options
.
head
=
this
.
options
.
head
||
process
.
env
.
WECHATY_HEAD
||
false
this
.
options
.
session
=
this
.
options
.
session
||
process
.
env
.
WECHATY_SESSION
// no session, no session
r
estore
this
.
options
.
session
=
this
.
options
.
session
||
process
.
env
.
WECHATY_SESSION
// no session, no session
save/
estore
this
.
VERSION
=
require
(
'
../package.json
'
).
version
}
...
...
@@ -36,12 +37,16 @@ class Wechaty extends EventEmitter {
log
.
verbose
(
'
Wechaty
'
,
'
head: %s
'
,
this
.
options
.
head
)
log
.
verbose
(
'
Wechaty
'
,
'
session: %s
'
,
this
.
options
.
session
)
this
.
initPuppet
()
this
.
initEventHook
()
return
co
.
call
(
this
,
function
*
()
{
yield
this
.
initPuppet
()
yield
this
.
initEventHook
()
yield
this
.
puppet
.
init
()
return
this
.
puppet
.
init
()
.
then
(
r
=>
{
return
this
// for chaining
}).
catch
(
e
=>
{
log
.
error
(
'
Wechaty
'
,
'
init() be rejected: %s
'
,
e
)
throw
e
})
}
initPuppet
()
{
...
...
@@ -85,7 +90,8 @@ class Wechaty extends EventEmitter {
return
Promise
.
resolve
()
}
quit
()
{
return
this
.
puppet
.
quit
()
}
quit
()
{
return
this
.
puppet
.
quit
()
}
logout
()
{
return
this
.
puppet
.
logout
()
}
send
(
message
)
{
return
this
.
puppet
.
send
(
message
)
}
reply
(
message
,
reply
)
{
return
this
.
puppet
.
reply
(
message
,
reply
)
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录