mirai/docs/Contacts.md

27 lines
5.1 KiB
Markdown
Raw Normal View History

2020-12-19 13:57:38 +08:00
# Mirai - Contacts
2021-01-29 10:44:26 +08:00
[![](https://mermaid.ink/img/eyJjb2RlIjoiY2xhc3NEaWFncmFtXG5cbmNsYXNzIEJvdCB7XG4gICAgK2ZyaWVuZHM6IENvbnRhY3RMaXN0XG4gICAgK2dyb3VwczogQ29udGFjdExpc3RcbiAgICArZ2V0RnJpZW5kKExvbmcpIEZyaWVuZD9cbiAgICArZ2V0RnJpZW5kT3JOdWxsKExvbmcpIEZyaWVuZFxuICAgICtnZXRHcm91cChMb25nKSBHcm91cD9cbiAgICArZ2V0R3JvdXBPckZhaWwoTG9uZykgR3JvdXBcbiAgICArbG9naW4oKVxuICAgICtjbG9zZSgpXG59XG5cbmNsYXNzIENvbnRhY3RPckJvdCB7XG4gICAgK2lkOiBJbnRcbiAgICArYXZhdGFyVXJsOiBTdHJpbmdcbn1cblxuY2xhc3MgVXNlck9yQm90IHtcbiAgICArbnVkZ2UoKSBOdWRnZVxufVxuXG5jbGFzcyBDb250YWN0IHtcbiAgICArYm90OiBCb3RcbiAgICArc2VuZE1lc3NhZ2UoTWVzc2FnZSkgTWVzc2FnZVJlY2VpcHRcbiAgICArc2VuZE1lc3NhZ2UoU3RyaW5nKSBNZXNzYWdlUmVjZWlwdFxuICAgICt1cGxvYWRJbWFnZShFeHRlcm5hbEltYWdlKSBJbWFnZVxufVxuXG5jbGFzcyBVc2VyIHtcbiAgICArbmljazogU3RyaW5nXG4gICAgK3JlbWFyazogU3RyaW5nXG4gICAgK3F1ZXJ5UHJvZmlsZSgpIFVzZXJQcm9maWxlXG59XG5cbmNsYXNzIEdyb3VwIHtcbiAgICArbWVtYmVyczogQ29udGFjdExpc3RcbiAgICArbmFtZTogU3RyaW5nXG4gICAgK3NldHRpbmdzOiBHcm91cFNldHRpbmdzXG4gICAgK293bmVyOiBOb3JtYWxNZW1iZXJcbiAgICArYm90TXV0ZVJlbWFpbmluZ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UNvbnRhY3RcbkNvbnRhY3RPckJvdDx8LS1Vc2VyT3JCb3RcblxuVXNlck9yQm90PHwtLUJvdFxuVXNlck9yQm90PHwtLVVzZXJcblxuQ29udGFjdDx8LS1Vc2VyXG5Db250YWN0PHwtLUdyb3VwXG5Db250YWN0PHwtLU90aGVyQ2xpZW50XG5cblVzZXI8fC0tTWVtYmVyXG5Vc2VyPHwtLUZyaWVuZFxuXG5NZW1iZXI8fC0tTm9ybWFsTWVtYmVyXG5NZW1iZXI8fC0tQW5vbnltb3VzTWVtYmVyIiwibWVybWFpZCI6eyJ0aGVtZSI6ImRlZmF1bHQifSwidXBkYXRlRWRpdG9yIjpmYWxzZX0)
2020-12-23 19:26:26 +08:00
2021-01-13 16:07:02 +08:00
| 类型 | 描述 | 最低支持的版本 |
|:--------------:|:---------------------------------------------------|:-----------:|
| `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 |
2020-12-23 19:26:26 +08:00
2021-01-13 16:07:02 +08:00
基于面向对象的设计,可直接获取 `Contact` 的属性如 `nick``permission`。请在实践时在接口源码内查看更清晰的说明。
2020-12-19 13:57:38 +08:00
2021-01-13 16:07:02 +08:00
要主动发送一条消息,总是调用 `Contact.sendMessage(message)`*`message` 在后文介绍)*。
2020-12-19 13:57:38 +08:00
2021-01-13 16:07:02 +08:00
可通过 `Bot.getFriend` `Bot.getGroup``Bot.getStranger` 获取相关对象,也可以通过事件获取 *(事件在后文介绍)*
----
2020-12-19 13:57:38 +08:00
> 下一步,[Events](Events.md)
2020-12-19 16:01:58 +08:00
>
2021-01-13 16:07:02 +08:00
> [回到 Mirai 文档索引](README.md#mirai-core-api-文档)