mirai/docs/Contacts.md
2021-01-13 16:07:02 +08:00

27 lines
4.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Mirai - Contacts
[![](https://mermaid.ink/img/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG5cbmNsYXNzIEJvdCB7XG4gICAgK2ZyaWVuZHM6IENvbnRhY3RMaXN0XG4gICAgK2dyb3VwczogQ29udGFjdExpc3RcbiAgICArZ2V0RnJpZW5kKExvbmcpIEZyaWVuZD9cbiAgICArZ2V0RnJpZW5kT3JOdWxsKExvbmcpIEZyaWVuZFxuICAgICtnZXRHcm91cChMb25nKSBHcm91cD9cbiAgICArZ2V0R3JvdXBPckZhaWwoTG9uZykgR3JvdXBcbiAgICArbG9naW4oKVxuICAgICtjbG9zZSgpXG59XG5cbmNsYXNzIENvbnRhY3RPckJvdCB7XG4gICAgK2lkOiBJbnRcbiAgICArYXZhdGFyVXJsOiBTdHJpbmdcbn1cblxuY2xhc3MgVXNlck9yQm90IHtcbiAgICArbnVkZ2UoKSBOdWRnZVxufVxuXG5jbGFzcyBDb250YWN0IHtcbiAgICArYm90OiBCb3RcbiAgICArc2VuZE1lc3NhZ2UoTWVzc2FnZSkgTWVzc2FnZVJlY2VpcHRcbiAgICArc2VuZE1lc3NhZ2UoU3RyaW5nKSBNZXNzYWdlUmVjZWlwdFxuICAgICt1cGxvYWRJbWFnZShFeHRlcm5hbEltYWdlKSBJbWFnZVxufVxuXG5jbGFzcyBVc2VyIHtcbiAgICArbmljazogU3RyaW5nXG4gICAgK3JlbWFyazogU3RyaW5nXG59XG5cbmNsYXNzIEdyb3VwIHtcbiAgICArbWVtYmVyczogQ29udGFjdExpc3RcbiAgICArbmFtZTogU3RyaW5nXG4gICAgK3NldHRpbmdzOiBHcm91cFNldHRpbmdzXG4gICAgK293bmVyOiBOb3JtYWxNZW1iZXJcbiAgICArYm90TXV0ZVJl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vdXBcblxuVXNlcjx8LS1NZW1iZXJcblVzZXI8fC0tRnJpZW5kXG5cbk1lbWJlcjx8LS1Ob3JtYWxNZW1iZXJcbk1lbWJlcjx8LS1Bbm9ueW1vdXNNZW1iZXIiLCJtZXJtYWlkIjp7InRoZW1lIjoiZGVmYXVsdCJ9LCJ1cGRhdGVFZGl0b3IiOmZhbHNlfQ)
| 类型 | 描述 | 最低支持的版本 |
|:--------------:|:---------------------------------------------------|:-----------:|
| `ContactOrBot` | `Contact``Bot` 的公共接口 | 2.0 |
| `OtherClient` | Bot 的*其他客户端*, 如 "我的 iPad", "我的电脑" | 2.0 |
| `Bot` | 机器人对象 | 2.0 |
| `Contact` | 联系人对象, 即所有的群, 好友, 陌生人, 群成员等 | 2.0 |
| `Group` | 群对象 | 2.0 |
| `User` | 用户对象, 即 "个人". 包含好友, 陌生人, 群成员, 临时会话用户 | 2.0 |
| `Friend` | 好友对象 | 2.0 |
| `Stranger` | 陌生人对象 | 2.0 |
| `Member` | 群成员对象, 属于一个 `Group`. | 2.0 |
基于面向对象的设计,可直接获取 `Contact` 的属性如 `nick``permission`。请在实践时在接口源码内查看更清晰的说明。
要主动发送一条消息,总是调用 `Contact.sendMessage(message)`*`message` 在后文介绍)*。
可通过 `Bot.getFriend` `Bot.getGroup``Bot.getStranger` 获取相关对象,也可以通过事件获取 *(事件在后文介绍)*
----
> 下一步,[Events](Events.md)
>
> [回到 Mirai 文档索引](README.md#mirai-core-api-文档)