Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
8a6d0b14
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,发现更多精彩内容 >>
提交
8a6d0b14
编写于
11月 26, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
d0558592
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
34 addition
and
12 deletion
+34
-12
example/gist-bot/on-message.ts
example/gist-bot/on-message.ts
+2
-2
example/tuling123-bot.ts
example/tuling123-bot.ts
+5
-5
src/contact.ts
src/contact.ts
+10
-0
src/io-client.ts
src/io-client.ts
+1
-5
src/message-media.ts
src/message-media.ts
+1
-0
src/message.ts
src/message.ts
+5
-0
src/room.ts
src/room.ts
+10
-0
未找到文件。
example/gist-bot/on-message.ts
浏览文件 @
8a6d0b14
...
@@ -6,8 +6,8 @@
...
@@ -6,8 +6,8 @@
*
*
*/
*/
import
{
import
{
Message
Message
,
,
Room
Room
,
}
from
'
../../
'
}
from
'
../../
'
export
async
function
onMessage
(
message
:
Message
):
Promise
<
void
>
{
export
async
function
onMessage
(
message
:
Message
):
Promise
<
void
>
{
...
...
example/tuling123-bot.ts
浏览文件 @
8a6d0b14
...
@@ -57,16 +57,16 @@ bot
...
@@ -57,16 +57,16 @@ bot
}
}
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
console
.
log
(
`
${
url
}
\n[
${
code
}
] Scan QR Code in above url to login: `
)
})
})
.
on
(
'
message
'
,
async
m
=>
{
.
on
(
'
message
'
,
async
m
sg
=>
{
if
(
m
.
self
())
return
if
(
m
sg
.
self
())
return
try
{
try
{
const
msg
=
await
m
.
ready
()
// const msg = await m.load
()
const
room
=
m
.
room
()
const
room
=
m
sg
.
room
()
if
(
room
&&
/Wechaty/i
.
test
(
room
.
topic
()))
{
if
(
room
&&
/Wechaty/i
.
test
(
room
.
topic
()))
{
log
.
info
(
'
Bot
'
,
'
talk: %s
'
,
msg
)
log
.
info
(
'
Bot
'
,
'
talk: %s
'
,
msg
)
talk
(
m
)
talk
(
m
sg
)
}
else
{
}
else
{
log
.
info
(
'
Bot
'
,
'
recv: %s
'
,
msg
)
log
.
info
(
'
Bot
'
,
'
recv: %s
'
,
msg
)
}
}
...
...
src/contact.ts
浏览文件 @
8a6d0b14
...
@@ -107,6 +107,11 @@ export class Contact implements Sayable {
...
@@ -107,6 +107,11 @@ export class Contact implements Sayable {
return
!!
(
this
.
obj
&&
this
.
obj
.
id
&&
this
.
obj
.
name
!==
undefined
)
return
!!
(
this
.
obj
&&
this
.
obj
.
id
&&
this
.
obj
.
name
!==
undefined
)
}
}
// public refresh() {
// log.warn('Contact', 'refresh() DEPRECATED. use reload() instead.')
// return this.reload()
// }
public
async
refresh
():
Promise
<
this
>
{
public
async
refresh
():
Promise
<
this
>
{
if
(
this
.
isReady
())
{
if
(
this
.
isReady
())
{
this
.
dirtyObj
=
this
.
obj
this
.
dirtyObj
=
this
.
obj
...
@@ -115,6 +120,11 @@ export class Contact implements Sayable {
...
@@ -115,6 +120,11 @@ export class Contact implements Sayable {
return
this
.
ready
()
return
this
.
ready
()
}
}
// public ready() {
// log.warn('Contact', 'ready() DEPRECATED. use load() instead.')
// return this.load()
// }
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
ContactRawObj
>
):
Promise
<
this
>
{
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
ContactRawObj
>
):
Promise
<
this
>
{
log
.
silly
(
'
Contact
'
,
'
ready(
'
+
(
contactGetter
?
typeof
contactGetter
:
''
)
+
'
)
'
)
log
.
silly
(
'
Contact
'
,
'
ready(
'
+
(
contactGetter
?
typeof
contactGetter
:
''
)
+
'
)
'
)
if
(
!
this
.
id
)
{
if
(
!
this
.
id
)
{
...
...
src/io-client.ts
浏览文件 @
8a6d0b14
...
@@ -99,11 +99,7 @@ export class IoClient {
...
@@ -99,11 +99,7 @@ export class IoClient {
.
on
(
'
login
'
,
user
=>
this
.
log
.
info
(
'
IoClient
'
,
`
${
user
.
name
()}
logined`
))
.
on
(
'
login
'
,
user
=>
this
.
log
.
info
(
'
IoClient
'
,
`
${
user
.
name
()}
logined`
))
.
on
(
'
logout
'
,
user
=>
this
.
log
.
info
(
'
IoClient
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
logout
'
,
user
=>
this
.
log
.
info
(
'
IoClient
'
,
`
${
user
.
name
()}
logouted`
))
.
on
(
'
scan
'
,
(
url
,
code
)
=>
this
.
log
.
info
(
'
IoClient
'
,
`[
${
code
}
]
${
url
}
`
))
.
on
(
'
scan
'
,
(
url
,
code
)
=>
this
.
log
.
info
(
'
IoClient
'
,
`[
${
code
}
]
${
url
}
`
))
.
on
(
'
message
'
,
message
=>
{
.
on
(
'
message
'
,
msg
=>
this
.
onMessage
(
msg
))
message
.
ready
()
.
then
(
this
.
onMessage
.
bind
(
this
))
.
catch
(
e
=>
this
.
log
.
error
(
'
IoClient
'
,
'
message.ready() %s
'
,
e
))
})
try
{
try
{
await
wechaty
.
init
()
await
wechaty
.
init
()
...
...
src/message-media.ts
浏览文件 @
8a6d0b14
...
@@ -74,6 +74,7 @@ export class MediaMessage extends Message {
...
@@ -74,6 +74,7 @@ export class MediaMessage extends Message {
default
:
default
:
const
e
=
new
Error
(
'
ready() unsupported typeApp():
'
+
this
.
typeApp
())
const
e
=
new
Error
(
'
ready() unsupported typeApp():
'
+
this
.
typeApp
())
log
.
warn
(
'
MediaMessage
'
,
e
.
message
)
log
.
warn
(
'
MediaMessage
'
,
e
.
message
)
this
.
dumpRaw
()
throw
e
throw
e
}
}
break
break
...
...
src/message.ts
浏览文件 @
8a6d0b14
...
@@ -404,6 +404,11 @@ export class Message implements Sayable {
...
@@ -404,6 +404,11 @@ export class Message implements Sayable {
return
fromId
===
userId
return
fromId
===
userId
}
}
// public ready() {
// log.warn('Message', 'ready() DEPRECATED. use load() instead.')
// return this.ready()
// }
public
async
ready
():
Promise
<
void
>
{
public
async
ready
():
Promise
<
void
>
{
log
.
silly
(
'
Message
'
,
'
ready()
'
)
log
.
silly
(
'
Message
'
,
'
ready()
'
)
...
...
src/room.ts
浏览文件 @
8a6d0b14
...
@@ -71,6 +71,11 @@ export class Room extends EventEmitter implements Sayable {
...
@@ -71,6 +71,11 @@ export class Room extends EventEmitter implements Sayable {
return
!!
(
this
.
obj
&&
this
.
obj
.
memberList
&&
this
.
obj
.
memberList
.
length
)
return
!!
(
this
.
obj
&&
this
.
obj
.
memberList
&&
this
.
obj
.
memberList
.
length
)
}
}
// public refresh() {
// log.warn('Room', 'refresh() DEPRECATED. use reload() instead.')
// return this.reload()
// }
public
async
refresh
():
Promise
<
void
>
{
public
async
refresh
():
Promise
<
void
>
{
if
(
this
.
isReady
())
{
if
(
this
.
isReady
())
{
this
.
dirtyObj
=
this
.
obj
this
.
dirtyObj
=
this
.
obj
...
@@ -80,6 +85,11 @@ export class Room extends EventEmitter implements Sayable {
...
@@ -80,6 +85,11 @@ export class Room extends EventEmitter implements Sayable {
return
return
}
}
// public ready(contactGetter?: (id: string) => Promise<any>) {
// log.warn('Room', 'ready() DEPRECATED. use load() instad.')
// return this.load(contactGetter)
// }
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
any
>
):
Promise
<
void
>
{
public
async
ready
(
contactGetter
?:
(
id
:
string
)
=>
Promise
<
any
>
):
Promise
<
void
>
{
log
.
silly
(
'
Room
'
,
'
ready(%s)
'
,
contactGetter
?
contactGetter
.
constructor
.
name
:
''
)
log
.
silly
(
'
Room
'
,
'
ready(%s)
'
,
contactGetter
?
contactGetter
.
constructor
.
name
:
''
)
if
(
!
this
.
id
)
{
if
(
!
this
.
id
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录