Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
weixin_46011646
wechaty
提交
7c3360ff
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,发现更多精彩内容 >>
提交
7c3360ff
编写于
6月 11, 2020
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Support say(message)
上级
8d0be487
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
47 addition
and
14 deletion
+47
-14
src/user/contact.ts
src/user/contact.ts
+12
-5
src/user/message.ts
src/user/message.ts
+24
-8
src/user/room.ts
src/user/room.ts
+11
-1
未找到文件。
src/user/contact.ts
浏览文件 @
7c3360ff
...
...
@@ -320,11 +320,12 @@ export class Contact extends Accessory implements Sayable {
return
`Contact<
${
identity
}
>`
}
public
async
say
(
text
:
string
)
:
Promise
<
void
|
Message
>
public
async
say
(
contact
:
Contact
)
:
Promise
<
void
|
Message
>
public
async
say
(
file
:
FileBox
)
:
Promise
<
void
|
Message
>
public
async
say
(
mini
:
MiniProgram
)
:
Promise
<
void
|
Message
>
public
async
say
(
url
:
UrlLink
)
:
Promise
<
void
|
Message
>
public
say
(
text
:
string
)
:
Promise
<
void
|
Message
>
public
say
(
message
:
Message
)
:
Promise
<
void
|
Message
>
public
say
(
contact
:
Contact
)
:
Promise
<
void
|
Message
>
public
say
(
file
:
FileBox
)
:
Promise
<
void
|
Message
>
public
say
(
mini
:
MiniProgram
)
:
Promise
<
void
|
Message
>
public
say
(
url
:
UrlLink
)
:
Promise
<
void
|
Message
>
/**
* > Tips:
...
...
@@ -385,12 +386,18 @@ export class Contact extends Accessory implements Sayable {
*/
public
async
say
(
something
:
string
|
Message
|
Contact
|
FileBox
|
MiniProgram
|
UrlLink
):
Promise
<
void
|
Message
>
{
log
.
verbose
(
'
Contact
'
,
'
say(%s)
'
,
something
)
if
(
something
instanceof
Message
)
{
return
something
.
forward
(
this
)
}
let
msgId
:
string
|
void
if
(
typeof
something
===
'
string
'
)
{
/**
...
...
src/user/message.ts
浏览文件 @
7c3360ff
...
...
@@ -416,13 +416,14 @@ export class Message extends Accessory implements Sayable {
}
}
public
async
say
(
text
:
string
,
mention
?:
Contact
|
Contact
[])
:
Promise
<
void
|
Message
>
public
async
say
(
contact
:
Contact
)
:
Promise
<
void
|
Message
>
public
async
say
(
file
:
FileBox
)
:
Promise
<
void
|
Message
>
public
async
say
(
url
:
UrlLink
)
:
Promise
<
void
|
Message
>
public
async
say
(
mini
:
MiniProgram
)
:
Promise
<
void
|
Message
>
public
async
say
(...
args
:
never
[]):
Promise
<
never
>
public
say
(
text
:
string
,
mention
?:
Contact
|
Contact
[])
:
Promise
<
void
|
Message
>
public
say
(
message
:
Message
)
:
Promise
<
void
|
Message
>
public
say
(
contact
:
Contact
)
:
Promise
<
void
|
Message
>
public
say
(
file
:
FileBox
)
:
Promise
<
void
|
Message
>
public
say
(
url
:
UrlLink
)
:
Promise
<
void
|
Message
>
public
say
(
mini
:
MiniProgram
)
:
Promise
<
void
|
Message
>
public
say
(...
args
:
never
[]):
Promise
<
never
>
/**
* Reply a Text or Media File message to the sender.
* > Tips:
...
...
@@ -501,7 +502,12 @@ export class Message extends Accessory implements Sayable {
* .start()
*/
public
async
say
(
textOrContactOrFileOrUrlOrMini
:
string
|
Contact
|
FileBox
|
UrlLink
|
MiniProgram
,
textOrContactOrFileOrUrlOrMini
:
string
|
Message
|
Contact
|
FileBox
|
UrlLink
|
MiniProgram
,
):
Promise
<
void
|
Message
>
{
log
.
verbose
(
'
Message
'
,
'
say(%s)
'
,
textOrContactOrFileOrUrlOrMini
)
...
...
@@ -511,14 +517,24 @@ export class Message extends Accessory implements Sayable {
const
room
=
this
.
room
()
let
conversationId
:
string
let
conversation
if
(
room
)
{
conversation
=
room
conversationId
=
room
.
id
}
else
if
(
from
)
{
conversation
=
from
conversationId
=
from
.
id
}
else
{
throw
new
Error
(
'
neither room nor from?
'
)
}
/**
* Support say a existing message: just forward it.
*/
if
(
textOrContactOrFileOrUrlOrMini
instanceof
Message
)
{
return
textOrContactOrFileOrUrlOrMini
.
forward
(
conversation
)
}
let
msgId
:
void
|
string
if
(
typeof
textOrContactOrFileOrUrlOrMini
===
'
string
'
)
{
/**
...
...
src/user/room.ts
浏览文件 @
7c3360ff
...
...
@@ -378,6 +378,7 @@ export class Room extends Accessory implements Sayable {
}
public
say
(
text
:
string
)
:
Promise
<
void
|
Message
>
public
say
(
message
:
Message
)
:
Promise
<
void
|
Message
>
public
say
(
text
:
string
,
...
mentionList
:
Contact
[])
:
Promise
<
void
|
Message
>
public
say
(
textList
:
TemplateStringsArray
,
...
varList
:
any
[])
:
Promise
<
void
|
Message
>
public
say
(
file
:
FileBox
)
:
Promise
<
void
|
Message
>
...
...
@@ -458,6 +459,7 @@ export class Room extends Accessory implements Sayable {
*/
public
async
say
(
something
:
string
|
Message
|
Contact
|
FileBox
|
MiniProgram
...
...
@@ -474,12 +476,20 @@ export class Room extends Accessory implements Sayable {
let
text
:
string
let
msgId
:
string
|
void
if
(
something
instanceof
Message
)
{
return
something
.
forward
(
this
)
}
function
isTemplateStringArray
(
tsa
:
any
):
tsa
is
TemplateStringsArray
{
return
tsa
instanceof
Array
}
/**
*
* 0. TemplateStringArray
*
*/
if
(
something
instanceof
Array
)
{
if
(
isTemplateStringArray
(
something
)
)
{
const
msgId
=
await
this
.
sayTemplateStringsArray
(
something
as
TemplateStringsArray
,
...
varList
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录