Commit 385b36b0 authored by Him188's avatar Him188

Merge remote-tracking branch 'origin/master'

parents c3bd03fc f96109c7
...@@ -16,6 +16,8 @@ fun main() { ...@@ -16,6 +16,8 @@ fun main() {
} }
``` ```
## 认证相关 ## 认证相关
### 开始会话-认证(Authorize) ### 开始会话-认证(Authorize)
...@@ -141,6 +143,8 @@ fun main() { ...@@ -141,6 +143,8 @@ fun main() {
> SessionKey与Bot 对应错误时将会返回状态码5:指定对象不存在 > SessionKey与Bot 对应错误时将会返回状态码5:指定对象不存在
## 消息相关 ## 消息相关
...@@ -261,10 +265,10 @@ fun main() { ...@@ -261,10 +265,10 @@ fun main() {
### 发送图片消息(通过URL) ### 发送图片消息(通过URL)
``` ```
[POST] /sendGroupMessage [POST] /sendImageMessage
``` ```
使用此方法向指定群发送消息 使用此方法向指定对象(群或好友)发送图片消息
#### 请求 #### 请求
...@@ -303,7 +307,7 @@ fun main() { ...@@ -303,7 +307,7 @@ fun main() {
### 图片文件上传 ### 图片文件上传
``` ```
[POST] /sendGroupMessage [POST] /uploadImage
``` ```
使用此方法上传图片文件至服务器并返回ImageId 使用此方法上传图片文件至服务器并返回ImageId
...@@ -385,7 +389,7 @@ Content-Type:multipart/form-data ...@@ -385,7 +389,7 @@ Content-Type:multipart/form-data
+ [x] At,@消息 + [x] At,@消息
+ [x] AtAll,@全体成员 + [x] AtAll,@全体成员
+ [x] Face,表情消息 + [ ] Face,表情消息
+ [x] Plain,文字消息 + [x] Plain,文字消息
+ [x] Image,图片消息 + [x] Image,图片消息
+ [ ] Xml,Xml卡片消息 + [ ] Xml,Xml卡片消息
...@@ -414,10 +418,10 @@ Content-Type:multipart/form-data ...@@ -414,10 +418,10 @@ Content-Type:multipart/form-data
} }
``` ```
| 名字 | 类型 | 说明 | | 名字 | 类型 | 说明 |
| ------- | ------ | ------------------------- | | ------- | ------ | ---------------------------------------------- |
| target | Long | 群员QQ号 | | target | Long | 群员QQ号 |
| display | String | @时显示的文本如:"@Mirai" | | dispaly | String | At时显示的文字,发送消息时无效,自动使用群名片 |
#### AtAll #### AtAll
...@@ -517,6 +521,7 @@ Content-Type:multipart/form-data ...@@ -517,6 +521,7 @@ Content-Type:multipart/form-data
``` ```
### 获取群列表 ### 获取群列表
使用此方法获取bot的群列表 使用此方法获取bot的群列表
...@@ -786,6 +791,8 @@ Content-Type:multipart/form-data ...@@ -786,6 +791,8 @@ Content-Type:multipart/form-data
} }
``` ```
### 获取群设置 ### 获取群设置
使用此方法获取群设置 使用此方法获取群设置
...@@ -816,6 +823,7 @@ Content-Type:multipart/form-data ...@@ -816,6 +823,7 @@ Content-Type:multipart/form-data
``` ```
### 修改群员资料 ### 修改群员资料
使用此方法修改群员资料(需要有相关限权) 使用此方法修改群员资料(需要有相关限权)
...@@ -856,6 +864,8 @@ Content-Type:multipart/form-data ...@@ -856,6 +864,8 @@ Content-Type:multipart/form-data
} }
``` ```
### 获取群员资料 ### 获取群员资料
使用此方法获取群员资料 使用此方法获取群员资料
......
...@@ -11,6 +11,9 @@ package net.mamoe.mirai.api.http.data.common ...@@ -11,6 +11,9 @@ package net.mamoe.mirai.api.http.data.common
import kotlinx.serialization.SerialName import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable import kotlinx.serialization.Serializable
import net.mamoe.mirai.contact.Contact
import net.mamoe.mirai.contact.Group
import net.mamoe.mirai.contact.Member
import net.mamoe.mirai.message.FriendMessage import net.mamoe.mirai.message.FriendMessage
import net.mamoe.mirai.message.GroupMessage import net.mamoe.mirai.message.GroupMessage
import net.mamoe.mirai.message.MessagePacket import net.mamoe.mirai.message.MessagePacket
...@@ -40,7 +43,7 @@ data class UnKnownMessagePacketDTO(val msg: String) : MessagePacketDTO() ...@@ -40,7 +43,7 @@ data class UnKnownMessagePacketDTO(val msg: String) : MessagePacketDTO()
data class MessageSourceDTO(val uid: Long) : MessageDTO() data class MessageSourceDTO(val uid: Long) : MessageDTO()
@Serializable @Serializable
@SerialName("At") @SerialName("At")
data class AtDTO(val target: Long, val display: String) : MessageDTO() data class AtDTO(val target: Long, val display: String = "") : MessageDTO()
@Serializable @Serializable
@SerialName("AtAll") @SerialName("AtAll")
data class AtAllDTO(val target: Long = 0) : MessageDTO() // target为保留字段 data class AtAllDTO(val target: Long = 0) : MessageDTO() // target为保留字段
...@@ -83,8 +86,8 @@ suspend fun MessagePacket<*, *>.toDTO(): MessagePacketDTO = when (this) { ...@@ -83,8 +86,8 @@ suspend fun MessagePacket<*, *>.toDTO(): MessagePacketDTO = when (this) {
else -> UnKnownMessagePacketDTO("UnKnown Message Packet") else -> UnKnownMessagePacketDTO("UnKnown Message Packet")
}.apply { messageChain = Array(message.size){ message[it].toDTO() }} }.apply { messageChain = Array(message.size){ message[it].toDTO() }}
fun MessageChainDTO.toMessageChain() = fun MessageChainDTO.toMessageChain(contact: Contact) =
MessageChain().apply { this@toMessageChain.forEach { add(it.toMessage()) } } MessageChain().apply { this@toMessageChain.forEach { add(it.toMessage(contact)) } }
@UseExperimental(ExperimentalUnsignedTypes::class) @UseExperimental(ExperimentalUnsignedTypes::class)
fun Message.toDTO() = when (this) { fun Message.toDTO() = when (this) {
...@@ -99,8 +102,8 @@ fun Message.toDTO() = when (this) { ...@@ -99,8 +102,8 @@ fun Message.toDTO() = when (this) {
} }
@UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class) @UseExperimental(ExperimentalUnsignedTypes::class, MiraiInternalAPI::class)
fun MessageDTO.toMessage() = when (this) { fun MessageDTO.toMessage(contact: Contact) = when (this) {
is AtDTO -> At(target, display) is AtDTO -> At((contact as Group)[target])
is AtAllDTO -> AtAll is AtAllDTO -> AtAll
is FaceDTO -> Face(FaceId(faceId.toUByte())) is FaceDTO -> Face(FaceId(faceId.toUByte()))
is PlainDTO -> PlainText(text) is PlainDTO -> PlainText(text)
......
...@@ -18,6 +18,7 @@ import net.mamoe.mirai.api.http.AuthedSession ...@@ -18,6 +18,7 @@ import net.mamoe.mirai.api.http.AuthedSession
import net.mamoe.mirai.api.http.SessionManager import net.mamoe.mirai.api.http.SessionManager
import net.mamoe.mirai.api.http.data.NoSuchBotException import net.mamoe.mirai.api.http.data.NoSuchBotException
import net.mamoe.mirai.api.http.data.StateCode import net.mamoe.mirai.api.http.data.StateCode
import net.mamoe.mirai.api.http.data.common.DTO
import net.mamoe.mirai.api.http.data.common.VerifyDTO import net.mamoe.mirai.api.http.data.common.VerifyDTO
import kotlin.coroutines.EmptyCoroutineContext import kotlin.coroutines.EmptyCoroutineContext
...@@ -28,7 +29,7 @@ fun Application.authModule() { ...@@ -28,7 +29,7 @@ fun Application.authModule() {
if (it.authKey != SessionManager.authKey) { if (it.authKey != SessionManager.authKey) {
call.respondStateCode(StateCode(1, "Auth Key错误")) call.respondStateCode(StateCode(1, "Auth Key错误"))
} else { } else {
call.respondStateCode(StateCode(0, SessionManager.createTempSession().key)) call.respondDTO(AuthRetDTO(0, SessionManager.createTempSession().key))
} }
} }
...@@ -55,6 +56,9 @@ fun Application.authModule() { ...@@ -55,6 +56,9 @@ fun Application.authModule() {
} }
} }
@Serializable
private data class AuthRetDTO(val code: Int, val session: String) : DTO
@Serializable @Serializable
private data class BindDTO(override val sessionKey: String, val qq: Long) : VerifyDTO() private data class BindDTO(override val sessionKey: String, val qq: Long) : VerifyDTO()
......
...@@ -43,18 +43,23 @@ fun Application.messageModule() { ...@@ -43,18 +43,23 @@ fun Application.messageModule() {
} }
miraiVerify<SendDTO>("/sendFriendMessage") { miraiVerify<SendDTO>("/sendFriendMessage") {
it.session.bot.getFriend(it.target).sendMessage(it.messageChain.toMessageChain()) it.session.bot.getFriend(it.target).apply {
sendMessage(it.messageChain.toMessageChain(this)) // this aka QQ
}
call.respondStateCode(StateCode.Success) call.respondStateCode(StateCode.Success)
} }
miraiVerify<SendDTO>("/sendGroupMessage") { miraiVerify<SendDTO>("/sendGroupMessage") {
it.session.bot.getGroup(it.target).sendMessage(it.messageChain.toMessageChain()) it.session.bot.getGroup(it.target).apply {
sendMessage(it.messageChain.toMessageChain(this)) // this aka Group
}
call.respondStateCode(StateCode.Success) call.respondStateCode(StateCode.Success)
} }
miraiVerify<SendDTO>("/quoteMessage") { miraiVerify<SendDTO>("/quoteMessage") {
it.session.messageQueue.quoteCache[it.target]?.quoteReply(it.messageChain.toMessageChain()) it.session.messageQueue.quoteCache[it.target]?.apply {
?: throw NoSuchElementException() quoteReply(it.messageChain.toMessageChain(group))
} ?: throw NoSuchElementException()
call.respondStateCode(StateCode.Success) call.respondStateCode(StateCode.Success)
} }
......
package net.mamoe.mirai.console.graphical package net.mamoe.mirai.console.graphical
import com.jfoenix.controls.JFXDecorator
import javafx.scene.control.Button
import javafx.stage.Stage
import net.mamoe.mirai.console.MiraiConsole import net.mamoe.mirai.console.MiraiConsole
import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController import net.mamoe.mirai.console.graphical.controller.MiraiGraphicalUIController
import net.mamoe.mirai.console.graphical.styleSheet.PrimaryStyleSheet
import net.mamoe.mirai.console.graphical.view.Decorator import net.mamoe.mirai.console.graphical.view.Decorator
import net.mamoe.mirai.console.graphical.view.PrimaryView
import tornadofx.App import tornadofx.App
import tornadofx.FX.Companion.primaryStage
import tornadofx.UIComponent
import tornadofx.find import tornadofx.find
import tornadofx.launch import tornadofx.launch
...@@ -17,7 +12,7 @@ fun main(args: Array<String>) { ...@@ -17,7 +12,7 @@ fun main(args: Array<String>) {
launch<MiraiGraphicalUI>(args) launch<MiraiGraphicalUI>(args)
} }
class MiraiGraphicalUI: App(Decorator::class) { class MiraiGraphicalUI : App(Decorator::class, PrimaryStyleSheet::class) {
override fun init() { override fun init() {
super.init() super.init()
...@@ -29,4 +24,4 @@ class MiraiGraphicalUI: App(Decorator::class) { ...@@ -29,4 +24,4 @@ class MiraiGraphicalUI: App(Decorator::class) {
super.stop() super.stop()
MiraiConsole.stop() MiraiConsole.stop()
} }
} }
\ No newline at end of file
package net.mamoe.mirai.console.graphical.styleSheet
import tornadofx.*
class PrimaryStyleSheet : Stylesheet() {
companion object {
val jfxTitle by cssclass("jfx-decorator-buttons-container")
val container by cssclass("jfx-decorator-content-container")
}
init {
jfxTitle {
backgroundColor += c("00BCD4")
}
container {
borderColor += box(c("00BCD4"))
borderWidth += box(0.px, 4.px, 4.px, 4.px)
}
}
}
\ No newline at end of file
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