Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
aee56601
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,发现更多精彩内容 >>
提交
aee56601
编写于
10月 05, 2016
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code clean
上级
df268dd9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
15 addition
and
16 deletion
+15
-16
example/api-ai-bot.js
example/api-ai-bot.js
+1
-1
example/ding-dong-bot.js
example/ding-dong-bot.js
+1
-1
src/contact.js
src/contact.js
+2
-2
src/io-client.js
src/io-client.js
+7
-7
src/message.js
src/message.js
+2
-2
src/puppet-web/event.js
src/puppet-web/event.js
+2
-3
未找到文件。
example/api-ai-bot.js
浏览文件 @
aee56601
...
...
@@ -52,7 +52,7 @@ bot
const
msg
=
yield
m
.
ready
()
const
room
=
Wechaty
.
Room
.
load
(
m
.
room
())
if
(
room
&&
/Wechaty/i
.
test
(
room
.
name
()))
{
if
(
room
&&
/Wechaty/i
.
test
(
room
.
topic
()))
{
log
.
info
(
'
Bot
'
,
'
talk: %s
'
,
msg
)
talk
(
m
)
}
else
{
...
...
example/ding-dong-bot.js
浏览文件 @
aee56601
...
...
@@ -48,7 +48,7 @@ bot
const
room
=
m
.
room
()
const
from
=
m
.
from
()
console
.
log
((
room
?
'
[
'
+
room
.
name
()
+
'
]
'
:
''
)
console
.
log
((
room
?
'
[
'
+
room
.
topic
()
+
'
]
'
:
''
)
+
'
<
'
+
from
.
name
()
+
'
>
'
+
'
:
'
+
m
.
toStringDigest
()
)
...
...
src/contact.js
浏览文件 @
aee56601
...
...
@@ -26,7 +26,7 @@ class Contact {
parse
(
rawObj
)
{
return
!
rawObj
?
{}
:
{
id
:
rawObj
.
UserName
,
uin
:
rawObj
.
Uin
// stable id
?
4763975 || getCookie("wxuin")
,
uin
:
rawObj
.
Uin
// stable id
:
4763975 || getCookie("wxuin")
,
weixin
:
rawObj
.
Alias
// Wechat ID
,
name
:
rawObj
.
NickName
,
remark
:
rawObj
.
RemarkName
...
...
@@ -105,7 +105,7 @@ Contact.init()
Contact
.
load
=
function
(
id
)
{
if
(
!
id
||
typeof
id
!==
'
string
'
)
{
throw
new
Error
(
'
id must be string
'
)
return
null
}
if
(
!
(
id
in
Contact
.
pool
))
{
...
...
src/io-client.js
浏览文件 @
aee56601
...
...
@@ -135,7 +135,7 @@ class IoClient {
}
const
wechaty
=
this
.
wechaty
const
io
=
new
Io
({
wechaty
,
token
:
this
.
token
()
...
...
@@ -174,7 +174,7 @@ class IoClient {
const
room
=
m
.
room
()
// this.log.info('Bot', '%s<%s>:%s'
// , (room ? '['+room.
name
()+']' : '')
// , (room ? '['+room.
topic
()+']' : '')
// , from.name()
// , m.toStringDigest()
// )
...
...
@@ -196,10 +196,10 @@ class IoClient {
this
.
log
.
warn
(
'
IoClient
'
,
'
start() with a pending state, not the time
'
)
return
Promise
.
reject
(
'
pending
'
)
}
this
.
targetState
(
'
connected
'
)
this
.
currentState
(
'
connecting
'
)
return
this
.
initIo
(
this
.
wechaty
)
.
then
(
io
=>
{
this
.
io
=
io
...
...
@@ -252,7 +252,7 @@ class IoClient {
quit
()
{
this
.
log
.
verbose
(
'
IoClient
'
,
'
quit()
'
)
if
(
this
.
currentState
()
===
'
disconnecting
'
)
{
this
.
log
.
warn
(
'
IoClient
'
,
'
quit() with currentState() = `disconnecting`, skipped
'
)
return
Promise
.
reject
(
'
quit() with currentState = `disconnecting`
'
)
...
...
@@ -270,13 +270,13 @@ class IoClient {
if
(
this
.
io
)
{
yield
this
.
io
.
quit
()
this
.
io
=
null
this
.
io
=
null
}
else
{
this
.
log
.
warn
(
'
IoClient
'
,
'
quit() no this.io
'
)
}
this
.
currentState
(
'
disconnected
'
)
}).
catch
(
e
=>
{
this
.
log
.
error
(
'
IoClient
'
,
'
exception: %s
'
,
e
.
message
)
// XXX fail safe?
this
.
currentState
(
'
disconnected
'
)
...
...
src/message.js
浏览文件 @
aee56601
...
...
@@ -83,9 +83,9 @@ class Message {
}
from
()
{
return
Contact
.
load
(
this
.
obj
.
from
)
}
to
()
{
return
Contact
.
load
(
this
.
obj
.
to
)
}
to
()
{
return
this
.
obj
.
to
?
Contact
.
load
(
this
.
obj
.
to
)
:
null
}
content
()
{
return
this
.
obj
.
content
}
room
()
{
return
Room
.
load
(
this
.
obj
.
room
)
}
room
()
{
return
this
.
obj
.
room
?
Room
.
load
(
this
.
obj
.
room
)
:
null
}
type
()
{
return
this
.
obj
.
type
}
typeEx
()
{
return
Message
.
Type
[
this
.
obj
.
type
]
}
...
...
src/puppet-web/event.js
浏览文件 @
aee56601
...
...
@@ -346,8 +346,7 @@ function onServerMessage(data) {
const
request
=
new
FriendRequest
()
request
.
receive
(
data
.
RecommendInfo
)
const
contact
=
Contact
.
load
(
request
.
contactId
)
this
.
emit
(
'
friend
'
,
contact
,
request
)
this
.
emit
(
'
friend
'
,
request
.
contact
,
request
)
break
case
Message
.
Type
.
SYS
:
...
...
@@ -358,7 +357,7 @@ function onServerMessage(data) {
/**
* try to find FriendRequest Confirmation Message
*/
if
(
/^You have added
(
.+
)
as your WeChat contact. Start chatting!$/
.
test
(
m
.
get
(
'
content
'
)))
{
if
(
/^You have added
(
.+
)
as your WeChat contact. Start chatting!$/
.
test
(
m
.
get
(
'
content
'
)))
{
const
request
=
new
FriendRequest
()
const
contact
=
Contact
.
load
(
m
.
get
(
'
from
'
))
request
.
confirm
(
contact
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录