Commit 9d4e0d05 authored by Him188's avatar Him188

Merge remote-tracking branch 'origin/master'

parents 67e70945 dc29420c
......@@ -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)
\ No newline at end of file
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/>.
<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-core,mirai-japt以及mirai-api-http等核心模块进行特性的开发,对于非开发者的使用暂时不做过多支持,仅展示开发计划
Mirai支持以多种方式进行部署,但是目前,我们在集中对mirai-core,mirai-japt, mirai-api-http, mirai-console等核心模块进行特性的开发
### 开发者
#### 以编写机器人逻辑为主
- 需了解<b>Java</b><b>Kotlin</b>, 使用[mirai-console](https://github.com/mamoe/mirai/tree/master/mirai-console)机器人框架的插件系统进行[插件开发(DOING)](), 直接进行逻辑编写并与其他插件开发者合作共享
- 假如你熟悉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
#### 使用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平台用户:
- 全部酷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)]())
## CHANGELOG
#### 其他平台
[Project](https://github.com/mamoe/mirai/projects/3) 查看已支持功能和计划
[CHANGELOG](https://github.com/mamoe/mirai/blob/master/CHANGELOG.md) 查看版本更新记录 (仅发布的版本)
- 如果你的插件是通过 `酷Q HTTPAPI` 实现的(绝大部分), 都可以通过 `Mirai-CQ-Adapter` 在mirai中直接使用
## 更新日志
*[Project](https://github.com/mamoe/mirai/projects/3) 查看已支持功能和计划
*[CHANGELOG](https://github.com/mamoe/mirai/blob/master/CHANGELOG.md) 查看版本更新记录 (仅发布的版本)
## Modules
## 模块
### 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)
\ No newline at end of file
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/>.
This diff is collapsed.
......@@ -331,24 +331,26 @@ Content-Type:multipart/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-Type:multipart/form-data
"permission": "MEMBER" // 发送群中,Bot的群限权
}
}
},
{
"type": "FriendMessage", // 消息类型:GroupMessage或FriendMessage
},{
"type": "FriendMessage", // 消息类型:GroupMessage或FriendMessage或各类Event
"messageChain": [{ // 消息链,是一个消息对象构成的数组
"type": "Plain",
"text": "Miral牛逼"
......@@ -378,11 +379,40 @@ Content-Type:multipart/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被动接收的信息,无法主动构建
### 消息类型一览
#### 消息是构成消息链的基本对象,目前支持的消息类型有
......
......@@ -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()
......
......@@ -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()
}
}
}
......
......@@ -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(
......
......@@ -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 = ""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment