Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.www.
wechaty
提交
a75f560f
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,发现更多精彩内容 >>
提交
a75f560f
编写于
7月 03, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
6f222d08
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
10 addition
and
30 deletion
+10
-30
src/puppet-web-injectio.js
src/puppet-web-injectio.js
+3
-3
src/wechaty.js
src/wechaty.js
+7
-27
未找到文件。
src/puppet-web-injectio.js
浏览文件 @
a75f560f
...
@@ -340,8 +340,8 @@ return (function(port) {
...
@@ -340,8 +340,8 @@ return (function(port) {
function
checkScan
()
{
function
checkScan
()
{
clog
(
'
checkScan()
'
)
clog
(
'
checkScan()
'
)
if
(
isLogin
())
{
if
(
isLogin
())
{
log
(
'
checkScan() - already login, no more check, but I will emit a login event
'
)
log
(
'
checkScan() - already login, no more check,
and return(only)
'
)
//
but I will emit a login event')
login
(
'
checkScan found already login
'
)
//
login('checkScan found already login')
return
return
}
}
if
(
!
Wechaty
.
glue
.
loginScope
)
{
if
(
!
Wechaty
.
glue
.
loginScope
)
{
...
@@ -352,9 +352,9 @@ return (function(port) {
...
@@ -352,9 +352,9 @@ return (function(port) {
// loginScope.code:
// loginScope.code:
// 0: 显示二维码
// 0: 显示二维码
// 408: 未确认(显示二维码后30秒触发)
// 201: 扫描,未确认
// 201: 扫描,未确认
// 200: 登录成功
// 200: 登录成功
// 408: 未确认
var
code
=
+
Wechaty
.
glue
.
loginScope
.
code
var
code
=
+
Wechaty
.
glue
.
loginScope
.
code
var
url
=
Wechaty
.
glue
.
loginScope
.
qrcodeUrl
var
url
=
Wechaty
.
glue
.
loginScope
.
qrcodeUrl
if
(
url
&&
code
!==
Wechaty
.
vars
.
scanCode
)
{
if
(
url
&&
code
!==
Wechaty
.
vars
.
scanCode
)
{
...
...
src/wechaty.js
浏览文件 @
a75f560f
...
@@ -64,15 +64,13 @@ class Wechaty extends EventEmitter {
...
@@ -64,15 +64,13 @@ class Wechaty extends EventEmitter {
log
.
verbose
(
'
Wechaty
'
,
'
port: %d
'
,
this
.
port
)
log
.
verbose
(
'
Wechaty
'
,
'
port: %d
'
,
this
.
port
)
}
}
yield
this
.
initIo
()
this
.
io
=
yield
this
.
initIo
()
.
catch
(
e
=>
{
// fail safe
.
catch
(
e
=>
{
// fail safe
log
.
error
(
'
WechatyIo
'
,
'
initIo failed: %s
'
,
e
.
message
)
log
.
error
(
'
WechatyIo
'
,
'
initIo failed: %s
'
,
e
.
message
)
this
.
emit
(
'
error
'
,
e
)
this
.
emit
(
'
error
'
,
e
)
})
})
yield
this
.
initPuppet
()
this
.
puppet
=
yield
this
.
initPuppet
()
yield
this
.
initEventHook
()
yield
this
.
puppet
.
init
()
this
.
inited
=
true
this
.
inited
=
true
return
this
// for chaining
return
this
// for chaining
...
@@ -92,7 +90,7 @@ class Wechaty extends EventEmitter {
...
@@ -92,7 +90,7 @@ class Wechaty extends EventEmitter {
}
}
const
WechatyIo
=
require
(
'
./wechaty-io
'
)
const
WechatyIo
=
require
(
'
./wechaty-io
'
)
const
io
=
this
.
io
=
new
WechatyIo
({
const
io
=
new
WechatyIo
({
wechaty
:
this
wechaty
:
this
,
token
:
this
.
token
,
token
:
this
.
token
,
endpoint
:
this
.
endpoint
,
endpoint
:
this
.
endpoint
...
@@ -106,9 +104,10 @@ class Wechaty extends EventEmitter {
...
@@ -106,9 +104,10 @@ class Wechaty extends EventEmitter {
}
}
initPuppet
()
{
initPuppet
()
{
let
puppet
switch
(
this
.
type
)
{
switch
(
this
.
type
)
{
case
'
web
'
:
case
'
web
'
:
this
.
puppet
=
new
PuppetWeb
(
{
puppet
=
new
PuppetWeb
(
{
head
:
this
.
head
head
:
this
.
head
,
port
:
this
.
port
,
port
:
this
.
port
,
profile
:
this
.
profile
,
profile
:
this
.
profile
...
@@ -117,10 +116,7 @@ class Wechaty extends EventEmitter {
...
@@ -117,10 +116,7 @@ class Wechaty extends EventEmitter {
default
:
default
:
throw
new
Error
(
'
Puppet unsupport(yet):
'
+
this
.
type
)
throw
new
Error
(
'
Puppet unsupport(yet):
'
+
this
.
type
)
}
}
return
Promise
.
resolve
(
this
.
puppet
)
}
initEventHook
()
{
;[
;[
'
scan
'
'
scan
'
,
'
message
'
,
'
message
'
...
@@ -129,26 +125,10 @@ class Wechaty extends EventEmitter {
...
@@ -129,26 +125,10 @@ class Wechaty extends EventEmitter {
,
'
error
'
,
'
error
'
,
'
heartbeat
'
,
'
heartbeat
'
].
map
(
e
=>
{
].
map
(
e
=>
{
this
.
puppet
.
on
(
e
,
data
=>
{
puppet
.
on
(
e
,
data
=>
{
this
.
emit
(
e
,
data
)
this
.
emit
(
e
,
data
)
})
})
})
})
// this.puppet.on('scan', data => {
// this.emit('scan', data) // Scan QRCode
// })
// this.puppet.on('message', data => {
// this.emit('message', data) // Receive Message
// })
// this.puppet.on('login', data => {
// this.emit('login', data)
// })
// this.puppet.on('logout', data => {
// this.emit('logout', data)
// })
// this.puppet.on('error', data => {
// this.emit('error', data)
// })
/**
/**
* TODO: support more events:
* TODO: support more events:
* 2. send
* 2. send
...
@@ -157,7 +137,7 @@ class Wechaty extends EventEmitter {
...
@@ -157,7 +137,7 @@ class Wechaty extends EventEmitter {
* 5. ...
* 5. ...
*/
*/
return
Promise
.
resolve
()
return
puppet
.
init
()
}
}
quit
()
{
quit
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录