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
5c30f187
Commit
5c30f187
authored
Feb 06, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http-api group info
parent
64980e06
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletion
+51
-1
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt
...src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt
+23
-0
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt
...otlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt
+28
-1
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt
View file @
5c30f187
...
@@ -3,6 +3,7 @@ package net.mamoe.mirai.api.http.dto
...
@@ -3,6 +3,7 @@ package net.mamoe.mirai.api.http.dto
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Serializable
import
kotlinx.serialization.Transient
import
kotlinx.serialization.Transient
import
net.mamoe.mirai.api.http.AuthedSession
import
net.mamoe.mirai.api.http.AuthedSession
import
net.mamoe.mirai.contact.Group
@Serializable
@Serializable
abstract
class
VerifyDTO
:
DTO
{
abstract
class
VerifyDTO
:
DTO
{
...
@@ -37,6 +38,28 @@ data class MuteDTO(
...
@@ -37,6 +38,28 @@ data class MuteDTO(
val
time
:
Int
=
0
val
time
:
Int
=
0
)
:
VerifyDTO
()
)
:
VerifyDTO
()
@Serializable
data class
GroupConfigDTO
(
override
val
sessionKey
:
String
,
val
target
:
Long
,
val
config
:
GroupInfoDTO
)
:
VerifyDTO
()
@Serializable
data class
GroupInfoDTO
(
val
name
:
String
?
=
null
,
val
announcement
:
String
?
=
null
,
val
confessTalk
:
Boolean
?
=
null
,
val
allowMemberInvite
:
Boolean
?
=
null
,
val
autoApprove
:
Boolean
?
=
null
,
val
anonymousChat
:
Boolean
?
=
null
)
:
DTO
{
constructor
(
group
:
Group
)
:
this
(
group
.
name
,
group
.
announcement
,
group
.
confessTalk
,
group
.
allowMemberInvite
,
group
.
autoApprove
,
group
.
anonymousChat
)
}
@Serializable
@Serializable
open
class
StateCode
(
val
code
:
Int
,
var
msg
:
String
)
{
open
class
StateCode
(
val
code
:
Int
,
var
msg
:
String
)
{
object
Success
:
StateCode
(
0
,
"success"
)
// 成功
object
Success
:
StateCode
(
0
,
"success"
)
// 成功
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt
View file @
5c30f187
...
@@ -3,6 +3,8 @@ package net.mamoe.mirai.api.http.route
...
@@ -3,6 +3,8 @@ 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.routing.routing
import
io.ktor.routing.routing
import
net.mamoe.mirai.api.http.dto.GroupConfigDTO
import
net.mamoe.mirai.api.http.dto.GroupInfoDTO
import
net.mamoe.mirai.api.http.dto.MuteDTO
import
net.mamoe.mirai.api.http.dto.MuteDTO
import
net.mamoe.mirai.api.http.dto.StateCode
import
net.mamoe.mirai.api.http.dto.StateCode
...
@@ -10,6 +12,9 @@ import net.mamoe.mirai.api.http.dto.StateCode
...
@@ -10,6 +12,9 @@ import net.mamoe.mirai.api.http.dto.StateCode
fun
Application
.
groupManageModule
()
{
fun
Application
.
groupManageModule
()
{
routing
{
routing
{
/**
* 禁言
*/
miraiVerify
<
MuteDTO
>(
"/muteAll"
)
{
miraiVerify
<
MuteDTO
>(
"/muteAll"
)
{
it
.
session
.
bot
.
getGroup
(
it
.
target
).
muteAll
=
true
it
.
session
.
bot
.
getGroup
(
it
.
target
).
muteAll
=
true
call
.
respondStateCode
(
StateCode
.
Success
)
call
.
respondStateCode
(
StateCode
.
Success
)
...
@@ -21,7 +26,7 @@ fun Application.groupManageModule() {
...
@@ -21,7 +26,7 @@ fun Application.groupManageModule() {
}
}
miraiVerify
<
MuteDTO
>(
"/mute"
)
{
miraiVerify
<
MuteDTO
>(
"/mute"
)
{
when
(
it
.
session
.
bot
.
getGroup
(
it
.
target
)
.
members
[
it
.
member
].
mute
(
it
.
time
))
{
when
(
it
.
session
.
bot
.
getGroup
(
it
.
target
)[
it
.
member
].
mute
(
it
.
time
))
{
true
->
call
.
respondStateCode
(
StateCode
.
Success
)
true
->
call
.
respondStateCode
(
StateCode
.
Success
)
else
->
throw
PermissionDeniedException
else
->
throw
PermissionDeniedException
}
}
...
@@ -34,5 +39,27 @@ fun Application.groupManageModule() {
...
@@ -34,5 +39,27 @@ fun Application.groupManageModule() {
}
}
}
}
/**
* 群设置(需要相关权限)
*/
miraiGet
(
"/groupConfig"
)
{
val
group
=
it
.
bot
.
getGroup
(
paramOrNull
(
"target"
))
call
.
respondDTO
(
GroupInfoDTO
(
group
))
}
miraiVerify
<
GroupConfigDTO
>(
"/groupConfig"
)
{
dto
->
val
group
=
dto
.
session
.
bot
.
getGroup
(
dto
.
target
)
with
(
dto
.
config
)
{
name
?.
let
{
group
.
name
=
it
}
announcement
?.
let
{
group
.
announcement
=
it
}
confessTalk
?.
let
{
group
.
confessTalk
=
it
}
allowMemberInvite
?.
let
{
group
.
allowMemberInvite
=
it
}
// TODO: 待core接口实现设置可改
// autoApprove?.let { group.autoApprove = it }
// anonymousChat?.let { group.anonymousChat = it }
}
call
.
respondStateCode
(
StateCode
.
Success
)
}
}
}
}
}
\ 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