Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
5dc52c9d
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,发现更多精彩内容 >>
提交
5dc52c9d
编写于
2月 11, 2017
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
jsdoc
上级
48749c8c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
29 addition
and
72 deletion
+29
-72
docs/index.md
docs/index.md
+9
-57
src/wechaty.ts
src/wechaty.ts
+20
-15
未找到文件。
docs/index.md
浏览文件 @
5dc52c9d
...
...
@@ -13,52 +13,19 @@ https://github.com/zixia/wechaty
*
[
Wechaty
](
#Wechaty
)
*
_instance_
*
[
.state
](
#Wechaty+state
)
*
[
.npmVersion
](
#Wechaty+npmVersion
)
*
[
.puppet
](
#Wechaty+puppet
)
*
[
.toString()
](
#Wechaty+toString
)
*
[
.version([forceNpm])
](
#Wechaty+version
)
⇒
<code>
string
</code>
*
[
.user()
](
#Wechaty+user
)
*
[
.reset()
](
#Wechaty+reset
)
*
~~
[
.user()
](
#Wechaty+user
)
⇒
<code>
Contact
</code>
~~
*
[
.init()
](
#Wechaty+init
)
*
[
.on()
](
#Wechaty+on
)
*
[
.initPuppet()
](
#Wechaty+initPuppet
)
*
[
.quit()
](
#Wechaty+quit
)
*
[
.logout()
](
#Wechaty+logout
)
*
[
.self()
](
#Wechaty+self
)
*
[
.self()
](
#Wechaty+self
)
⇒
<code>
Contact
</code>
*
[
.send()
](
#Wechaty+send
)
*
[
.say()
](
#Wechaty+say
)
*
[
.sleep()
](
#Wechaty+sleep
)
*
[
.ding()
](
#Wechaty+ding
)
*
_static_
*
[
.instance()
](
#Wechaty.instance
)
<a
name=
"Wechaty+state"
></a>
### wechaty.state
the state
**Kind**
: instance property of
<code>
[
Wechaty
](
#Wechaty
)
</code>
<a
name=
"Wechaty+npmVersion"
></a>
### wechaty.npmVersion
the npmVersion
**Kind**
: instance property of
<code>
[
Wechaty
](
#Wechaty
)
</code>
<a
name=
"Wechaty+puppet"
></a>
### wechaty.puppet
TODO: support more events:
2.
send
3.
reply
4.
quit
5.
...
**Kind**
: instance property of
<code>
[
Wechaty
](
#Wechaty
)
</code>
<a
name=
"Wechaty+toString"
></a>
### wechaty.toString()
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
<a
name=
"Wechaty+version"
></a>
### wechaty.version([forceNpm]) ⇒ <code>string</code>
...
...
@@ -80,16 +47,14 @@ console.log(Wechaty.instance().version())
```
<a
name=
"Wechaty+user"
></a>
### wechaty.user()
### ~~wechaty.user() ⇒ <code>Contact</code>~~
***Deprecated**
*
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
**Todo**
-
[ ] document me
<a
name=
"Wechaty+reset"
></a>
### wechaty.reset()
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
<a
name=
"Wechaty+init"
></a>
### wechaty.init()
...
...
@@ -106,14 +71,6 @@ console.log(Wechaty.instance().version())
-
[ ] document me
<a
name=
"Wechaty+initPuppet"
></a>
### wechaty.initPuppet()
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
**Todo**
-
[ ] document me
<a
name=
"Wechaty+quit"
></a>
### wechaty.quit()
...
...
@@ -132,10 +89,11 @@ console.log(Wechaty.instance().version())
<a
name=
"Wechaty+self"
></a>
### wechaty.self()
### wechaty.self()
⇒ <code>Contact</code>
get current user
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
**Returns**
:
<code>
Contact
</code>
- current logined user
<a
name=
"Wechaty+send"
></a>
### wechaty.send()
...
...
@@ -160,15 +118,9 @@ get current user
-
[ ] document me
<a
name=
"Wechaty+ding"
></a>
### wechaty.ding()
**Kind**
: instance method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
**Todo**
-
[ ] document me
<a
name=
"Wechaty.instance"
></a>
### Wechaty.instance()
get the singleton instance of Wechaty
**Kind**
: static method of
<code>
[
Wechaty
](
#Wechaty
)
</code>
src/wechaty.ts
浏览文件 @
5dc52c9d
...
...
@@ -51,29 +51,34 @@ export type WechatyEventName = 'error'
export
class
Wechaty
extends
EventEmitter
implements
Sayable
{
/**
* singleton _instance
* @private
*/
private
static
_instance
:
Wechaty
/**
* the puppet
* @private
*/
public
puppet
:
Puppet
|
null
/**
* the state
* @private
*/
private
state
=
new
StateMonitor
<
'
standby
'
,
'
ready
'
>
(
'
Wechaty
'
,
'
standby
'
)
/**
* the npmVersion
* @private
*/
private
npmVersion
:
string
=
require
(
'
../package.json
'
).
version
/**
* the uuid
* @private
*/
public
uuid
:
string
/**
*
*
get the singleton instance of Wechaty
*/
public
static
instance
(
setting
?:
PuppetSetting
)
{
if
(
setting
&&
this
.
_instance
)
{
...
...
@@ -86,7 +91,7 @@ export class Wechaty extends EventEmitter implements Sayable {
}
/**
*
*
@private
*/
private
constructor
(
private
setting
:
PuppetSetting
=
{})
{
super
()
...
...
@@ -108,13 +113,13 @@ export class Wechaty extends EventEmitter implements Sayable {
}
/**
*
*
@private
*/
public
toString
()
{
return
'
Class Wechaty(
'
+
this
.
setting
.
puppet
+
'
)
'
}
/**
* Return version of Wechaty
* @param
{boolean} [forceNpm=false]
if set to true, will only return the version in package.json.
* @param
[forceNpm=false] {boolean}
if set to true, will only return the version in package.json.
* otherwise will return git commit hash if .git exists.
* @returns {string} version number
* @example
...
...
@@ -160,8 +165,11 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* @todo document me
* @returns {Contact}
* @deprecated
*/
public
user
():
Contact
{
log
.
warn
(
'
Wechaty
'
,
'
user() DEPRECATED. use self() instead.
'
)
if
(
!
this
.
puppet
||
!
this
.
puppet
.
user
)
{
throw
new
Error
(
'
no user
'
)
}
...
...
@@ -169,7 +177,7 @@ export class Wechaty extends EventEmitter implements Sayable {
}
/**
*
*
@private
*/
public
async
reset
(
reason
?:
string
):
Promise
<
void
>
{
log
.
verbose
(
'
Wechaty
'
,
'
reset() because %s
'
,
reason
)
...
...
@@ -211,9 +219,10 @@ export class Wechaty extends EventEmitter implements Sayable {
// public on(event: WechatyEventName, listener: Function): this
/**
* @param {string} [event='error'] the `error` event
* @param {Function} listener (error) => void callback function
* @return {Wechaty} this for chain
* @listens Wechaty#error
* @param [event='error'] {string} the `error` event
* @param listener {Function} listener (error) => void callback function
* @return {Wechaty} this for chain
*/
public
on
(
event
:
'
error
'
,
listener
:
(
this
:
Wechaty
,
error
:
Error
)
=>
void
):
this
/**
...
...
@@ -282,6 +291,7 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* @todo document me
* @private
*/
public
async
initPuppet
():
Promise
<
Puppet
>
{
let
puppet
:
Puppet
...
...
@@ -323,13 +333,6 @@ export class Wechaty extends EventEmitter implements Sayable {
this
.
emit
.
apply
(
this
,
[
e
,
...
args
])
})
})
/**
* TODO: support more events:
* 2. send
* 3. reply
* 4. quit
* 5. ...
*/
// set puppet before init, because we need this.puppet if we quit() before init() finish
this
.
puppet
=
<
Puppet
>
puppet
// force to use base class Puppet interface for better encapsolation
...
...
@@ -383,6 +386,7 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* get current user
* @returns {Contact} current logined user
*/
public
self
():
Contact
{
if
(
!
this
.
puppet
)
{
...
...
@@ -430,6 +434,7 @@ export class Wechaty extends EventEmitter implements Sayable {
/**
* @todo document me
* @private
*/
public
ding
()
{
if
(
!
this
.
puppet
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录