Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
197aa1f3
W
wechaty
项目概览
weixin_46011646
/
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,发现更多精彩内容 >>
提交
197aa1f3
编写于
11月 09, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
linting with typescript v2.1
上级
e407c9e5
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
22 addition
and
17 deletion
+22
-17
src/config.ts
src/config.ts
+4
-5
src/message-media.ts
src/message-media.ts
+2
-0
src/puppet-web/firer.ts
src/puppet-web/firer.ts
+1
-1
src/puppet-web/puppet-web.ts
src/puppet-web/puppet-web.ts
+2
-1
src/puppet.ts
src/puppet.ts
+1
-1
src/room.ts
src/room.ts
+10
-7
src/wechaty.ts
src/wechaty.ts
+2
-2
未找到文件。
src/config.ts
浏览文件 @
197aa1f3
...
...
@@ -141,20 +141,19 @@ function puppetInstance(instance: Puppet): void
function
puppetInstance
(
instance
?:
Puppet
|
null
):
Puppet
|
void
{
if
(
instance
===
undefined
)
{
if
(
!
global
[
'
_puppetInstance
'
]
)
{
if
(
!
this
.
_puppetInstance
)
{
throw
new
Error
(
'
no puppet instance
'
)
}
return
global
[
'
_puppetInstance
'
]
return
this
.
_puppetInstance
}
else
if
(
instance
===
null
)
{
log
.
verbose
(
'
Config
'
,
'
puppetInstance(null)
'
)
global
[
'
_puppetInstance
'
]
=
null
this
.
_puppetInstance
=
null
return
}
log
.
verbose
(
'
Config
'
,
'
puppetInstance(%s)
'
,
instance
.
constructor
.
name
)
global
[
'
_puppetInstance
'
]
=
instance
this
.
_puppetInstance
=
instance
return
}
...
...
src/message-media.ts
浏览文件 @
197aa1f3
...
...
@@ -20,6 +20,7 @@ export class MediaMessage extends Message {
constructor
(
rawObj
)
{
super
(
rawObj
)
// FIXME: decoupling needed
this
.
bridge
=
(
Config
.
puppetInstance
()
as
PuppetWeb
)
.
bridge
}
...
...
@@ -89,6 +90,7 @@ export class MediaMessage extends Message {
public
readyStream
():
Promise
<
NodeJS
.
ReadableStream
>
{
return
this
.
ready
()
.
then
(()
=>
{
// FIXME: decoupling needed
return
(
Config
.
puppetInstance
()
as
PuppetWeb
)
.
browser
.
readCookie
()
})
...
...
src/puppet-web/firer.ts
浏览文件 @
197aa1f3
...
...
@@ -272,7 +272,7 @@ async function checkRoomJoin(m: Message): Promise<void> {
return
}
function
parseRoomLeave
(
content
:
string
):
string
|
null
{
function
parseRoomLeave
(
content
:
string
):
string
{
const
reList
=
regexConfig
.
roomLeave
let
found
:
string
[]
|
null
=
[]
...
...
src/puppet-web/puppet-web.ts
浏览文件 @
197aa1f3
...
...
@@ -95,7 +95,7 @@ export class PuppetWeb extends Puppet {
const
food
:
WatchdogFood
=
{
data
:
'
inited
'
,
timeout
:
120
000
// 2 mins for first login
,
timeout
:
2
*
60
*
1
000
// 2 mins for first login
}
this
.
emit
(
'
watchdog
'
,
food
)
...
...
@@ -368,6 +368,7 @@ export class PuppetWeb extends Puppet {
throw
e
})
}
public
logined
():
boolean
{
return
!!
(
this
.
user
)
}
public
ding
(
data
?:
any
):
Promise
<
string
>
{
if
(
!
this
.
bridge
)
{
...
...
src/puppet.ts
浏览文件 @
197aa1f3
...
...
@@ -35,7 +35,7 @@ export abstract class Puppet extends EventEmitter implements Sayable {
super
()
}
public
abstract
async
init
():
Promise
<
this
>
public
abstract
async
init
():
Promise
<
void
>
/**
* @deprecated
* use Message.self() instead
...
...
src/room.ts
浏览文件 @
197aa1f3
...
...
@@ -70,22 +70,23 @@ export class Room extends EventEmitter implements Sayable {
return
!!
(
this
.
obj
&&
this
.
obj
.
memberList
&&
this
.
obj
.
memberList
.
length
)
}
public
async
refresh
():
Promise
<
this
>
{
public
async
refresh
():
Promise
<
void
>
{
if
(
this
.
isReady
())
{
this
.
dirtyObj
=
this
.
obj
}
this
.
obj
=
null
return
this
.
ready
()
await
this
.
ready
()
return
}
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
RoomRawObj
>
):
Promise
<
this
>
{
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
any
>
):
Promise
<
void
>
{
log
.
silly
(
'
Room
'
,
'
ready(%s)
'
,
contactGetter
?
contactGetter
.
constructor
.
name
:
''
)
if
(
!
this
.
id
)
{
const
e
=
new
Error
(
'
ready() on a un-inited Room
'
)
log
.
warn
(
'
Room
'
,
e
.
message
)
return
Promise
.
reject
(
e
)
throw
e
}
else
if
(
this
.
isReady
())
{
return
Promise
.
resolve
(
this
)
return
}
else
if
(
this
.
obj
&&
this
.
obj
.
id
)
{
log
.
warn
(
'
Room
'
,
'
ready() has obj.id but memberList empty in room %s. reloading
'
,
this
.
obj
.
topic
)
}
...
...
@@ -109,7 +110,7 @@ export class Room extends EventEmitter implements Sayable {
}
await
Promise
.
all
(
this
.
obj
.
memberList
.
map
(
c
=>
c
.
ready
(
contactGetter
)))
return
this
return
}
catch
(
e
)
{
log
.
error
(
'
Room
'
,
'
contactGetter(%s) exception: %s
'
,
this
.
id
,
e
.
message
)
...
...
@@ -423,7 +424,9 @@ export class Room extends EventEmitter implements Sayable {
if
(
!
roomList
||
roomList
.
length
<
1
)
{
throw
new
Error
(
'
no room found
'
)
}
return
roomList
[
0
].
ready
()
const
room
=
roomList
[
0
]
await
room
.
ready
()
return
room
}
public
static
load
(
id
:
string
):
Room
|
null
{
...
...
src/wechaty.ts
浏览文件 @
197aa1f3
...
...
@@ -323,8 +323,8 @@ export class Wechaty extends EventEmitter implements Sayable {
return
}
public
sleep
(
millisecond
:
number
):
Promise
<
void
>
{
return
new
Promise
(
resolve
=>
{
public
async
sleep
(
millisecond
:
number
):
Promise
<
void
>
{
await
new
Promise
(
resolve
=>
{
setTimeout
(
resolve
,
millisecond
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录