diff --git a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IGProResultCallback.java b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IGProResultCallback.java new file mode 100644 index 00000000..a5a4a9fa --- /dev/null +++ b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IGProResultCallback.java @@ -0,0 +1,5 @@ +package com.tencent.qqnt.kernel.nativeinterface; + +public interface IGProResultCallback { + void onResult(int code, String msg, GProSecurityResult result); +} diff --git a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IKernelGuildService.java b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IKernelGuildService.java index 22ebca62..5e6012e1 100644 --- a/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IKernelGuildService.java +++ b/qqinterface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IKernelGuildService.java @@ -65,4 +65,8 @@ public interface IKernelGuildService { String getGuildUserAvatarUrl(long guildId, long tinyId, int seq); String getGuildUserNickname(long guildId); + + void deleteRole(long guild, long role, IGProResultCallback cb); + + } diff --git a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GProSvc.kt b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GProSvc.kt index e0aa48dc..99a15be8 100644 --- a/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GProSvc.kt +++ b/xposed/src/main/java/moe/fuqiuluo/qqinterface/servlet/GProSvc.kt @@ -296,4 +296,13 @@ internal object GProSvc: BaseSvc() { } ?: return Result.failure(Exception("unable to fetch guild roles")) return Result.success(roles) } + + fun deleteGuildRole(guildId: ULong, roleId: ULong) { + val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService + kernelGProService.deleteRole(guildId.toLong(), roleId.toLong()) { code, msg, result -> + if (code != 0) { + LogCenter.log("deleteGuildRole failed: $code($msg) => $result", Level.WARN) + } + } + } } \ No newline at end of file diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/DeleteGuildRole.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/DeleteGuildRole.kt new file mode 100644 index 00000000..754368c2 --- /dev/null +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/DeleteGuildRole.kt @@ -0,0 +1,24 @@ +package moe.fuqiuluo.shamrock.remote.action.handlers + +import kotlinx.serialization.json.JsonElement +import moe.fuqiuluo.qqinterface.servlet.GProSvc +import moe.fuqiuluo.shamrock.remote.action.ActionSession +import moe.fuqiuluo.shamrock.remote.action.IActionHandler +import moe.fuqiuluo.shamrock.tools.EmptyJsonString +import moe.fuqiuluo.symbols.OneBotHandler + +@OneBotHandler("delete_guild_role") +internal object DeleteGuildRole: IActionHandler() { + override suspend fun internalHandle(session: ActionSession): String { + val guildId = session.getString("guild_id").toULong() + val roleId = session.getString("role_id").toULong() + return invoke(guildId, roleId, session.echo) + } + + operator fun invoke(guildId: ULong, roleId: ULong, echo: JsonElement = EmptyJsonString): String { + GProSvc.deleteGuildRole(guildId, roleId) + return ok("success", echo = echo) + } + + override val requiredParams: Array = arrayOf("guild_id", "role_id") +} \ No newline at end of file diff --git a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/GuildAction.kt b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/GuildAction.kt index cfc7484e..a3504a34 100644 --- a/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/GuildAction.kt +++ b/xposed/src/main/java/moe/fuqiuluo/shamrock/remote/api/GuildAction.kt @@ -8,6 +8,7 @@ import io.ktor.server.routing.get import io.ktor.server.routing.post import io.ktor.server.routing.route import moe.fuqiuluo.shamrock.helper.MessageHelper +import moe.fuqiuluo.shamrock.remote.action.handlers.DeleteGuildRole import moe.fuqiuluo.shamrock.remote.action.handlers.GetGProChannelList import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildFeeds import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildList @@ -123,4 +124,10 @@ fun Routing.guildAction() { val guildId = fetchOrThrow("guild_id").toULong() call.respondText(GetGuildRoles(guildId), ContentType.Application.Json) } + + getOrPost("/delete_guild_role") { + val guildId = fetchOrThrow("guild_id").toULong() + val roleId = fetchOrThrow("role_id").toULong() + call.respondText(DeleteGuildRole(guildId, roleId), ContentType.Application.Json) + } } \ No newline at end of file