Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
385b36b0
Commit
385b36b0
authored
Feb 19, 2020
by
Him188
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
c3bd03fc
f96109c7
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
26 deletions
+64
-26
mirai-api-http/README_CH.md
mirai-api-http/README_CH.md
+18
-8
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
...kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
+8
-5
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/AuthRouteModule.kt
.../kotlin/net/mamoe/mirai/api/http/route/AuthRouteModule.kt
+5
-1
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
.../net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
+9
-4
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
...otlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
+3
-8
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/styleSheet/PrimaryStyleSheet.kt
...e/mirai/console/graphical/styleSheet/PrimaryStyleSheet.kt
+21
-0
No files found.
mirai-api-http/README_CH.md
View file @
385b36b0
...
@@ -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] /send
Group
Message
[POST] /send
Image
Message
```
```
使用此方法向指定
群发送
消息
使用此方法向指定
对象(群或好友)发送图片
消息
#### 请求
#### 请求
...
@@ -303,7 +307,7 @@ fun main() {
...
@@ -303,7 +307,7 @@ fun main() {
### 图片文件上传
### 图片文件上传
```
```
[POST] /
sendGroupMess
age
[POST] /
uploadIm
age
```
```
使用此方法上传图片文件至服务器并返回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号
|
| disp
lay | String | @时显示的文本如:"@Mirai"
|
| disp
aly | 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
}
}
```
```
### 获取群员资料
### 获取群员资料
使用此方法获取群员资料
使用此方法获取群员资料
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/common/MessageDTO.kt
View file @
385b36b0
...
@@ -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
)
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/AuthRouteModule.kt
View file @
385b36b0
...
@@ -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
.
respond
StateCode
(
StateCode
(
0
,
SessionManager
.
createTempSession
().
key
))
call
.
respond
DTO
(
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
()
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/SendMessageRouteModule.kt
View file @
385b36b0
...
@@ -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
)
}
}
...
...
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/MiraiGraphical.kt
View file @
385b36b0
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
mirai-console-graphical/src/main/kotlin/net/mamoe/mirai/console/graphical/styleSheet/PrimaryStyleSheet.kt
0 → 100644
View file @
385b36b0
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment