Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wechaty
wechaty
提交
d3753fee
W
wechaty
项目概览
wechaty
/
wechaty
上一次同步 接近 3 年
通知
298
Star
10499
Fork
6
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
152
列表
看板
标记
里程碑
合并请求
1
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
W
wechaty
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
152
Issue
152
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d3753fee
编写于
6月 07, 2021
作者:
Huan (李卓桓)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade docs
上级
a7c2089a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
47 addition
and
20 deletion
+47
-20
docs/index.md
docs/index.md
+47
-20
未找到文件。
docs/index.md
浏览文件 @
d3753fee
# Wechaty v0.
48.2
Documentation
# Wechaty v0.
62.1
Documentation
-
Website -
<https://wechaty.js.org>
-
Docs Site -
<https://wechaty.js.org/docs/>
...
...
@@ -384,7 +384,8 @@ All WeChat rooms(groups) will be encapsulated as a Room.
*
[
.sync()
](
#Room+sync
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.say(textOrContactOrFileOrUrlOrMini, [mention])
](
#Room+say
)
⇒
<code>
Promise.
<
(void\|Message)
>
</code>
*
[
.add(contact)
](
#Room+add
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.del(contact)
](
#Room+del
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.remove(contact)
](
#Room+remove
)
⇒
<code>
Promise.
<
void
>
</code>
*
~~
[
.del()
](
#Room+del
)
~~
*
[
.quit()
](
#Room+quit
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.topic([newTopic])
](
#Room+topic
)
⇒
<code>
Promise.
<
(string\|void)
>
</code>
*
[
.announce([text])
](
#Room+announce
)
⇒
<code>
Promise.
<
(void\|string)
>
</code>
...
...
@@ -515,10 +516,10 @@ if (room) {
}
}
```
<a
name=
"Room+
del
"
></a>
<a
name=
"Room+
remove
"
></a>
### room.
del
(contact) ⇒ <code>Promise.<void></code>
Delet
e a contact from the room
### room.
remove
(contact) ⇒ <code>Promise.<void></code>
Remov
e a contact from the room
It works only when the bot is the owner of the room
> Tips:
...
...
@@ -541,12 +542,18 @@ const room = await bot.Room.find({topic: 'WeChat'}) // change 'WeChat'
const
contact
=
await
bot
.
Contact
.
find
({
name
:
'
lijiarui
'
})
// change 'lijiarui' to any room member in the room you just set
if
(
room
)
{
try
{
await
room
.
del
(
contact
)
await
room
.
remove
(
contact
)
}
catch
(
e
)
{
console
.
error
(
e
)
}
}
```
<a
name=
"Room+del"
></a>
### ~~room.del()~~
***Deprecated**
*
**Kind**
: instance method of
[
<code>Room</code>
](
#Room
)
<a
name=
"Room+quit"
></a>
### room.quit() ⇒ <code>Promise.<void></code>
...
...
@@ -1258,7 +1265,7 @@ Send, receive friend request, and friend confirmation events.
*
[
.toJSON()
](
#Friendship+toJSON
)
⇒
<code>
FriendshipPayload
</code>
*
_static_
*
[
.search(condition)
](
#Friendship.search
)
⇒
[
<code>Promise.<Contact></code>
](
#Contact
)
*
[
.add(contact,
hello
)
](
#Friendship.add
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.add(contact,
options
)
](
#Friendship.add
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.fromJSON()
](
#Friendship.fromJSON
)
<a
name=
"Friendship+accept"
></a>
...
...
@@ -1380,7 +1387,7 @@ bot.on('friendship', async friendship => {
Search a Friend by phone or weixin.
The best practice is to search friend request once per minute.
Remeber not to do this too frequently, or your account may be blocked.
Reme
m
ber not to do this too frequently, or your account may be blocked.
**Kind**
: static method of
[
<code>Friendship</code>
](
#Friendship
)
...
...
@@ -1398,7 +1405,7 @@ await bot.Friendship.add(friend_phone, 'hello')
```
<a
name=
"Friendship.add"
></a>
### Friendship.add(contact,
hello
) ⇒ <code>Promise.<void></code>
### Friendship.add(contact,
options
) ⇒ <code>Promise.<void></code>
Send a Friend Request to a
`contact`
with message
`hello`
.
The best practice is to send friend request once per minute.
...
...
@@ -1409,13 +1416,19 @@ Remeber not to do this too frequently, or your account may be blocked.
| Param | Type | Description |
| --- | --- | --- |
| contact |
[
<code>Contact</code>
](
#Contact
)
| Send friend request to contact |
|
hello |
<code>
string
</code>
| The friend request content |
|
options |
<code>
FriendshipAddOptions
</code>
| The friend request content |
**Example**
```
js
const
contact
=
await
bot
.
Friendship
.
search
({
phone
:
'
13112341234
'
})
await
bot
.
Friendship
.
add
(
contact
,
'
Nice to meet you! I am wechaty bot!
'
)
const
memberList
=
await
room
.
memberList
()
for
(
let
i
=
0
;
i
<
memberList
.
length
;
i
++
)
{
await
bot
.
Friendship
.
add
(
member
,
'
Nice to meet you! I am wechaty bot!
'
)
await
bot
.
Friendship
.
add
(
member
,
{
room
:
room
,
hello
:
`Nice to meet you! I am wechaty bot from room:
${
await
room
.
topic
()}
!`
,
})
}
```
<a
name=
"Friendship.fromJSON"
></a>
...
...
@@ -1444,7 +1457,8 @@ All wechat messages will be encapsulated as a Message.
*
[
Message
](
#Message
)
*
_instance_
*
[
.from()
](
#Message+from
)
⇒
[
<code>Contact</code>
](
#Contact
)
*
[
.talker()
](
#Message+talker
)
⇒
[
<code>Contact</code>
](
#Contact
)
*
[
.from()
](
#Message+from
)
*
[
.to()
](
#Message+to
)
⇒
[
<code>Contact</code>
](
#Contact
)
\|
<code>
null
</code>
*
[
.room()
](
#Message+room
)
⇒
[
<code>Room</code>
](
#Room
)
\|
<code>
null
</code>
*
[
.text()
](
#Message+text
)
⇒
<code>
string
</code>
...
...
@@ -1454,6 +1468,7 @@ All wechat messages will be encapsulated as a Message.
*
[
.type()
](
#Message+type
)
⇒
<code>
MessageType
</code>
*
[
.self()
](
#Message+self
)
⇒
<code>
boolean
</code>
*
[
.mentionList()
](
#Message+mentionList
)
⇒
<code>
Promise.
<
Array.
<
Contact
>>
</code>
*
~~
[
.mention()
](
#Message+mention
)
~~
*
[
.mentionSelf()
](
#Message+mentionSelf
)
⇒
<code>
Promise.
<
boolean
>
</code>
*
[
.forward(to)
](
#Message+forward
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.date()
](
#Message+date
)
...
...
@@ -1465,10 +1480,10 @@ All wechat messages will be encapsulated as a Message.
*
[
.find()
](
#Message.find
)
*
[
.findAll()
](
#Message.findAll
)
<a
name=
"Message+
from
"
></a>
<a
name=
"Message+
talker
"
></a>
### message.
from
() ⇒ [<code>Contact</code>](#Contact)
Get the
sender from
a message.
### message.
talker
() ⇒ [<code>Contact</code>](#Contact)
Get the
talker of
a message.
**Kind**
: instance method of
[
<code>Message</code>
](
#Message
)
**Example**
...
...
@@ -1476,18 +1491,24 @@ Get the sender from a message.
const
bot
=
new
Wechaty
()
bot
.
on
(
'
message
'
,
async
m
=>
{
const
contact
=
msg
.
from
()
const
talker
=
msg
.
talker
()
const
text
=
msg
.
text
()
const
room
=
msg
.
room
()
if
(
room
)
{
const
topic
=
await
room
.
topic
()
console
.
log
(
`Room:
${
topic
}
Contact:
${
contact
.
name
()}
Text:
${
text
}
`
)
console
.
log
(
`Room:
${
topic
}
Contact:
${
talker
.
name
()}
Text:
${
text
}
`
)
}
else
{
console
.
log
(
`Contact:
${
contact
.
name
()}
Text:
${
text
}
`
)
console
.
log
(
`Contact:
${
talker
.
name
()}
Text:
${
text
}
`
)
}
})
.
start
()
```
<a
name=
"Message+from"
></a>
### message.from()
**Kind**
: instance method of
[
<code>Message</code>
](
#Message
)
**Depreacated**
: Use
`message.talker()`
to replace
`message.from()`
https://github.com/wechaty/wechaty/issues/2094
<a
name=
"Message+to"
></a>
### message.to() ⇒ [<code>Contact</code>](#Contact) \| <code>null</code>
...
...
@@ -1715,6 +1736,12 @@ Message event table as follows
const
contactList
=
await
message
.
mentionList
()
console
.
log
(
contactList
)
```
<a
name=
"Message+mention"
></a>
### ~~message.mention()~~
***Deprecated**
*
**Kind**
: instance method of
[
<code>Message</code>
](
#Message
)
<a
name=
"Message+mentionSelf"
></a>
### message.mentionSelf() ⇒ <code>Promise.<boolean></code>
...
...
@@ -1830,7 +1857,7 @@ accept room invitation
*
_instance_
*
[
.accept()
](
#RoomInvitation+accept
)
⇒
<code>
Promise.
<
void
>
</code>
*
[
.inviter()
](
#RoomInvitation+inviter
)
⇒
[
<code>Contact</code>
](
#Contact
)
*
[
.topic()
](
#RoomInvitation+topic
)
⇒
[
<code>Contact</code>
](
#Contact
)
*
[
.topic()
](
#RoomInvitation+topic
)
⇒
<code>
string
</code>
*
[
.date()
](
#RoomInvitation+date
)
⇒
<code>
Promise.
<
Date
>
</code>
*
[
.age()
](
#RoomInvitation+age
)
⇒
<code>
number
</code>
*
[
.toJSON()
](
#RoomInvitation+toJSON
)
⇒
<code>
string
</code>
...
...
@@ -1874,7 +1901,7 @@ bot.on('room-invite', async roomInvitation => {
```
<a
name=
"RoomInvitation+topic"
></a>
### roomInvitation.topic() ⇒
[<code>Contact</code>](#Contact)
### roomInvitation.topic() ⇒
<code>string</code>
Get the room topic from room invitation
**Kind**
: instance method of
[
<code>RoomInvitation</code>
](
#RoomInvitation
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录