Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
b440563f
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,发现更多精彩内容 >>
提交
b440563f
编写于
6月 13, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix all room event unit tests
上级
e69f1eb6
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
45 addition
and
18 deletion
+45
-18
src/puppet-padchat/padchat-rpc.ts
src/puppet-padchat/padchat-rpc.ts
+8
-2
src/puppet-padchat/pure-function-helpers/is-type.ts
src/puppet-padchat/pure-function-helpers/is-type.ts
+10
-5
src/puppet-padchat/pure-function-helpers/room-event-message-parser.join.en.spec.ts
...unction-helpers/room-event-message-parser.join.en.spec.ts
+2
-2
src/puppet-padchat/pure-function-helpers/room-event-message-parser.join.zh.spec.ts
...unction-helpers/room-event-message-parser.join.zh.spec.ts
+4
-4
src/puppet-padchat/pure-function-helpers/room-event-message-parser.spec.ts
...t/pure-function-helpers/room-event-message-parser.spec.ts
+2
-2
src/puppet-padchat/pure-function-helpers/room-event-message-parser.ts
...adchat/pure-function-helpers/room-event-message-parser.ts
+19
-3
未找到文件。
src/puppet-padchat/padchat-rpc.ts
浏览文件 @
b440563f
...
...
@@ -324,7 +324,7 @@ export class PadchatRpc extends EventEmitter {
private
async
rpcCall
(
apiName
:
string
,
...
params
:
(
string
|
WXSearchContactTypeStatus
)
[]
...
params
:
string
[]
):
Promise
<
any
>
{
log
.
silly
(
'
PadchatRpc
'
,
'
rpcCall(%s, %s)
'
,
apiName
,
JSON
.
stringify
(
params
).
substr
(
0
,
500
))
return
await
this
.
jsonRpc
.
request
(
apiName
,
params
)
...
...
@@ -851,7 +851,13 @@ export class PadchatRpc extends EventEmitter {
}
public
async
WXAddUser
(
strangerV1
:
string
,
strangerV2
:
string
,
type
:
WXSearchContactTypeStatus
,
verify
:
string
):
Promise
<
any
>
{
const
result
=
await
this
.
rpcCall
(
'
WXAddUser
'
,
strangerV1
,
strangerV2
,
type
,
verify
)
const
result
=
await
this
.
rpcCall
(
'
WXAddUser
'
,
strangerV1
,
strangerV2
,
String
(
type
),
verify
,
)
log
.
silly
(
'
PadchatRpc
'
,
'
WXAddUser result: %s
'
,
JSON
.
stringify
(
result
))
return
result
}
...
...
src/puppet-padchat/pure-function-helpers/is-type.ts
浏览文件 @
b440563f
export
function
isRoomId
(
id
?:
string
):
boolean
{
if
(
!
id
)
{
throw
new
Error
(
'
no id
'
)
// throw new Error('no id')
return
false
}
return
/@chatroom$/
.
test
(
id
)
}
export
function
isContactId
(
id
?:
string
):
boolean
{
if
(
!
id
)
{
throw
new
Error
(
'
no id
'
)
return
false
// throw new Error('no id')
}
return
!
isRoomId
(
id
)
}
export
function
isContactOfficialId
(
id
?:
string
):
boolean
{
if
(
!
id
)
{
throw
new
Error
(
'
no id
'
)
return
false
// throw new Error('no id')
}
return
/^gh_/i
.
test
(
id
)
}
export
function
isStrangerV1
(
strangerId
?:
string
):
boolean
{
if
(
!
strangerId
)
{
throw
new
Error
(
'
no id
'
)
return
false
// throw new Error('no id')
}
return
/^v1_/i
.
test
(
strangerId
)
}
export
function
isStrangerV2
(
strangerId
?:
string
):
boolean
{
if
(
!
strangerId
)
{
throw
new
Error
(
'
no id
'
)
return
false
// throw new Error('no id')
}
return
/^v2_/i
.
test
(
strangerId
)
}
...
...
src/puppet-padchat/pure-function-helpers/room-event-message-parser.join.en.spec.ts
浏览文件 @
b440563f
...
...
@@ -141,8 +141,8 @@ test('roomJoinEventMessageParser() EN-bot-invite-other', async t => {
t
.
deepEqual
(
event
,
EXPECTED_EVENT
,
'
should parse event
'
)
})
test
(
'
roomJoinEventMessageParser() EN-bot-invite-
others
'
,
async
t
=>
{
t
.
skip
(
'
should be the same as the bot-invite-
other
'
)
test
(
'
roomJoinEventMessageParser() EN-bot-invite-
many
'
,
async
t
=>
{
t
.
skip
(
'
should be the same as the bot-invite-
many
'
)
})
test
(
'
roomJoinEventMessageParser() EN-room-create
'
,
async
t
=>
{
...
...
src/puppet-padchat/pure-function-helpers/room-event-message-parser.join.zh.spec.ts
浏览文件 @
b440563f
...
...
@@ -38,7 +38,7 @@ test('roomJoinEventMessageParser() ZH-other-invite-other', async t => {
}
const
event
=
roomJoinEventMessageParser
(
MESSAGE_PAYLOAD
)
console
.
log
(
'
payload:
'
,
event
)
//
console.log('payload:', event)
t
.
deepEqual
(
event
,
EXPECTED_EVENT
,
'
should parse room join message payload
'
)
})
...
...
@@ -72,7 +72,7 @@ test('roomJoinEventMessageParser() ZH-other-invite-bot', async t => {
t
.
deepEqual
(
event
,
EXPECTED_EVENT
,
'
should parse event
'
)
})
test
(
'
roomJoinEventMessageParser() ZH-other-invite-bot-with-other
s
'
,
async
t
=>
{
test
(
'
roomJoinEventMessageParser() ZH-other-invite-bot-with-other
'
,
async
t
=>
{
const
MESSAGE_PAYLOAD
:
PadchatMessagePayload
=
{
content
:
'
"李卓桓"邀请你和"Huan LI++"加入了群聊
'
,
continue
:
1
,
...
...
@@ -97,7 +97,7 @@ test('roomJoinEventMessageParser() ZH-other-invite-bot-with-others', async t =>
t
.
deepEqual
(
event
,
EXPECTED_EVENT
,
'
should parse event
'
)
})
test
(
'
roomJoinEventMessageParser() ZH-bot-invite-o
ther
'
,
async
t
=>
{
test
(
'
roomJoinEventMessageParser() ZH-bot-invite-o
ne
'
,
async
t
=>
{
const
MESSAGE_PAYLOAD
:
PadchatMessagePayload
=
{
content
:
'
5354656522@chatroom:
\n
<sysmsg type="delchatroommember">
\n\t
<delchatroommember>
\n\t\t
<plain><![CDATA[你邀请"Huan LI++"加入了群聊 ]]></plain>
\n\t\t
<text><![CDATA[你邀请"Huan LI++"加入了群聊 ]]></text>
\n\t\t
<link>
\n\t\t\t
<scene>invite</scene>
\n\t\t\t
<text><![CDATA[ 撤销]]></text>
\n\t\t\t
<memberlist>
\n\t\t\t\t
<username><![CDATA[wxid_5zj4i5htp9ih22]]></username>
\n\t\t\t
</memberlist>
\n\t\t
</link>
\n\t
</delchatroommember>
\n
</sysmsg>
\n
'
,
continue
:
1
,
...
...
@@ -122,7 +122,7 @@ test('roomJoinEventMessageParser() ZH-bot-invite-other', async t => {
t
.
deepEqual
(
event
,
EXPECTED_EVENT
,
'
should parse event
'
)
})
test
(
'
roomJoinEventMessageParser() ZH-bot-invite-
others
'
,
async
t
=>
{
test
(
'
roomJoinEventMessageParser() ZH-bot-invite-
three
'
,
async
t
=>
{
t
.
skip
(
'
tbw
'
)
})
...
...
src/puppet-padchat/pure-function-helpers/room-event-message-parser.spec.ts
浏览文件 @
b440563f
...
...
@@ -122,7 +122,7 @@ test('splitChineseNameList()', async t => {
const
EXPECTED_LIST
=
[
'
李卓桓
'
,
'
李佳芮
'
,
'
桔小秘
'
]
const
list
=
splitChineseNameList
(
TEXT
)
t
.
e
qual
(
list
,
EXPECTED_LIST
,
'
should split chinese name list
'
)
t
.
deepE
qual
(
list
,
EXPECTED_LIST
,
'
should split chinese name list
'
)
})
test
(
'
splitEnglihshNameList()
'
,
async
t
=>
{
...
...
@@ -130,5 +130,5 @@ test('splitEnglihshNameList()', async t => {
const
EXPECTED_LIST
=
[
'
Zhuohuan
'
,
'
李佳芮
'
,
'
太阁_传话助手
'
]
const
list
=
splitEnglishNameList
(
TEXT
)
t
.
e
qual
(
list
,
EXPECTED_LIST
,
'
should split english name list
'
)
t
.
deepE
qual
(
list
,
EXPECTED_LIST
,
'
should split english name list
'
)
})
src/puppet-padchat/pure-function-helpers/room-event-message-parser.ts
浏览文件 @
b440563f
...
...
@@ -85,11 +85,27 @@ export function roomJoinEventMessageParser(
* when the message is a Recalled type, bot can undo the invitation
*/
if
(
rawPayload
.
sub_type
===
PadchatMessageType
.
Recalled
)
{
/**
* content:
* ```
* 3453262102@chatroom:
* <sysmsg type="delchatroommember">
* ...
* </sysmsg>
* ```
*/
const
tryXmlText
=
content
.
replace
(
/^
[^\n]
+
\n
/
,
''
)
interface
XmlSchema
{
sysmsg
:
{
type
:
string
,
delchatroommember
:
{
plain
:
string
,
text
:
string
,
},
}
}
const
jsonPayload
=
toJson
(
conten
t
,
{
object
:
true
})
as
XmlSchema
content
=
jsonPayload
.
plain
const
jsonPayload
=
toJson
(
tryXmlTex
t
,
{
object
:
true
})
as
XmlSchema
content
=
jsonPayload
.
sysmsg
.
delchatroommember
.
plain
}
let
matchesForBotInviteOtherEn
=
null
as
null
|
string
[]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录