Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
d3471839
W
wechaty
项目概览
.www.
/
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,发现更多精彩内容 >>
提交
d3471839
编写于
9月 05, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean up
上级
21d5a27f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
46 deletion
+43
-46
src/puppet-web/puppet-web.js
src/puppet-web/puppet-web.js
+38
-39
src/wechaty.js
src/wechaty.js
+5
-7
未找到文件。
src/puppet-web/puppet-web.js
浏览文件 @
d3471839
...
@@ -47,6 +47,8 @@ class PuppetWeb extends Puppet {
...
@@ -47,6 +47,8 @@ class PuppetWeb extends Puppet {
this
.
userId
=
null
// user id
this
.
userId
=
null
// user id
this
.
user
=
null
// <Contact> of user self
this
.
user
=
null
// <Contact> of user self
this
.
on
(
'
watchdog
'
,
Watchdog
.
onFeed
.
bind
(
this
))
}
}
toString
()
{
return
`Class PuppetWeb({browser:
${
this
.
browser
}
,port:
${
this
.
port
}
})`
}
toString
()
{
return
`Class PuppetWeb({browser:
${
this
.
browser
}
,port:
${
this
.
port
}
})`
}
...
@@ -56,8 +58,6 @@ class PuppetWeb extends Puppet {
...
@@ -56,8 +58,6 @@ class PuppetWeb extends Puppet {
this
.
readyState
(
'
connecting
'
)
this
.
readyState
(
'
connecting
'
)
this
.
on
(
'
watchdog
'
,
Watchdog
.
onFeed
.
bind
(
this
))
return
co
.
call
(
this
,
function
*
()
{
return
co
.
call
(
this
,
function
*
()
{
this
.
port
=
yield
UtilLib
.
getPort
(
Config
.
DEFAULT_PUPPET_PORT
)
this
.
port
=
yield
UtilLib
.
getPort
(
Config
.
DEFAULT_PUPPET_PORT
)
...
@@ -75,7 +75,6 @@ class PuppetWeb extends Puppet {
...
@@ -75,7 +75,6 @@ class PuppetWeb extends Puppet {
this
.
bridge
=
yield
this
.
initBridge
()
this
.
bridge
=
yield
this
.
initBridge
()
log
.
verbose
(
'
PuppetWeb
'
,
'
initBridge() done
'
)
log
.
verbose
(
'
PuppetWeb
'
,
'
initBridge() done
'
)
// this.watchDog('inited') // start watchdog
this
.
emit
(
'
watchdog
'
,
{
data
:
'
inited
'
})
this
.
emit
(
'
watchdog
'
,
{
data
:
'
inited
'
})
})
})
.
catch
(
e
=>
{
// Reject
.
catch
(
e
=>
{
// Reject
...
@@ -190,14 +189,14 @@ class PuppetWeb extends Puppet {
...
@@ -190,14 +189,14 @@ class PuppetWeb extends Puppet {
})
})
return
bridge
.
init
()
return
bridge
.
init
()
.
catch
(
e
=>
{
.
catch
(
e
=>
{
if
(
this
.
browser
.
dead
())
{
if
(
this
.
browser
.
dead
())
{
log
.
warn
(
'
PuppetWeb
'
,
'
initBridge() found browser dead, wait it to restore
'
)
log
.
warn
(
'
PuppetWeb
'
,
'
initBridge() found browser dead, wait it to restore
'
)
}
else
{
}
else
{
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() exception: %s
'
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
initBridge() exception: %s
'
,
e
.
message
)
throw
e
throw
e
}
}
})
})
}
}
initServer
()
{
initServer
()
{
...
@@ -222,10 +221,10 @@ class PuppetWeb extends Puppet {
...
@@ -222,10 +221,10 @@ class PuppetWeb extends Puppet {
server
.
on
(
'
ding
'
,
Event
.
onServerDing
.
bind
(
this
))
server
.
on
(
'
ding
'
,
Event
.
onServerDing
.
bind
(
this
))
return
server
.
init
()
return
server
.
init
()
.
catch
(
e
=>
{
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWeb
'
,
'
initServer() exception: %s
'
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
initServer() exception: %s
'
,
e
.
message
)
throw
e
throw
e
})
})
}
}
...
@@ -257,10 +256,10 @@ class PuppetWeb extends Puppet {
...
@@ -257,10 +256,10 @@ class PuppetWeb extends Puppet {
log
.
silly
(
'
PuppetWeb
'
,
`send(
${
destination
}
,
${
content
}
)`
)
log
.
silly
(
'
PuppetWeb
'
,
`send(
${
destination
}
,
${
content
}
)`
)
return
this
.
bridge
.
send
(
destination
,
content
)
return
this
.
bridge
.
send
(
destination
,
content
)
.
catch
(
e
=>
{
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWeb
'
,
'
send() exception: %s
'
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
send() exception: %s
'
,
e
.
message
)
throw
e
throw
e
})
})
}
}
reply
(
message
,
replyContent
)
{
reply
(
message
,
replyContent
)
{
if
(
this
.
self
(
message
))
{
if
(
this
.
self
(
message
))
{
...
@@ -287,10 +286,10 @@ class PuppetWeb extends Puppet {
...
@@ -287,10 +286,10 @@ class PuppetWeb extends Puppet {
*/
*/
logout
()
{
logout
()
{
return
this
.
bridge
.
logout
()
return
this
.
bridge
.
logout
()
.
catch
(
e
=>
{
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWeb
'
,
'
logout() exception: %s
'
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
logout() exception: %s
'
,
e
.
message
)
throw
e
throw
e
})
})
}
}
getContact
(
id
)
{
getContact
(
id
)
{
...
@@ -299,10 +298,10 @@ class PuppetWeb extends Puppet {
...
@@ -299,10 +298,10 @@ class PuppetWeb extends Puppet {
}
}
return
this
.
bridge
.
getContact
(
id
)
return
this
.
bridge
.
getContact
(
id
)
.
catch
(
e
=>
{
.
catch
(
e
=>
{
log
.
error
(
'
PuppetWeb
'
,
'
getContact(%d) exception: %s
'
,
id
,
e
.
message
)
log
.
error
(
'
PuppetWeb
'
,
'
getContact(%d) exception: %s
'
,
id
,
e
.
message
)
throw
e
throw
e
})
})
}
}
logined
()
{
return
!!
(
this
.
user
)
}
logined
()
{
return
!!
(
this
.
user
)
}
ding
(
data
)
{
ding
(
data
)
{
...
@@ -310,19 +309,19 @@ class PuppetWeb extends Puppet {
...
@@ -310,19 +309,19 @@ class PuppetWeb extends Puppet {
return
Promise
.
reject
(
new
Error
(
'
ding fail: no bridge(yet)!
'
))
return
Promise
.
reject
(
new
Error
(
'
ding fail: no bridge(yet)!
'
))
}
}
return
this
.
bridge
.
ding
(
data
)
return
this
.
bridge
.
ding
(
data
)
.
catch
(
e
=>
{
.
catch
(
e
=>
{
log
.
warn
(
'
PuppetWeb
'
,
'
ding(%s) rejected: %s
'
,
data
,
e
.
message
)
log
.
warn
(
'
PuppetWeb
'
,
'
ding(%s) rejected: %s
'
,
data
,
e
.
message
)
throw
e
throw
e
})
})
}
}
}
}
Object
.
assign
(
PuppetWeb
,
{
//
Object.assign(PuppetWeb, {
default
:
PuppetWeb
//
default: PuppetWeb
,
PuppetWeb
//
, PuppetWeb
,
Server
//
, Server
,
Browser
//
, Browser
,
Bridge
//
, Bridge
})
//
})
module
.
exports
=
PuppetWeb
module
.
exports
=
PuppetWeb
.
default
=
PuppetWeb
.
PuppetWeb
=
PuppetWeb
src/wechaty.js
浏览文件 @
d3471839
...
@@ -9,16 +9,14 @@
...
@@ -9,16 +9,14 @@
*
*
*/
*/
const
EventEmitter
=
require
(
'
events
'
)
const
EventEmitter
=
require
(
'
events
'
)
const
path
=
require
(
'
path
'
)
const
co
=
require
(
'
co
'
)
const
co
=
require
(
'
co
'
)
const
fs
=
require
(
'
fs
'
)
const
fs
=
require
(
'
fs
'
)
const
path
=
require
(
'
path
'
)
const
log
=
require
(
'
./brolog-env
'
)
const
UtilLib
=
require
(
'
./util-lib
'
)
const
PuppetWeb
=
require
(
'
./puppet-web
'
)
const
Config
=
require
(
'
./config
'
)
const
PuppetWeb
=
require
(
'
./puppet-web
'
)
const
UtilLib
=
require
(
'
./util-lib
'
)
const
Config
=
require
(
'
./config
'
)
const
log
=
require
(
'
./brolog-env
'
)
class
Wechaty
extends
EventEmitter
{
class
Wechaty
extends
EventEmitter
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录