Merge remote-tracking branch 'origin/master'

This commit is contained in:
Him188 2020-02-21 14:39:34 +08:00
commit 9d4e0d053f
8 changed files with 862 additions and 57 deletions

View File

@ -6,14 +6,16 @@ Some of the protocol came from the other open-source projects.
**The development is only for learning, DO NOT use it for illegal purposes.**
## UpdateLog
## Changelog
You can inspect supported protocols at [Project](https://github.com/mamoe/mirai/projects/1)
and logs of updates at [UpdateLog](https://github.com/mamoe/mirai/blob/master/UpdateLog.md)
and logs of updates at [CHANGELOG](https://github.com/mamoe/mirai/blob/master/CHANGELOG.md)
## Use as a library
You can install mirai as a library into your project.
Mirai is only published on `jcenter`, therefore please ensure you have the `jcenter()` repository in your `build.gradle`, like:
Mirai is only published on `jcenter`, therefore please ensure you have the `jcenter()` repository in your `build.gradle`.
```kotlin
repositories{
jcenter()
@ -23,7 +25,8 @@ repositories{
If your project is a multiplatform project, you should add dependencies for each platform respectively.
If your project is not a multiplatform project, you just need to add the platform-specific dependency.
`VERSION` should be replaced with the newest version, say [![Download](https://api.bintray.com/packages/him188moe/mirai/mirai-core/images/download.svg)](https://bintray.com/him188moe/mirai/mirai-core/)
`VERSION` should be replaced with the newest version, say [![Download](https://api.bintray.com/packages/him188moe/mirai/mirai-core/images/download.svg)](https://bintray.com/him188moe/mirai/mirai-core/)
Mirai is still under experimental stage, it is suggested to keep the version newest.
**common**
@ -71,14 +74,20 @@ If you meet any problem or have any questions, be free to open a issue. Our goal
Kotlin 1.3.61
On JVM: Java 6
On Android: SDK 15
### Using java
Q: Can I use Mirai without Kotlin?
A: Calling from java is not yet supported. Coroutines, extensions and inlines, which are difficult to use from Java, are generally used in Mirai. Therefore you should have the skill of Kotlin before you use Mirai.
#### Libraries used
Mirai uses these open-source libraries.
## Acknowledgements
Thanks to [JetBrains](https://www.jetbrains.com/?from=mirai) for allocating free open-source licences for IDEs such as [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai).
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
### Third Party Libraries
- [kotlin-stdlib](https://github.com/JetBrains/kotlin)
- [kotlinx-coroutines](https://github.com/Kotlin/kotlinx.coroutines)
@ -92,7 +101,19 @@ Mirai uses these open-source libraries.
- [javafx](https://github.com/openjdk/jfx)
- [kotlinx-serialization](https://github.com/Kotlin/kotlinx.serialization)
## License
## Acknowledgement
Thanks to [JetBrains](https://www.jetbrains.com/?from=mirai) for allocating free open-source licences for IDEs such as [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai).
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
Copyright (C) 2019-2020 mamoe and Mirai contributors
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -1,10 +1,9 @@
<div align="center">
<img width="160" src="http://img.mamoe.net/2020/02/16/a759783b42f72.png" alt="logo"></br>
<img width="95" src="http://img.mamoe.net/2020/02/16/c4aece361224d.png" alt="title">
----
[![Gitter](https://badges.gitter.im/mamoe/mirai.svg)](https://gitter.im/mamoe/mirai?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
@ -32,39 +31,48 @@ Mirai既可以作为你项目中的QQ协议支持Lib, 也可以作为单独的Ap
加入 Gitter, 或加入 QQ 群: 655057127
## 开始使用Mirai
Mirai支持以多种方式进行部署但是目前我们在集中对mirai-coremirai-japt以及mirai-api-http等核心模块进行特性的开发对于非开发者的使用暂时不做过多支持仅展示开发计划
Mirai支持以多种方式进行部署但是目前我们在集中对mirai-coremirai-japt, mirai-api-http, mirai-console等核心模块进行特性的开发
### 开发者
#### 以编写机器人逻辑为主
- 假如你熟悉Kotlin及包管理工具请参阅[Mirai Guide - Quick Start](/docs/guide_quick_start.md)
- 假如你不熟悉Kotlin希望一份较详细的起步教程请参阅[Mirai Guide - Getting Started](/docs/guide_getting_started.md)
- 假如你使用Java作为开发语言请参阅[mirai-japt](/mirai-japt/README.md)
- 假如你是其他平台开发者,可以通过了解 [mirai-api-http](https://github.com/mamoe/mirai/tree/master/mirai-api-http) 进行接入欢迎开发不同平台的mirai-sdk
- 需了解<b>Java</b><b>Kotlin</b>, 使用[mirai-console](https://github.com/mamoe/mirai/tree/master/mirai-console)机器人框架的插件系统进行[插件开发(DOING)](), 直接进行逻辑编写并与其他插件开发者合作共享
#### 使用Mirai为第三方库
- 假如你倾向使用Kotlin及包管理工具请参阅[Mirai Guide - Quick Start](/docs/guide_quick_start.md)
- 假如你想要试用Kotlin希望一份较详细的起步教程请参阅[Mirai Guide - Getting Started](/docs/guide_getting_started.md)
- 假如你倾向Java作为开发语言请参阅[mirai-japt](/mirai-japt/README.md)
- 假如你倾向其他语言开发,可以通过了解 [mirai-api-http](https://github.com/mamoe/mirai/tree/master/mirai-api-http) 进行接入欢迎开发不同平台的mirai-sdk
- 此外,你还可以在 [Wiki](https://github.com/mamoe/mirai/wiki/Home) 中查看各类帮助,**如 API 示例**。
### 使用者
- [mirai-console](https://github.com/mamoe/mirai/tree/master/mirai-console) 支持插件, 在终端中启动 Mirai 并获得机器人服务,**本模块还未完善**,请耐心等待开发完成。
- mirai-webpanel Mirai的Web控制台支持在网页中管理机器人与插件。本模块目前在计划中。在其他模块稳定后将开始进行开发。
- [mirai-console](https://github.com/mamoe/mirai/tree/master/mirai-console) 支持插件, **全平台可运行(UI版, Unix版, Android版, Web版)** **本模块正在完善**
### 我是其他平台的使用者
#### 酷Q平台用户:
## CHANGELOG
- 全部酷Q的DLL插件可以在mirai中直接加载, 需使用 `Mirai-Native` ([源码(DOING)](https://github.com/iTXTech/mirai-native),[插件版(mirai-console插件)(DOING)]())
- 全部基于 `酷Q HTTPAPI` 的插件可以在`mirai`中直接加载, 需使用`Mirai-CQ-Adapter`([源码(TODO)](https://github.com/iTXTech/mirai-native),[插件版(mirai-console插件)(TODO)]())
在 [Project](https://github.com/mamoe/mirai/projects/3) 查看已支持功能和计划
在 [CHANGELOG](https://github.com/mamoe/mirai/blob/master/CHANGELOG.md) 查看版本更新记录 (仅发布的版本)
#### 其他平台
- 如果你的插件是通过 `酷Q HTTPAPI` 实现的(绝大部分), 都可以通过 `Mirai-CQ-Adapter` 在mirai中直接使用
## 更新日志
## Modules
* 在 [Project](https://github.com/mamoe/mirai/projects/3) 查看已支持功能和计划
* 在 [CHANGELOG](https://github.com/mamoe/mirai/blob/master/CHANGELOG.md) 查看版本更新记录 (仅发布的版本)
## 模块
### mirai-core
通用 API 模块,一套 API 适配两套协议。
通用 API 模块,一套 API 适配两套协议。
**请参考此模块的 API**
### mirai-core-qqandroid
@ -84,22 +92,21 @@ TIM PC 2.3.2 版本2019 年 8 月)协议的实现
- 群管功能:群员列表,禁言
(目前不再更新此协议,请关注上文的安卓协议)
## Contribution
## 加入开发
我们欢迎一切形式的贡献。
我们也期待有更多人能加入 Mirai 的开发。
我们也期待有更多人能加入 `Mirai` 的开发。
若在使用过程中有任何疑问, 可提交 issue 或是邮件联系(support@mamoe.net). 我们希望 Mirai 变得更易用.
若在使用过程中有任何疑问, 可提交 `issue` 或是[邮件联系](mailto:support@mamoe.net). 我们希望 `Mirai` 变得更易用.
您的 star 是对我们最大的鼓励(点击项目右上角)
您的 `star` 是对我们最大的鼓励(点击项目右上角)
## 鸣谢
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
## Libraries used
感谢:
### 第三方类库
- [kotlin-stdlib](https://github.com/JetBrains/kotlin)
- [kotlinx-coroutines](https://github.com/Kotlin/kotlinx.coroutines)
@ -117,9 +124,7 @@ TIM PC 2.3.2 版本2019 年 8 月)协议的实现
- [toml4j](https://github.com/mwanji/toml4j)
- [snakeyaml](https://mvnrepository.com/artifact/org.yaml/snakeyaml)
## License
## 许可证
协议原版权归属腾讯科技股份有限公司所有,本项目其他代码遵守:
**GNU AFFERO GENERAL PUBLIC LICENSE version 3**
@ -129,9 +134,19 @@ TIM PC 2.3.2 版本2019 年 8 月)协议的实现
- (见 LICENSE 第 13 节) 尽管本许可协议有其他规定,但如果您修改本程序,则修改后的版本必须显着地为所有通过计算机网络与它进行远程交互的用户(如果您的版本支持这种交互)提供从网络服务器通过一些标准或惯用的软件复制方法**免费**访问相应的**源代码**的机会
- (见 LICENSE 第 4 节) 您可以免费或收费地传递这个项目的源代码或目标代码(即编译结果), **但前提是提供明显的版权声明** (您需要标注本 `GitHub` 项目地址)
------
Copyright (C) 2019-2020 mamoe and Mirai contributors
## Acknowledgement
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
特别感谢 [JetBrains](https://www.jetbrains.com/?from=mirai) 为开源项目提供免费的 [IntelliJ IDEA](https://www.jetbrains.com/idea/?from=mirai) 等 IDE 的授权
[<img src=".github/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/?from=mirai)
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.

View File

@ -0,0 +1,727 @@
#### Bot登录成功
```json5
{
"type": "BotOnlineEvent",
"qq": 123456
}
```
| 名字 | 类型 | 说明 |
| ---- | ---- | ------------------- |
| qq | Long | 登录成功的Bot的QQ号 |
#### Bot主动离线
```json5
{
"type": "BotOfflineEventActive",
"qq": 123456
}
```
| 名字 | 类型 | 说明 |
| ---- | ---- | ------------------- |
| qq | Long | 主动离线的Bot的QQ号 |
#### Bot被挤下线
```json5
{
"type": "BotOfflineEventForce",
"qq": 123456
}
```
| 名字 | 类型 | 说明 |
| ---- | ---- | ------------------- |
| qq | Long | 被挤下线的Bot的QQ号 |
#### Bot被服务器断开或因网络问题而掉线
```json5
{
"type": "BotOfflineEventDropped",
"qq": 123456
}
```
| 名字 | 类型 | 说明 |
| ---- | ---- | ----------------------------------------- |
| qq | Long | 被服务器断开或因网络问题而掉线的Bot的QQ号 |
#### Bot主动重新登录.
```json5
{
"type": "BotReloginEvent",
"qq": 123456
}
```
| 名字 | 类型 | 说明 |
| ---- | ---- | ----------------------- |
| qq | Long | 主动重新登录的Bot的QQ号 |
#### Bot在群里的权限被改变. 操作人一定是群主
```json5
{
"type": "BotGroupPermissionChangeEvent",
"origin": "MEMBER",
"new": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "ADMINISTRATOR"
}
}
```
| 名字 | 类型 | 说明 |
| ---------------- | ------ | --------------------------------------------- |
| origin | String | Bot的原权限OWNER、ADMINISTRATOR或MEMBER |
| new | String | Bot的新权限OWNER、ADMINISTRATOR或MEMBER |
| group | Object | 权限改变所在的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
#### Bot被禁言
```json5
{
"type": "BotMuteEvent",
"durationSeconds": "600",
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------------- | ------ | ------------------------------------------------ |
| durationSeconds | Int | 禁言时长,单位为秒 |
| operator | Object | 操作的管理员或群主信息 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator.group | Object | Bot被禁言所在群的信息 |
| operator.group.id | Long | 群号 |
| operator.group.name | String | 群名 |
| operator.group.permission | String | Bot在群中的权限OWNER或ADMINISTRATOR |
#### Bot被取消禁言
```json5
{
"type": "BotUnmuteEvent",
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------------- | ------ | ------------------------------------------------ |
| operator | Object | 操作的管理员或群主信息 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator.group | Object | Bot被取消禁言所在群的信息 |
| operator.group.id | Long | 群号 |
| operator.group.name | String | 群名 |
| operator.group.permission | String | Bot在群中的权限OWNER或ADMINISTRATOR |
#### Bot加入了一个新群
```json5
{
"type": "BotJoinGroupEvent",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
```
| 名字 | 类型 | 说明 |
| ---------------- | ------ | ------------------------------------------------------------ |
| group | Object | Bot新加入群的信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER新加入群通常是Member |
#### 某个群名改变
```json5
{
"type": "GroupNameChangeEvent",
"origin": "miral technology",
"new": "MIRAI TECHNOLOGY",
"group": {
"id": 123456789,
"name": "MIRAI TECHNOLOGY",
"permission": "MEMBER"
},
"isByBot": false
}
```
| 名字 | 类型 | 说明 |
| ---------------- | ------- | --------------------------------------------- |
| origin | String | 原群名 |
| new | String | 新群名 |
| group | Object | 群名改名的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| isByBot | Boolean | 是否Bot进行该操作 |
#### 某群入群公告改变
```json5
{
"type": "GroupEntranceAnnouncementChangeEvent",
"origin": "abc",
"new": "cba",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------- | ------- | --------------------------------------------- |
| origin | String | 原公告 |
| new | String | 新公告 |
| group | Object | 公告改变的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作的管理员或群主信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER或ADMINISTRATOR |
| operator.group | Object | 同group |
#### 全员禁言
```json5
{
"type": "GroupMuteAllEvent",
"origin": false,
"new": true,
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------- | ------- | --------------------------------------------- |
| origin | Boolean | 原本是否处于全员禁言 |
| new | Boolean | 现在是否处于全员禁言 |
| group | Object | 全员禁言的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作的管理员或群主信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER或ADMINISTRATOR |
| operator.group | Object | 同group |
#### 匿名聊天
```json5
{
"type": "GroupAllowAnonymousChatEvent",
"origin": false,
"new": true,
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------- | ------- | --------------------------------------------- |
| origin | Boolean | 原本匿名聊天是否开启 |
| new | Boolean | 现在匿名聊天是否开启 |
| group | Object | 匿名聊天状态改变的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作的管理员或群主信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER或ADMINISTRATOR |
| operator.group | Object | 同group |
#### 坦白说
```json5
{
"type": "GroupAllowConfessTalkEvent",
"origin": false,
"new": true,
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
},
"isByBot": false
}
```
| 名字 | 类型 | 说明 |
| ---------------- | ------- | --------------------------------------------- |
| origin | Boolean | 原本坦白说是否开启 |
| new | Boolean | 现在坦白说是否开启 |
| group | Object | 坦白说状态改变的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| isByBot | Boolean | 是否Bot进行该操作 |
#### 允许群员邀请好友加群
```json5
{
"type": "GroupAllowMemberInviteEvent",
"origin": false,
"new": true,
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ------------------- | ------- | --------------------------------------------- |
| origin | Boolean | 原本是否允许群员邀请好友加群 |
| new | Boolean | 现在是否允许群员邀请好友加群 |
| group | Object | 允许群员邀请好友加群状态改变的群信息 |
| group.id | Long | 群号 |
| group.name | String | 群名 |
| group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作的管理员或群主信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER或ADMINISTRATOR |
| operator.group | Object | 同group |
#### 新人入群的事件
```json5
{
"type": "MemberJoinEvent",
"member": {
"id": 123456789,
"memberName": "我是新人",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------ | ------------------------------------------------------------ |
| member | Object | 新人信息 |
| member.id | Long | 新人的QQ号 |
| member.memberName | String | 新人的群名片 |
| member.permission | String | 新人在群中的权限OWNER、ADMINISTRATOR或MEMBER新入群通常是MEMBER |
| member.group | Object | 新人入群的群信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
#### 成员被踢出群该成员不是Bot
```json5
{
"type": "MemberLeaveEventKick",
"member": {
"id": 123456789,
"memberName": "我是被踢的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------- | --------------------------------------------- |
| member | Object | 被踢者的信息 |
| member.id | Long | 被踢者的QQ号 |
| member.memberName | String | 被踢者的群名片 |
| member.permission | String | 被踢者在群中的权限ADMINISTRATOR或MEMBER |
| member.group | Object | 被踢者所在的群 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作的管理员或群主信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER或ADMINISTRATOR |
| operator.group | Object | 同member.group |
#### 成员主动离群该成员不是Bot
```json5
{
"type": "MemberLeaveEventQuit",
"member": {
"id": 123456789,
"memberName": "我是被踢的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------ | --------------------------------------------- |
| member | Object | 退群群员的信息 |
| member.id | Long | 退群群员的QQ号 |
| member.memberName | String | 退群群员的群名片 |
| member.permission | String | 退群群员在群中的权限ADMINISTRATOR或MEMBER |
| member.group | Object | 退群群员所在的群信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
#### 群名片改动
```json5
{
"type": "MemberCardChangeEvent",
"origin": "origin name",
"new": "我是被改名的",
"member": {
"id": 123456789,
"memberName": "我是被改名的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
},
"operator": {
"id": 123456789,
"memberName": "我是管理员,也可能是我自己",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------- | -------------------------------------------------------- |
| member | Object | 名片改动的群员的信息 |
| member.id | Long | 名片改动的群员的QQ号 |
| member.memberName | String | 名片改动的群员的群名片 |
| member.permission | String | 名片改动的群员在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| member.group | Object | 名片改动的群员所在群的信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作者的信息可能为该群员自己当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator.group | Object | 同member.group |
#### 群头衔改动(只有群主有操作限权)
```json5
{
"type": "MemberSpecialTitleChangeEvent",
"origin": "origin title",
"new": "new title",
"member": {
"id": 123456789,
"memberName": "我是被改头衔的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------ | -------------------------------------------------------- |
| origin | String | 原头衔 |
| new | String | 现头衔 |
| member | Object | 头衔改动的群员的信息 |
| member.id | Long | 头衔改动的群员的QQ号 |
| member.memberName | String | 头衔改动的群员的群名片 |
| member.permission | String | 头衔改动的群员在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| member.group | Object | 头衔改动的群员所在群的信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
#### 成员权限改变的事件该成员不可能是Bot见BotGroupPermissionChangeEvent
```json5
{
"type": "MemberPermissionChangeEvent",
"origin": "MEMBER",
"new": "ADMINISTRATOR",
"member": {
"id": 123456789,
"memberName": "我是被改权限的",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------ | ------------------------------------------------- |
| origin | String | 原权限 |
| new | String | 现权限 |
| member | Object | 权限改动的群员的信息 |
| member.id | Long | 权限改动的群员的QQ号 |
| member.memberName | String | 权限改动的群员的群名片 |
| member.permission | String | 权限改动的群员在群中的权限ADMINISTRATOR或MEMBER |
| member.group | Object | 权限改动的群员所在群的信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
#### 群成员被禁言事件该成员不可能是Bot见BotMuteEvent
```json5
{
"type": "MemberMuteEvent",
"durationSeconds": 600,
"member": {
"id": 123456789,
"memberName": "我是被禁言的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------- | ----------------------------------------------- |
| durationSeconds | Long | 禁言时长,单位为秒 |
| member | Object | 被禁言的群员的信息 |
| member.id | Long | 被禁言的群员的QQ号 |
| member.memberName | String | 被禁言的群员的群名片 |
| member.permission | String | 被禁言的群员在群中的权限ADMINISTRATOR或MEMBER |
| member.group | Object | 被禁言的群员所在群的信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作者的信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER、ADMINISTRATOR |
| operator.group | Object | 同member.group |
#### 群成员被取消禁言事件该成员不可能是Bot见BotUnmuteEvent
```json5
{
"type": "MemberUnmuteEvent",
"member": {
"id": 123456789,
"memberName": "我是被取消禁言的",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
},
"operator": {
"id": 123456789,
"memberName": "我是管理员",
"permission": "ADMINISTRATOR",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}
```
| 名字 | 类型 | 说明 |
| ----------------------- | ------- | --------------------------------------------------- |
| member | Object | 被取消禁言的群员的信息 |
| member.id | Long | 被取消禁言的群员的QQ号 |
| member.memberName | String | 被取消禁言的群员的群名片 |
| member.permission | String | 被取消禁言的群员在群中的权限ADMINISTRATOR或MEMBER |
| member.group | Object | 被取消禁言的群员所在群的信息 |
| member.group.id | Long | 群号 |
| member.group.name | String | 群名 |
| member.group.permission | String | Bot在群中的权限OWNER、ADMINISTRATOR或MEMBER |
| operator | Object? | 操作者的信息当null时为Bot操作 |
| operator.id | Long | 操作者的QQ号 |
| operator.memberName | String | 操作者的群名片 |
| operator.permission | String | 操作者在群中的权限OWNER、ADMINISTRATOR |
| operator.group | Object | 同member.group |

View File

@ -331,24 +331,26 @@ Content-Typemultipart/form-data
### 获取Bot收到的消息
### 获取Bot收到的消息和事件
```
[GET] /fetchMessage?sessionKey=YourSessionKey&count=10
```
使用此方法获取bot接收到的消息和各类事件
#### 请求:
| 名字 | 可选 | 举例 | 说明 |
| ---------- | ----- | -------------- | --------------- |
| sessionKey | false | YourSessionKey | 你的session key |
| count | false | 10 | 获取消息的数量 |
| 名字 | 可选 | 举例 | 说明 |
| ---------- | ----- | -------------- | -------------------- |
| sessionKey | false | YourSessionKey | 你的session key |
| count | false | 10 | 获取消息和事件的数量 |
#### 响应: 返回JSON对象
```json5
[{
"type": "GroupMessage", // 消息类型GroupMessage或FriendMessage
"type": "GroupMessage", // 消息类型GroupMessage或FriendMessage或各类Event
"messageChain": [{ // 消息链,是一个消息对象构成的数组
"type": "Source",
"uid": 123456
@ -366,9 +368,8 @@ Content-Typemultipart/form-data
"permission": "MEMBER" // 发送群中Bot的群限权
}
}
},
{
"type": "FriendMessage", // 消息类型GroupMessage或FriendMessage
},{
"type": "FriendMessage", // 消息类型GroupMessage或FriendMessage或各类Event
"messageChain": [{ // 消息链,是一个消息对象构成的数组
"type": "Plain",
"text": "Miral牛逼"
@ -378,11 +379,40 @@ Content-Typemultipart/form-data
"nickName": "", // 发送者的昵称
"remark": "" // 发送者的备注
}
},{
"type": "MemberMuteEvent", // 消息类型GroupMessage或FriendMessage或各类Event
"durationSeconds": 600,
"member":{
"id": 123456789,
"memberName": "禁言对象",
"permission": "MEMBER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
},
"operator":{
"id": 987654321,
"memberName": "群主大人",
"permission": "OWNER",
"group": {
"id": 123456789,
"name": "Miral Technology",
"permission": "MEMBER"
}
}
}]
```
### 事件类型一览
[事件类型一览](./EventType_CN.md)
> 事件为Bot被动接收的信息无法主动构建
### 消息类型一览
#### 消息是构成消息链的基本对象,目前支持的消息类型有

View File

@ -38,7 +38,7 @@ fun BotEvent.toDTO() = when(this) {
is MemberJoinEvent -> MemberJoinEventDTO(MemberDTO(member))
is MemberLeaveEvent.Kick -> MemberLeaveEventKickDTO(MemberDTO(member), operator?.let(::MemberDTO))
is MemberLeaveEvent.Quit -> MemberLeaveEventQuitDTO(MemberDTO(member))
is MemberCardChangeEvent -> MemberCardChangeEventDTO(origin, new, GroupDTO(group), operator?.let(::MemberDTO))
is MemberCardChangeEvent -> MemberCardChangeEventDTO(origin, new, MemberDTO(member), operator?.let(::MemberDTO))
is MemberSpecialTitleChangeEvent -> MemberSpecialTitleChangeEventDTO(origin, new, MemberDTO(member))
is MemberPermissionChangeEvent -> MemberPermissionChangeEventDTO(origin, new, MemberDTO(member))
is MemberMuteEvent -> MemberMuteEventDTO(durationSeconds, MemberDTO(member), operator?.let(::MemberDTO))
@ -103,7 +103,7 @@ data class MemberLeaveEventKickDTO(val member: MemberDTO, val operator: MemberDT
data class MemberLeaveEventQuitDTO(val member: MemberDTO) : BotEventDTO()
@Serializable
@SerialName("MemberCardChangeEvent")
data class MemberCardChangeEventDTO(val origin: String, val new: String, val group: GroupDTO, val operator: MemberDTO?) : BotEventDTO()
data class MemberCardChangeEventDTO(val origin: String, val new: String, val member: MemberDTO, val operator: MemberDTO?) : BotEventDTO()
@Serializable
@SerialName("MemberSpecialTitleChangeEvent")
data class MemberSpecialTitleChangeEventDTO(val origin: String, val new: String, val member: MemberDTO) : BotEventDTO()

View File

@ -20,8 +20,13 @@ import net.mamoe.mirai.console.plugins.loadAsConfig
import net.mamoe.mirai.console.plugins.withDefaultWrite
import net.mamoe.mirai.console.plugins.withDefaultWriteSave
import net.mamoe.mirai.contact.sendMessage
import net.mamoe.mirai.utils.DeviceInfo
import net.mamoe.mirai.utils.FileBasedDeviceInfo
import net.mamoe.mirai.utils.SimpleLogger
import net.mamoe.mirai.utils.SystemDeviceInfo
import net.mamoe.mirai.utils.cryptor.ECDH
import java.io.File
import java.security.Security
import java.util.*
@ -46,8 +51,8 @@ object MiraiConsole {
var path: String = System.getProperty("user.dir")
val version = "v0.01"
var coreVersion = "v0.15.1"
val build = "Beta"
var coreVersion = "v0.18.0"
val build = "Zeta"
var allDown = false
@ -55,6 +60,13 @@ object MiraiConsole {
fun start(
frontEnd: MiraiConsoleUI
) {
try {
ECDH()
} catch (ignored: Exception) {
}
Security.removeProvider("BC")
this.frontEnd = frontEnd
frontEnd.pushVersion(
version, build, coreVersion
@ -305,7 +317,6 @@ object MiraiConsole {
if (!CommandManager.runCommand(fullCommand)) {
logger("未知指令 $fullCommand")
}
}
}
}
@ -334,7 +345,6 @@ object MiraiConsole {
var HTTP_API_AUTH_KEY: String by config.withDefaultWriteSave {
"InitKey" + generateSessionKey()
}
}
}

View File

@ -9,9 +9,11 @@
package net.mamoe.mirai.qqandroid.network.protocol.data.jce
import kotlinx.io.core.toByteArray
import kotlinx.serialization.SerialId
import kotlinx.serialization.Serializable
import net.mamoe.mirai.qqandroid.io.JceStruct
import net.mamoe.mirai.qqandroid.network.protocol.packet.EMPTY_BYTE_ARRAY
@Serializable
internal class ModifyGroupCardReq(

View File

@ -410,7 +410,7 @@ internal class TroopManagement {
gender = 0,
dwuin = member.id,
dwFlag = 31,
sName = newName.toUtf8Bytes().encodeToString(charset = CharsetGBK),
sName = newName.toByteArray(CharsetUTF8).encodeToString(CharsetGBK),
sPhone = "",
sEmail = "",
sRemark = ""