Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
.Veneno.
wechaty
提交
75a4c706
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,发现更多精彩内容 >>
提交
75a4c706
编写于
5月 11, 2018
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clean PuppetMock
上级
9774604b
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
65 addition
and
467 deletion
+65
-467
src/puppet-mock/mock-contact.ts
src/puppet-mock/mock-contact.ts
+0
-219
src/puppet-mock/mock-friend-request.ts
src/puppet-mock/mock-friend-request.ts
+0
-24
src/puppet-mock/mock-message.ts
src/puppet-mock/mock-message.ts
+19
-19
src/puppet-mock/mock-room.ts
src/puppet-mock/mock-room.ts
+0
-157
src/puppet-mock/puppet-mock.ts
src/puppet-mock/puppet-mock.ts
+34
-29
src/puppet/contact.ts
src/puppet/contact.ts
+12
-19
未找到文件。
src/puppet-mock/mock-contact.ts
已删除
100644 → 0
浏览文件 @
9774604b
/**
* Wechaty - https://github.com/chatie/wechaty
*
* @copyright 2016-2018 Huan LI <zixia@zixia.net>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @ignore
*/
import
{
Sayable
,
log
,
}
from
'
../config
'
import
{
Contact
,
ContactType
,
Gender
,
Message
,
}
from
'
../puppet/
'
import
{
MockMessage
}
from
'
./mock-message
'
export
class
MockContact
extends
Contact
implements
Sayable
{
constructor
(
public
readonly
id
:
string
,
)
{
super
(
id
)
log
.
silly
(
'
MockContact
'
,
`constructor(
${
id
}
)`
)
}
public
toString
():
string
{
return
`MockContact<
${
this
.
id
}
>`
}
public
async
say
(
text
:
string
)
:
Promise
<
void
>
public
async
say
(
message
:
MockMessage
):
Promise
<
void
>
public
async
say
(
textOrMessage
:
string
|
MockMessage
,
):
Promise
<
void
>
{
log
.
verbose
(
'
MockContact
'
,
'
say(%s)
'
,
textOrMessage
)
let
msg
if
(
textOrMessage
instanceof
Message
)
{
msg
=
textOrMessage
}
else
{
msg
=
new
MockMessage
()
msg
.
text
(
textOrMessage
)
}
msg
.
from
(
this
.
puppet
.
userSelf
())
msg
.
to
(
this
)
await
this
.
puppet
.
send
(
msg
)
}
public
name
():
string
{
if
(
!
this
.
payload
)
{
throw
new
Error
(
'
no payload
'
)
}
return
this
.
payload
.
name
||
''
}
public
alias
()
:
string
|
null
public
alias
(
newAlias
:
string
):
Promise
<
void
>
public
alias
(
empty
:
null
)
:
Promise
<
void
>
public
alias
(
newAlias
?:
string
|
null
):
Promise
<
void
>
|
string
|
null
{
log
.
verbose
(
'
MockContact
'
,
'
alias(%s)
'
,
newAlias
)
if
(
newAlias
===
undefined
)
{
return
this
.
payload
&&
this
.
payload
.
alias
||
null
}
return
this
.
puppet
.
contactAlias
(
this
,
newAlias
)
}
/**
* @deprecated
*/
public
stranger
():
boolean
|
null
{
if
(
!
this
.
payload
)
{
return
null
}
return
this
.
payload
.
friend
===
undefined
?
null
:
!
(
this
.
payload
.
friend
)
}
public
friend
():
boolean
|
null
{
if
(
!
this
.
payload
)
{
return
null
}
return
this
.
payload
.
friend
===
undefined
?
null
:
this
.
payload
.
friend
}
/**
* @deprecated
*/
public
personal
():
boolean
{
if
(
this
.
type
()
===
ContactType
.
UNKNOWN
)
{
throw
new
Error
(
'
unknown type
'
)
}
return
this
.
type
()
===
Contact
.
Type
.
PERSONAL
}
/**
* @deprecated
*/
public
official
():
boolean
{
if
(
this
.
type
()
===
ContactType
.
UNKNOWN
)
{
throw
new
Error
(
'
unknown type
'
)
}
return
this
.
type
()
===
Contact
.
Type
.
OFFICIAL
}
public
type
():
ContactType
{
if
(
!
this
.
payload
)
{
return
ContactType
.
UNKNOWN
}
return
this
.
payload
.
type
}
public
star
():
boolean
|
null
{
if
(
!
this
.
payload
)
{
return
null
}
return
this
.
payload
.
star
===
undefined
?
null
:
this
.
payload
.
star
}
public
gender
():
Gender
{
if
(
!
this
.
payload
)
{
return
Gender
.
UNKNOWN
}
return
this
.
payload
.
gender
}
public
province
():
string
|
null
{
if
(
!
this
.
payload
)
{
return
null
}
return
this
.
payload
.
province
===
undefined
?
null
:
this
.
payload
.
province
}
public
city
():
string
|
null
{
if
(
!
this
.
payload
)
{
return
null
}
return
this
.
payload
.
city
===
undefined
?
null
:
this
.
payload
.
city
}
public
async
avatar
():
Promise
<
NodeJS
.
ReadableStream
>
{
log
.
verbose
(
'
MockContact
'
,
'
avatar()
'
)
return
this
.
puppet
.
contactAvatar
(
this
)
}
public
isReady
():
boolean
{
return
this
.
payload
!==
undefined
}
/**
* @deprecated use sync() instead
*/
public
async
refresh
():
Promise
<
void
>
{
log
.
verbose
(
'
MockContact
'
,
'
refresh() DEPRECATED use sync instead
'
)
return
this
.
sync
()
}
public
async
sync
():
Promise
<
void
>
{
log
.
verbose
(
'
MockContact
'
,
'
sync()
'
)
this
.
payload
=
undefined
await
this
.
ready
()
}
public
async
ready
():
Promise
<
void
>
{
log
.
verbose
(
'
MockContact
'
,
'
ready()
'
)
if
(
!
this
.
payload
)
{
this
.
payload
=
await
this
.
puppet
.
contactPayload
(
this
)
}
}
public
self
():
boolean
{
const
userSelf
=
this
.
puppet
.
userSelf
()
return
userSelf
.
id
===
this
.
id
}
public
weixin
():
string
|
null
{
if
(
!
this
.
payload
)
{
throw
new
Error
(
'
no payload
'
)
}
return
this
.
payload
.
weixin
||
null
}
}
export
default
MockContact
src/puppet-mock/mock-friend-request.ts
已删除
100644 → 0
浏览文件 @
9774604b
/**
* Wechaty - https://github.com/chatie/wechaty
*
* @copyright 2016-2018 Huan LI <zixia@zixia.net>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* @ignore
*/
import
{
FriendRequest
}
from
'
../puppet/
'
export
class
MockFriendRequest
extends
FriendRequest
{}
export
default
MockFriendRequest
src/puppet-mock/mock-message.ts
浏览文件 @
75a4c706
...
...
@@ -24,10 +24,10 @@ import {
import
{
log
,
}
from
'
../config
'
import
{
Message
}
from
'
../puppet/
'
import
{
Message
}
from
'
../puppet/
message
'
import
{
MockContact
}
from
'
./mock-
contact
'
import
{
MockRoom
}
from
'
./mock-
room
'
import
{
Contact
}
from
'
../puppet/
contact
'
import
{
Room
}
from
'
../puppet/
room
'
import
{
WebMsgType
,
...
...
@@ -38,9 +38,9 @@ export type ParsedPath = Partial<path.ParsedPath>
export
interface
MockMessagePayload
{
text
:
string
,
from
:
Mock
Contact
,
to
?:
Mock
Contact
,
room
?:
Mock
Room
,
from
:
Contact
,
to
?:
Contact
,
room
?:
Room
,
type
:
WebMsgType
,
}
...
...
@@ -63,10 +63,10 @@ export class MockMessage extends Message {
this
.
payload
=
{}
as
MockMessagePayload
}
public
from
(
contact
:
Mock
Contact
)
:
void
public
from
()
:
Mock
Contact
public
from
(
contact
:
Contact
)
:
void
public
from
()
:
Contact
public
from
(
contact
?:
MockContact
):
void
|
Mock
Contact
{
public
from
(
contact
?:
Contact
):
void
|
Contact
{
if
(
contact
)
{
this
.
payload
.
from
=
contact
return
...
...
@@ -75,10 +75,10 @@ export class MockMessage extends Message {
return
this
.
payload
.
from
}
public
to
(
contact
:
Mock
Contact
)
:
void
public
to
()
:
Mock
Contact
|
null
// if no `to` there must be a `room`
public
to
(
contact
:
Contact
)
:
void
public
to
()
:
Contact
|
null
// if no `to` there must be a `room`
public
to
(
contact
?:
MockContact
):
void
|
Mock
Contact
|
null
{
public
to
(
contact
?:
Contact
):
void
|
Contact
|
null
{
if
(
contact
)
{
this
.
payload
.
to
=
contact
return
...
...
@@ -87,10 +87,10 @@ export class MockMessage extends Message {
return
this
.
payload
.
to
||
null
}
public
room
(
room
:
Mock
Room
)
:
void
public
room
()
:
null
|
Mock
Room
public
room
(
room
:
Room
)
:
void
public
room
()
:
null
|
Room
public
room
(
room
?:
MockRoom
):
void
|
null
|
Mock
Room
{
public
room
(
room
?:
Room
):
void
|
null
|
Room
{
if
(
room
)
{
this
.
payload
.
room
=
room
return
...
...
@@ -108,12 +108,12 @@ export class MockMessage extends Message {
return
this
.
payload
.
text
||
''
}
public
async
say
(
text
:
string
,
mention
?:
MockContact
|
Mock
Contact
[]):
Promise
<
void
>
public
async
say
(
text
:
string
,
mention
?:
Contact
|
Contact
[]):
Promise
<
void
>
public
async
say
(
message
:
MockMessage
):
Promise
<
void
>
public
async
say
(
textOrMessage
:
string
|
MockMessage
,
mention
?:
MockContact
|
Mock
Contact
[],
mention
?:
Contact
|
Contact
[],
):
Promise
<
void
>
{
log
.
verbose
(
'
MockMessage
'
,
'
say(%s, %s)
'
,
textOrMessage
,
mention
)
...
...
@@ -148,7 +148,7 @@ export class MockMessage extends Message {
return
fromId
===
userId
}
public
mentioned
():
Mock
Contact
[]
{
public
mentioned
():
Contact
[]
{
return
[]
}
...
...
@@ -180,7 +180,7 @@ export class MockMessage extends Message {
return
'
text/plain
'
}
public
async
forward
(
to
:
MockRoom
|
Mock
Contact
):
Promise
<
void
>
{
public
async
forward
(
to
:
Room
|
Contact
):
Promise
<
void
>
{
/**
* 1. Text message
*/
...
...
src/puppet-mock/mock-room.ts
已删除
100644 → 0
浏览文件 @
9774604b
/**
* Wechaty - https://github.com/chatie/wechaty
*
* @copyright 2016-2018 Huan LI <zixia@zixia.net>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* @ignore
*/
import
{
log
,
}
from
'
../config
'
import
{
Room
,
RoomMemberQueryFilter
,
}
from
'
../puppet/
'
import
{
MockMessage
}
from
'
./mock-message
'
import
{
MockContact
}
from
'
./mock-contact
'
export
class
MockRoom
extends
Room
{
constructor
(
public
id
:
string
,
)
{
super
(
id
)
log
.
silly
(
'
MockRoom
'
,
`constructor(
${
id
}
)`
)
}
public
isReady
():
boolean
{
return
true
}
public
async
sync
():
Promise
<
void
>
{
return
}
public
async
ready
():
Promise
<
void
>
{
return
}
public
say
(
message
:
MockMessage
)
:
Promise
<
void
>
public
say
(
text
:
string
)
:
Promise
<
void
>
public
say
(
text
:
string
,
replyTo
:
MockContact
)
:
Promise
<
void
>
public
say
(
text
:
string
,
replyTo
:
MockContact
[])
:
Promise
<
void
>
public
say
(
text
:
never
,
...
args
:
never
[])
:
Promise
<
never
>
public
async
say
(
textOrMessage
:
string
|
MockMessage
,
replyTo
?:
MockContact
|
MockContact
[]):
Promise
<
void
>
{
log
.
verbose
(
'
MockRoom
'
,
'
say(%s, %s)
'
,
textOrMessage
,
Array
.
isArray
(
replyTo
)
?
replyTo
.
map
(
c
=>
c
.
name
()).
join
(
'
,
'
)
:
replyTo
?
replyTo
.
name
()
:
''
,
)
let
m
m
=
new
MockMessage
()
m
.
puppet
=
this
.
puppet
m
.
room
(
this
)
await
this
.
puppet
.
send
(
m
)
}
public
async
add
(
contact
:
MockContact
):
Promise
<
void
>
{
log
.
verbose
(
'
MockRoom
'
,
'
add(%s)
'
,
contact
)
await
this
.
puppet
.
roomAdd
(
this
,
contact
)
}
public
async
del
(
contact
:
MockContact
):
Promise
<
void
>
{
log
.
verbose
(
'
MockRoom
'
,
'
del(%s)
'
,
contact
.
name
())
await
this
.
puppet
.
roomDel
(
this
,
contact
)
}
public
async
quit
():
Promise
<
void
>
{
return
}
public
topic
()
:
string
public
async
topic
(
newTopic
:
string
):
Promise
<
void
>
public
topic
(
newTopic
?:
string
):
string
|
Promise
<
void
>
{
log
.
verbose
(
'
MockRoom
'
,
'
topic(%s)
'
,
newTopic
?
newTopic
:
''
)
if
(
typeof
newTopic
===
'
undefined
'
)
{
return
'
mock topic
'
}
this
.
puppet
.
roomTopic
(
this
,
newTopic
)
.
catch
(
e
=>
{
log
.
warn
(
'
MockRoom
'
,
'
topic(newTopic=%s) exception: %s
'
,
newTopic
,
e
&&
e
.
message
||
e
,
)
})
return
Promise
.
resolve
()
}
public
alias
(
contact
:
MockContact
):
string
|
null
{
return
this
.
roomAlias
(
contact
)
}
public
roomAlias
(
contact
:
MockContact
):
string
|
null
{
return
'
mock room alias
'
}
public
has
(
contact
:
MockContact
):
boolean
{
return
false
}
public
memberAll
(
filter
:
RoomMemberQueryFilter
)
:
MockContact
[]
public
memberAll
(
name
:
string
)
:
MockContact
[]
public
memberAll
(
queryArg
:
RoomMemberQueryFilter
|
string
):
MockContact
[]
{
return
[]
}
public
member
(
name
:
string
)
:
MockContact
|
null
public
member
(
filter
:
RoomMemberQueryFilter
):
MockContact
|
null
public
member
(
queryArg
:
RoomMemberQueryFilter
|
string
):
MockContact
|
null
{
log
.
verbose
(
'
MockRoom
'
,
'
member(%s)
'
,
JSON
.
stringify
(
queryArg
))
return
null
}
public
memberList
():
MockContact
[]
{
log
.
verbose
(
'
MockRoom
'
,
'
memberList
'
)
return
[]
}
public
static
async
create
(
contactList
:
MockContact
[],
topic
?:
string
):
Promise
<
Room
>
{
log
.
verbose
(
'
MockRoom
'
,
'
create(%s, %s)
'
,
contactList
.
join
(
'
,
'
),
topic
)
const
room
=
await
this
.
puppet
.
roomCreate
(
contactList
,
topic
)
return
room
}
public
async
refresh
():
Promise
<
void
>
{
return
}
public
owner
():
MockContact
|
null
{
log
.
info
(
'
MockRoom
'
,
'
owner()
'
)
return
null
}
}
export
default
MockRoom
src/puppet-mock/puppet-mock.ts
浏览文件 @
75a4c706
...
...
@@ -39,18 +39,19 @@ import {
// import Wechaty from '../wechaty'
import
{
MockContact
,
}
from
'
./mock-contact
'
import
{
MockFriendRequest
}
from
'
./mock-friend-request
'
Contact
,
}
from
'
../puppet/contact
'
import
{
FriendRequest
}
from
'
../puppet/friend-request
'
import
{
Room
}
from
'
../puppet/room
'
import
{
MockMessage
}
from
'
./mock-message
'
import
{
MockRoom
}
from
'
./mock-room
'
export
type
PuppetFoodType
=
'
scan
'
|
'
ding
'
export
type
ScanFoodType
=
'
scan
'
|
'
login
'
|
'
logout
'
export
class
PuppetMock
extends
Puppet
{
private
user
?:
Mock
Contact
private
user
?:
Contact
constructor
(
public
options
:
PuppetOptions
,
...
...
@@ -58,10 +59,10 @@ export class PuppetMock extends Puppet {
super
(
options
,
{
Contact
:
Mock
Contact
,
FriendRequest
:
Mock
FriendRequest
,
Contact
:
Contact
,
FriendRequest
:
FriendRequest
,
Message
:
MockMessage
,
Room
:
Mock
Room
,
Room
:
Room
,
},
)
}
...
...
@@ -81,8 +82,8 @@ export class PuppetMock extends Puppet {
// await some tasks...
this
.
state
.
on
(
true
)
const
from
=
Mock
Contact
.
load
(
'
xxx_from
'
)
const
to
=
Mock
Contact
.
load
(
'
xxx_to
'
)
const
from
=
Contact
.
load
(
'
xxx_from
'
)
const
to
=
Contact
.
load
(
'
xxx_to
'
)
const
msg
=
new
MockMessage
()
msg
.
from
(
from
)
...
...
@@ -121,7 +122,7 @@ export class PuppetMock extends Puppet {
}
}
public
userSelf
():
Mock
Contact
{
public
userSelf
():
Contact
{
log
.
verbose
(
'
PuppetMock
'
,
'
self()
'
)
if
(
!
this
.
user
)
{
...
...
@@ -131,7 +132,7 @@ export class PuppetMock extends Puppet {
return
this
.
user
}
public
async
forward
(
message
:
MockMessage
,
sendTo
:
MockContact
|
Mock
Room
):
Promise
<
void
>
{
public
async
forward
(
message
:
MockMessage
,
sendTo
:
Contact
|
Room
):
Promise
<
void
>
{
log
.
silly
(
'
PuppetMock
'
,
'
forward() to: %s, message: %s)
'
,
sendTo
,
message
.
filename
(),
// patchData.ToUserName,
...
...
@@ -170,26 +171,26 @@ export class PuppetMock extends Puppet {
this
.
user
=
undefined
}
public
contactAlias
(
contact
:
Mock
Contact
)
:
Promise
<
string
>
public
contactAlias
(
contact
:
Mock
Contact
,
alias
:
string
|
null
):
Promise
<
void
>
public
contactAlias
(
contact
:
Contact
)
:
Promise
<
string
>
public
contactAlias
(
contact
:
Contact
,
alias
:
string
|
null
):
Promise
<
void
>
public
async
contactAlias
(
contact
:
Mock
Contact
,
alias
?:
string
|
null
):
Promise
<
void
|
string
>
{
public
async
contactAlias
(
contact
:
Contact
,
alias
?:
string
|
null
):
Promise
<
void
|
string
>
{
if
(
typeof
alias
===
'
undefined
'
)
{
return
'
mock alias
'
}
return
}
public
async
contactFindAll
(
query
:
ContactQueryFilter
):
Promise
<
Mock
Contact
[]
>
{
public
async
contactFindAll
(
query
:
ContactQueryFilter
):
Promise
<
Contact
[]
>
{
return
[]
}
public
async
contactAvatar
(
contact
:
Mock
Contact
):
Promise
<
NodeJS
.
ReadableStream
>
{
public
async
contactAvatar
(
contact
:
Contact
):
Promise
<
NodeJS
.
ReadableStream
>
{
const
WECHATY_ICON_PNG
=
path
.
resolve
(
'
../../docs/images/wechaty-icon.png
'
)
return
fs
.
createReadStream
(
WECHATY_ICON_PNG
)
}
public
async
contactPayload
(
contact
:
Mock
Contact
):
Promise
<
ContactPayload
>
{
public
async
contactPayload
(
contact
:
Contact
):
Promise
<
ContactPayload
>
{
return
{
gender
:
Gender
.
UNKNOWN
,
type
:
ContactType
.
UNKNOWN
,
...
...
@@ -197,7 +198,7 @@ export class PuppetMock extends Puppet {
}
public
async
roomPayload
(
room
:
Mock
Room
):
Promise
<
RoomPayload
>
{
public
async
roomPayload
(
room
:
Room
):
Promise
<
RoomPayload
>
{
return
{
topic
:
'
mock topic
'
,
memberList
:
[],
...
...
@@ -209,45 +210,49 @@ export class PuppetMock extends Puppet {
public
async
roomFindAll
(
query
:
RoomQueryFilter
=
{
topic
:
/.*/
},
):
Promise
<
Mock
Room
[]
>
{
):
Promise
<
Room
[]
>
{
return
[]
}
public
async
roomDel
(
room
:
Mock
Room
,
contact
:
Mock
Contact
,
room
:
Room
,
contact
:
Contact
,
):
Promise
<
void
>
{
//
}
public
async
roomAdd
(
room
:
Mock
Room
,
contact
:
Mock
Contact
,
room
:
Room
,
contact
:
Contact
,
):
Promise
<
void
>
{
//
}
public
async
roomTopic
(
room
:
Mock
Room
,
topic
?:
string
):
Promise
<
void
|
string
>
{
public
async
roomTopic
(
room
:
Room
,
topic
?:
string
):
Promise
<
void
|
string
>
{
if
(
typeof
topic
===
'
undefined
'
)
{
return
'
mock room topic
'
}
return
}
public
async
roomCreate
(
contactList
:
MockContact
[],
topic
:
string
):
Promise
<
Mock
Room
>
{
public
async
roomCreate
(
contactList
:
Contact
[],
topic
:
string
):
Promise
<
Room
>
{
if
(
!
contactList
||
!
contactList
.
map
)
{
throw
new
Error
(
'
contactList not found
'
)
}
const
r
=
MockRoom
.
load
(
'
mock room id
'
)
as
Mock
Room
const
r
=
Room
.
load
(
'
mock room id
'
)
as
Room
r
.
puppet
=
this
return
r
}
public
async
friendRequestSend
(
contact
:
MockContact
,
hello
:
string
):
Promise
<
void
>
{
public
async
roomQuit
(
room
:
Room
):
Promise
<
void
>
{
//
}
public
async
friendRequestSend
(
contact
:
Contact
,
hello
:
string
):
Promise
<
void
>
{
//
}
public
async
friendRequestAccept
(
contact
:
Mock
Contact
,
ticket
:
string
):
Promise
<
void
>
{
public
async
friendRequestAccept
(
contact
:
Contact
,
ticket
:
string
):
Promise
<
void
>
{
//
}
...
...
src/puppet/contact.ts
浏览文件 @
75a4c706
...
...
@@ -240,31 +240,24 @@ export class Contact extends PuppetAccessory implements Sayable {
public
async
say
(
textOrMessage
:
string
|
Message
):
Promise
<
void
>
{
log
.
verbose
(
'
Contact
'
,
'
say(%s)
'
,
textOrMessage
)
const
user
=
this
.
puppet
.
userSelf
()
as
Contact
if
(
!
user
)
{
throw
new
Error
(
'
no user
'
)
}
let
m
if
(
typeof
textOrMessage
===
'
string
'
)
{
m
=
new
PuppeteerMessage
()
m
.
puppet
=
this
.
puppet
m
.
text
(
textOrMessage
)
}
else
if
(
textOrMessage
instanceof
Message
)
{
m
=
textOrMessage
let
msg
if
(
textOrMessage
instanceof
Message
)
{
msg
=
textOrMessage
}
else
{
throw
new
Error
(
'
not support args
'
)
msg
=
new
PuppeteerMessage
()
msg
.
puppet
=
this
.
puppet
msg
.
text
(
textOrMessage
)
}
m
.
from
(
user
)
m
.
to
(
this
)
msg
.
from
(
this
.
puppet
.
userSelf
())
msg
.
to
(
this
)
log
.
silly
(
'
Contact
'
,
'
say() from: %s to: %s content: %s
'
,
user
,
this
.
puppet
.
userSelf
()
,
this
,
textOrMessage
,
msg
,
)
await
this
.
puppet
.
send
(
m
)
await
this
.
puppet
.
send
(
m
sg
)
}
/**
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录