mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 18:02:58 +08:00
http-api support kick
This commit is contained in:
parent
2687b55f8b
commit
cf82401eed
@ -28,14 +28,24 @@ fun Application.groupManageModule() {
|
||||
}
|
||||
|
||||
miraiVerify<MuteDTO>("/mute") {
|
||||
when(it.session.bot.getGroup(it.target)[it.memberId].mute(it.time)) {
|
||||
when (it.session.bot.getGroup(it.target)[it.memberId].mute(it.time)) {
|
||||
true -> call.respondStateCode(StateCode.Success)
|
||||
else -> throw PermissionDeniedException
|
||||
}
|
||||
}
|
||||
|
||||
miraiVerify<MuteDTO>("/unmute") {
|
||||
when(it.session.bot.getGroup(it.target).members[it.memberId].unmute()) {
|
||||
when (it.session.bot.getGroup(it.target).members[it.memberId].unmute()) {
|
||||
true -> call.respondStateCode(StateCode.Success)
|
||||
else -> throw PermissionDeniedException
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移出群聊(需要相关权限)
|
||||
*/
|
||||
miraiVerify<KickDTO>("/kick") {
|
||||
when (it.session.bot.getGroup(it.target)[it.memberId].kick(it.msg)) {
|
||||
true -> call.respondStateCode(StateCode.Success)
|
||||
else -> throw PermissionDeniedException
|
||||
}
|
||||
@ -55,7 +65,7 @@ fun Application.groupManageModule() {
|
||||
name?.let { group.name = it }
|
||||
announcement?.let { group.announcement = it }
|
||||
confessTalk?.let { group.confessTalk = it }
|
||||
allowMemberInvite?.let{ group.allowMemberInvite = it }
|
||||
allowMemberInvite?.let { group.allowMemberInvite = it }
|
||||
// TODO: 待core接口实现设置可改
|
||||
// autoApprove?.let { group.autoApprove = it }
|
||||
// anonymousChat?.let { group.anonymousChat = it }
|
||||
@ -92,6 +102,14 @@ private data class MuteDTO(
|
||||
val time: Int = 0
|
||||
) : VerifyDTO()
|
||||
|
||||
@Serializable
|
||||
private data class KickDTO(
|
||||
override val sessionKey: String,
|
||||
val target: Long,
|
||||
val memberId: Long,
|
||||
val msg: String = ""
|
||||
) : VerifyDTO()
|
||||
|
||||
@Serializable
|
||||
private data class GroupConfigDTO(
|
||||
override val sessionKey: String,
|
||||
@ -128,4 +146,4 @@ private data class MemberDetailDTO(
|
||||
val specialTitle: String? = null
|
||||
) : DTO {
|
||||
constructor(member: Member) : this(member.groupCard, member.specialTitle)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user