Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
195d11ee
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,体验更适合开发者的 AI 搜索 >>
提交
195d11ee
编写于
10月 09, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Typescript transition step 7: fix puppet.ts & tslint
上级
5787f6da
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
40 addition
and
23 deletion
+40
-23
src/puppet.ts
src/puppet.ts
+40
-23
未找到文件。
src/puppet.ts
浏览文件 @
195d11ee
...
...
@@ -10,11 +10,19 @@
*
*/
const
EventEmitter
=
require
(
'
events
'
)
import
{
EventEmitter
}
from
'
events
'
import
log
from
'
./brolog-env
'
import
Contact
from
'
./contact
'
import
Message
from
'
./message
'
import
Room
from
'
./room
'
import
log
from
'
./brolog-env
'
class
Puppet
extends
EventEmitter
{
private
_user
:
Contact
private
_targetState
:
string
private
_currentState
:
string
constructor
()
{
super
()
...
...
@@ -30,7 +38,7 @@ class Puppet extends EventEmitter {
}
// targetState : 'live' | 'dead'
targetState
(
newState
)
{
public
targetState
(
newState
)
{
if
(
newState
)
{
log
.
verbose
(
'
Puppet
'
,
'
targetState(%s)
'
,
newState
)
this
.
_targetState
=
newState
...
...
@@ -39,7 +47,7 @@ class Puppet extends EventEmitter {
}
// currentState : 'birthing' | 'killing'
currentState
(
newState
)
{
public
currentState
(
newState
)
{
if
(
newState
)
{
log
.
verbose
(
'
Puppet
'
,
'
currentState(%s)
'
,
newState
)
this
.
_currentState
=
newState
...
...
@@ -47,14 +55,16 @@ class Puppet extends EventEmitter {
return
this
.
_currentState
}
// @deprecated
// readyState(newState) {
// if (newState) {
// log.verbose('Puppet', 'readyState() set to "%s"', newState)
// this._readyState = newState
// }
// return this._readyState
// }
public
self
(
message
?:
Message
):
boolean
|
Contact
{
throw
new
Error
(
'
pure virtual interface function
'
)
}
public
user
(
contact
?:
Contact
)
{
if
(
contact
)
{
this
.
_user
=
contact
}
return
this
.
_user
}
/**
* let puppet send message
...
...
@@ -62,14 +72,15 @@ class Puppet extends EventEmitter {
* @param <Message> message - the message to be sent
* @return <Promise>
*/
send
(
message
)
{
throw
new
Error
(
'
To Be Implemented
'
)
}
reply
(
message
,
reply
)
{
throw
new
Error
(
'
To Be Implemented
'
)
}
public
send
(
message
):
Promise
<
any
>
{
throw
new
Error
(
'
To Be Implemented
'
)
}
public
reply
(
message
,
reply
):
Promise
<
any
>
{
throw
new
Error
(
'
To Be Implemented
'
)
}
logout
()
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
quit
()
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
ding
()
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
public
reset
(
reason
?:
string
)
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
public
logout
():
Promise
<
any
>
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
public
quit
():
Promise
<
any
>
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
public
ding
(
data
?:
string
):
Promise
<
any
>
{
throw
new
Error
(
'
To Be Implementsd
'
)
}
getContact
(
id
)
{
// for unit testing
public
getContact
(
id
):
Promise
<
any
>
{
// for unit testing
log
.
verbose
(
'
Puppet
'
,
`Interface method getContact(
${
id
}
)`
)
throw
new
Error
(
'
Absolute Interface Method should never to be called
'
)
// return Promise.resolve({UserName: 'WeChaty', NickName: 'Puppet'})
...
...
@@ -78,11 +89,17 @@ class Puppet extends EventEmitter {
// () { throw new Error('To Be Implemented') }
}
Object
.
assign
(
Puppet
,
{
Message
:
require
(
'
./message
'
)
,
Contact
:
require
(
'
./contact
'
)
,
Room
:
require
(
'
./room
'
)
})
//
Object.assign(Puppet, {
//
Message: require('./message')
//
, Contact: require('./contact')
//
, Room: require('./room')
//
})
// module.exports = Puppet
export
default
Puppet
export
{
Contact
,
Message
,
Puppet
,
Room
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录