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
241cf2d5
Commit
241cf2d5
authored
Feb 22, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Http api ready for recall
parent
06c69ad6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
5 deletions
+18
-5
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
...rc/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
+2
-1
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt
...tlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt
+16
-4
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/StateCode.kt
View file @
241cf2d5
package
net.mamoe.mirai.api.http.data
package
net.mamoe.mirai.api.http.data
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.api.http.data.common.DTO
@Serializable
@Serializable
open
class
StateCode
(
val
code
:
Int
,
var
msg
:
String
)
{
open
class
StateCode
(
val
code
:
Int
,
var
msg
:
String
)
:
DTO
{
object
Success
:
StateCode
(
0
,
"success"
)
// 成功
object
Success
:
StateCode
(
0
,
"success"
)
// 成功
object
NoBot
:
StateCode
(
2
,
"指定Bot不存在"
)
object
NoBot
:
StateCode
(
2
,
"指定Bot不存在"
)
object
IllegalSession
:
StateCode
(
3
,
"Session失效或不存在"
)
object
IllegalSession
:
StateCode
(
3
,
"Session失效或不存在"
)
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/MessageRouteModule.kt
View file @
241cf2d5
...
@@ -11,9 +11,11 @@ package net.mamoe.mirai.api.http.route
...
@@ -11,9 +11,11 @@ package net.mamoe.mirai.api.http.route
import
io.ktor.application.Application
import
io.ktor.application.Application
import
io.ktor.application.call
import
io.ktor.application.call
import
io.ktor.http.HttpStatusCode
import
io.ktor.http.content.readAllParts
import
io.ktor.http.content.readAllParts
import
io.ktor.http.content.streamProvider
import
io.ktor.http.content.streamProvider
import
io.ktor.request.receiveMultipart
import
io.ktor.request.receiveMultipart
import
io.ktor.response.respond
import
io.ktor.response.respondText
import
io.ktor.response.respondText
import
io.ktor.routing.post
import
io.ktor.routing.post
import
io.ktor.routing.routing
import
io.ktor.routing.routing
...
@@ -45,14 +47,12 @@ fun Application.messageModule() {
...
@@ -45,14 +47,12 @@ fun Application.messageModule() {
it
.
session
.
bot
.
getFriend
(
it
.
target
).
apply
{
it
.
session
.
bot
.
getFriend
(
it
.
target
).
apply
{
sendMessage
(
it
.
messageChain
.
toMessageChain
(
this
))
// this aka QQ
sendMessage
(
it
.
messageChain
.
toMessageChain
(
this
))
// this aka QQ
}
}
call
.
respondStateCode
(
StateCode
.
Success
)
}
}
miraiVerify
<
SendDTO
>(
"/sendGroupMessage"
)
{
miraiVerify
<
SendDTO
>(
"/sendGroupMessage"
)
{
it
.
session
.
bot
.
getGroup
(
it
.
target
).
apply
{
it
.
session
.
bot
.
getGroup
(
it
.
target
).
apply
{
sendMessage
(
it
.
messageChain
.
toMessageChain
(
this
))
// this aka Group
sendMessage
(
it
.
messageChain
.
toMessageChain
(
this
))
// this aka Group
}
}
call
.
respondStateCode
(
StateCode
.
Success
)
}
}
miraiVerify
<
SendDTO
>(
"/quoteMessage"
)
{
miraiVerify
<
SendDTO
>(
"/quoteMessage"
)
{
...
@@ -100,6 +100,11 @@ fun Application.messageModule() {
...
@@ -100,6 +100,11 @@ fun Application.messageModule() {
}
?:
throw
IllegalAccessException
(
"图片上传错误"
)
}
?:
throw
IllegalAccessException
(
"图片上传错误"
)
}
?:
throw
IllegalAccessException
(
"未知错误"
)
}
?:
throw
IllegalAccessException
(
"未知错误"
)
}
}
miraiVerify
<
RecallDTO
>(
"recall"
)
{
// TODO
call
.
respond
(
HttpStatusCode
.
NotFound
,
"未完成"
)
}
}
}
}
}
...
@@ -121,6 +126,13 @@ private data class SendImageDTO(
...
@@ -121,6 +126,13 @@ private data class SendImageDTO(
@Serializable
@Serializable
private
class
SendRetDTO
(
private
class
SendRetDTO
(
@Transient
val
stateCode
:
StateCode
=
StateCode
.
Success
,
val
messageId
:
Long
,
val
messageId
:
Long
@Transient
val
stateCode
:
StateCode
=
Success
)
:
StateCode
(
stateCode
.
code
,
stateCode
.
msg
)
)
:
StateCode
(
stateCode
.
code
,
stateCode
.
msg
)
@Serializable
private
data class
RecallDTO
(
override
val
sessionKey
:
String
,
val
target
:
Long
,
val
sender
:
Long
)
:
VerifyDTO
()
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