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
830f7306
Commit
830f7306
authored
Feb 15, 2020
by
ryoii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http api handle PermissionDeniedException
parent
baa3e56d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
18 deletions
+7
-18
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/Exception.kt
...rc/main/kotlin/net/mamoe/mirai/api/http/data/Exception.kt
+0
-5
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
...c/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
+1
-0
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt
.../net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt
+6
-13
No files found.
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/data/Exception.kt
View file @
830f7306
...
...
@@ -27,11 +27,6 @@ object NotVerifiedSessionException : IllegalAccessException("Session未激活")
*/
object
NoSuchBotException
:
IllegalAccessException
(
"指定Bot不存在"
)
/**
* 指定Bot不存在
*/
object
PermissionDeniedException
:
IllegalAccessException
(
"无操作限权"
)
/**
* 错误参数
*/
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/BaseRoute.kt
View file @
830f7306
...
...
@@ -35,6 +35,7 @@ import net.mamoe.mirai.api.http.data.common.DTO
import
net.mamoe.mirai.api.http.data.common.VerifyDTO
import
net.mamoe.mirai.api.http.util.jsonParseOrNull
import
net.mamoe.mirai.api.http.util.toJson
import
net.mamoe.mirai.contact.PermissionDeniedException
import
org.slf4j.Logger
import
org.slf4j.helpers.NOPLogger
import
org.slf4j.helpers.NOPLoggerFactory
...
...
mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageRouteModule.kt
View file @
830f7306
...
...
@@ -4,7 +4,6 @@ import io.ktor.application.Application
import
io.ktor.application.call
import
io.ktor.routing.routing
import
kotlinx.serialization.Serializable
import
net.mamoe.mirai.api.http.data.PermissionDeniedException
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
...
...
@@ -29,27 +28,21 @@ fun Application.groupManageModule() {
}
miraiVerify
<
MuteDTO
>(
"/mute"
)
{
when
(
it
.
session
.
bot
.
getGroup
(
it
.
target
)[
it
.
memberId
].
mute
(
it
.
time
))
{
true
->
call
.
respondStateCode
(
StateCode
.
Success
)
else
->
throw
PermissionDeniedException
}
it
.
session
.
bot
.
getGroup
(
it
.
target
)[
it
.
memberId
].
mute
(
it
.
time
)
call
.
respondStateCode
(
StateCode
.
Success
)
}
miraiVerify
<
MuteDTO
>(
"/unmute"
)
{
when
(
it
.
session
.
bot
.
getGroup
(
it
.
target
).
members
[
it
.
memberId
].
unmute
())
{
true
->
call
.
respondStateCode
(
StateCode
.
Success
)
else
->
throw
PermissionDeniedException
}
it
.
session
.
bot
.
getGroup
(
it
.
target
).
members
[
it
.
memberId
].
unmute
()
call
.
respondStateCode
(
StateCode
.
Success
)
}
/**
* 移出群聊(需要相关权限)
*/
miraiVerify
<
KickDTO
>(
"/kick"
)
{
when
(
it
.
session
.
bot
.
getGroup
(
it
.
target
)[
it
.
memberId
].
kick
(
it
.
msg
))
{
true
->
call
.
respondStateCode
(
StateCode
.
Success
)
else
->
throw
PermissionDeniedException
}
it
.
session
.
bot
.
getGroup
(
it
.
target
)[
it
.
memberId
].
kick
(
it
.
msg
)
call
.
respondStateCode
(
StateCode
.
Success
)
}
/**
...
...
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