diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt index 4437083f2..2d99334ec 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/dto/VerifyDTO.kt @@ -4,6 +4,7 @@ import kotlinx.serialization.Serializable import kotlinx.serialization.Transient import net.mamoe.mirai.api.http.AuthedSession import net.mamoe.mirai.contact.Group +import net.mamoe.mirai.contact.Member @Serializable abstract class VerifyDTO : DTO { @@ -60,6 +61,22 @@ data class GroupInfoDTO( ) } +@Serializable +data class MemberConfigDTO( + override val sessionKey: String, + val target: Long, + val memberID: Long, + val config: MemberInfoDTO +) : VerifyDTO() + +@Serializable +data class MemberInfoDTO( + val name: String? = null, + val specialTitle: String? = null +) : DTO { + constructor(member: Member) : this(member.groupCard, member.specialTitle) +} + @Serializable open class StateCode(val code: Int, var msg: String) { object Success : StateCode(0, "success") // 成功 diff --git a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt index d97c27ac7..faeb737ac 100644 --- a/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt +++ b/mirai-api-http/src/main/kotlin/net/mamoe/mirai/api/http/route/GroupManageModule.kt @@ -3,17 +3,14 @@ package net.mamoe.mirai.api.http.route import io.ktor.application.Application import io.ktor.application.call 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.StateCode +import net.mamoe.mirai.api.http.dto.* fun Application.groupManageModule() { routing { /** - * 禁言 + * 禁言(需要相关权限) */ miraiVerify("/muteAll") { it.session.bot.getGroup(it.target).muteAll = true @@ -61,5 +58,22 @@ fun Application.groupManageModule() { call.respondStateCode(StateCode.Success) } + /** + * 群员信息管理(需要相关权限) + */ + miraiGet("/memberInfo") { + val member = it.bot.getGroup(paramOrNull("target"))[paramOrNull("memberID")] + call.respondDTO(MemberInfoDTO(member)) + } + + miraiVerify("/memberInfo") { dto -> + val member = dto.session.bot.getGroup(dto.target)[dto.memberID] + with(dto.config) { + name?.let { member.groupCard = it } + specialTitle?.let { member.specialTitle = it } + } + call.respondStateCode(StateCode.Success) + } + } } \ No newline at end of file