Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
624eb986
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,发现更多精彩内容 >>
提交
624eb986
编写于
12月 29, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
856fd1fb
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
40 addition
and
34 deletion
+40
-34
example/api-ai-bot.ts
example/api-ai-bot.ts
+1
-1
example/tuling123-bot.ts
example/tuling123-bot.ts
+3
-3
src/puppet-web/browser-cookie.ts
src/puppet-web/browser-cookie.ts
+2
-2
src/puppet-web/browser.ts
src/puppet-web/browser.ts
+1
-0
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+1
-1
src/puppet-web/watchdog.ts
src/puppet-web/watchdog.ts
+6
-6
test/puppet-web/browser.spec.ts
test/puppet-web/browser.spec.ts
+2
-2
test/webdriver.spec.ts
test/webdriver.spec.ts
+21
-17
tsconfig.json
tsconfig.json
+3
-2
未找到文件。
example/api-ai-bot.ts
浏览文件 @
624eb986
...
...
@@ -24,7 +24,7 @@ import { EventEmitter } from 'events'
import
{
Config
,
Wechaty
}
from
'
..
'
}
from
'
..
/
'
// log.level = 'verbose'
// log.level = 'silly'
...
...
example/tuling123-bot.ts
浏览文件 @
624eb986
...
...
@@ -87,7 +87,7 @@ class Talker extends EventEmitter {
text
:
any
time
:
any
}
private
timer
:
numb
er
|
null
private
timer
:
NodeJS
.
Tim
er
|
null
constructor
(
private
thinker
)
{
super
()
...
...
@@ -111,12 +111,12 @@ class Talker extends EventEmitter {
return
text
}
public
updateTimer
(
delayTime
?)
{
public
updateTimer
(
delayTime
?
:
number
)
{
delayTime
=
delayTime
||
this
.
delayTime
()
log
.
verbose
(
'
Talker
'
,
'
updateTimer(%s)
'
,
delayTime
)
if
(
this
.
timer
)
{
clearTimeout
(
this
.
timer
)
}
this
.
timer
=
setTimeout
(
this
.
say
.
bind
(
this
),
delayTime
)
this
.
timer
=
setTimeout
(
_
=>
this
.
say
(
),
delayTime
)
}
public
hear
(
text
)
{
...
...
src/puppet-web/browser-cookie.ts
浏览文件 @
624eb986
...
...
@@ -137,7 +137,7 @@ export class BrowserCookie {
}
public
async
load
():
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebBrowserCookie
'
,
'
load() from %s
'
,
this
.
storeFile
)
log
.
verbose
(
'
PuppetWebBrowserCookie
'
,
'
load() from %s
'
,
this
.
storeFile
||
'
"undefined"
'
)
const
cookies
=
this
.
getCookiesFromFile
()
...
...
@@ -166,7 +166,7 @@ export class BrowserCookie {
}
public
getCookiesFromFile
():
CookieType
[]
|
null
{
log
.
verbose
(
'
PuppetWebBrowserCookie
'
,
'
getCookiesFromFile() from %s
'
,
this
.
storeFile
)
log
.
verbose
(
'
PuppetWebBrowserCookie
'
,
'
getCookiesFromFile() from %s
'
,
this
.
storeFile
||
'
"undefined"
'
)
try
{
if
(
!
this
.
storeFile
)
{
...
...
src/puppet-web/browser.ts
浏览文件 @
624eb986
...
...
@@ -268,6 +268,7 @@ export class Browser extends EventEmitter {
psTree
(
process
.
pid
,
(
err
,
children
)
=>
{
if
(
err
)
{
log
.
error
(
'
PuppetWebBrowser
'
,
'
getBrowserPidList() %s
'
,
err
.
message
||
err
)
reject
(
err
)
return
}
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
624eb986
...
...
@@ -50,7 +50,7 @@ export class PuppetWeb extends Puppet {
public
lastScanEventTime
:
number
public
watchDogLastSaveSession
:
number
public
watchDogTimer
:
number
public
watchDogTimer
:
NodeJS
.
Timer
|
null
public
watchDogTimerTime
:
number
constructor
(
public
setting
:
PuppetWebSetting
=
{})
{
...
...
src/puppet-web/watchdog.ts
浏览文件 @
624eb986
...
...
@@ -81,7 +81,7 @@ function onFeed(this: PuppetWeb, food: WatchdogFood): void {
memoryCheck
.
call
(
this
)
}
function
clearWatchDogTimer
()
{
function
clearWatchDogTimer
(
this
:
PuppetWeb
)
{
if
(
!
this
.
watchDogTimer
)
{
log
.
verbose
(
'
PuppetWebWatchdog
'
,
'
clearWatchDogTimer() nothing to clear
'
)
return
...
...
@@ -95,19 +95,18 @@ function clearWatchDogTimer() {
}
}
function
setWatchDogTimer
(
this
:
PuppetWeb
,
timeout
,
feed
)
{
function
setWatchDogTimer
(
this
:
PuppetWeb
,
timeout
:
number
,
feed
)
{
clearWatchDogTimer
.
call
(
this
)
log
.
silly
(
'
PuppetWebWatchdog
'
,
'
setWatchDogTimer(%d, %s)
'
,
timeout
,
feed
)
this
.
watchDogTimer
=
setTimeout
(
watchDogReset
.
bind
(
this
,
timeout
,
feed
),
timeout
)
this
.
watchDogTimer
=
setTimeout
(
_
=>
watchDogReset
.
call
(
this
,
timeout
,
feed
),
timeout
)
this
.
watchDogTimerTime
=
Date
.
now
()
+
timeout
// this.watchDogTimer.unref()
// block quit, force to use quit() // this.watchDogTimer.unref() // dont block quit
}
function
watchDogReset
(
timeout
,
lastFeed
)
{
async
function
watchDogReset
(
timeout
,
lastFeed
):
Promise
<
void
>
{
log
.
verbose
(
'
PuppetWebWatchdog
'
,
'
watchDogReset(%d, %s)
'
,
timeout
,
lastFeed
)
const
e
=
new
Error
(
'
watchDogReset() watchdog reset after
'
...
...
@@ -117,7 +116,8 @@ function watchDogReset(timeout, lastFeed) {
)
log
.
verbose
(
'
PuppetWebWatchdog
'
,
e
.
message
)
this
.
emit
(
'
error
'
,
e
)
return
Event
.
onBrowserDead
.
call
(
this
,
e
)
Event
.
onBrowserDead
.
call
(
this
,
e
)
return
}
/**
...
...
test/puppet-web/browser.spec.ts
浏览文件 @
624eb986
...
...
@@ -9,8 +9,8 @@ import * as fs from 'fs'
import
{
test
}
from
'
ava
'
import
{
Config
,
log
Config
,
log
,
}
from
'
../../
'
import
{
...
...
test/webdriver.spec.ts
浏览文件 @
624eb986
...
...
@@ -25,23 +25,27 @@ import {
* if 2 tests run parallel in the same process,
* there will have race conditions for the conflict of `getBrowserPids()`
*/
test
.
serial
(
'
WebDriver process create & quit test
'
,
async
t
=>
{
const
browser
=
new
Browser
()
t
.
truthy
(
browser
,
'
should instanciate a browser
'
)
await
browser
.
init
()
t
.
pass
(
'
should be inited successful
'
)
await
browser
.
open
()
t
.
pass
(
'
should open successful
'
)
let
pids
=
await
browser
.
getBrowserPidList
()
t
.
truthy
(
pids
.
length
>
0
,
'
should exist browser process after b.open()
'
)
await
browser
.
quit
()
t
.
pass
(
'
quited
'
)
pids
=
await
browser
.
getBrowserPidList
()
t
.
is
(
pids
.
length
,
0
,
'
no driver process after quit
'
)
test
.
only
(
'
WebDriver process create & quit test
'
,
async
t
=>
{
try
{
const
browser
=
new
Browser
()
t
.
truthy
(
browser
,
'
should instanciate a browser
'
)
await
browser
.
init
()
t
.
pass
(
'
should be inited successful
'
)
await
browser
.
open
()
t
.
pass
(
'
should open successful
'
)
let
pids
=
await
browser
.
getBrowserPidList
()
t
.
truthy
(
pids
.
length
>
0
,
'
should exist browser process after b.open()
'
)
await
browser
.
quit
()
t
.
pass
(
'
quited
'
)
pids
=
await
browser
.
getBrowserPidList
()
t
.
is
(
pids
.
length
,
0
,
'
no driver process after quit
'
)
}
catch
(
err
)
{
t
.
fail
(
err
.
message
||
err
)
}
})
test
.
serial
(
'
WebDriver smoke testing
'
,
async
t
=>
{
...
...
tsconfig.json
浏览文件 @
624eb986
{
"compilerOptions"
:
{
"target"
:
"es
6
"
"target"
:
"es
2015
"
,
"module"
:
"commonjs"
,
"outDir"
:
"dist"
,
"declaration"
:
true
...
...
@@ -15,13 +15,14 @@
,
"noImplicitAny"
:
false
,
"noUnusedParameters"
:
false
,
"noImplicitThis"
:
false
,
"traceResolution"
:
false
}
,
"exclude"
:
[
"node_modules"
,
"dist"
]
,
"include"
:
[
"bin/*.ts"
"bin/*.ts"
,
"example/**/*.ts"
,
"src/**/*.ts"
,
"test/**/*.spec.ts"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录