mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: support /delete_guild_role
This commit is contained in:
parent
7952453137
commit
c43689822b
@ -0,0 +1,5 @@
|
|||||||
|
package com.tencent.qqnt.kernel.nativeinterface;
|
||||||
|
|
||||||
|
public interface IGProResultCallback {
|
||||||
|
void onResult(int code, String msg, GProSecurityResult result);
|
||||||
|
}
|
@ -65,4 +65,8 @@ public interface IKernelGuildService {
|
|||||||
String getGuildUserAvatarUrl(long guildId, long tinyId, int seq);
|
String getGuildUserAvatarUrl(long guildId, long tinyId, int seq);
|
||||||
|
|
||||||
String getGuildUserNickname(long guildId);
|
String getGuildUserNickname(long guildId);
|
||||||
|
|
||||||
|
void deleteRole(long guild, long role, IGProResultCallback cb);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -296,4 +296,13 @@ internal object GProSvc: BaseSvc() {
|
|||||||
} ?: return Result.failure(Exception("unable to fetch guild roles"))
|
} ?: return Result.failure(Exception("unable to fetch guild roles"))
|
||||||
return Result.success(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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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<String> = arrayOf("guild_id", "role_id")
|
||||||
|
}
|
@ -8,6 +8,7 @@ import io.ktor.server.routing.get
|
|||||||
import io.ktor.server.routing.post
|
import io.ktor.server.routing.post
|
||||||
import io.ktor.server.routing.route
|
import io.ktor.server.routing.route
|
||||||
import moe.fuqiuluo.shamrock.helper.MessageHelper
|
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.GetGProChannelList
|
||||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildFeeds
|
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildFeeds
|
||||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildList
|
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildList
|
||||||
@ -123,4 +124,10 @@ fun Routing.guildAction() {
|
|||||||
val guildId = fetchOrThrow("guild_id").toULong()
|
val guildId = fetchOrThrow("guild_id").toULong()
|
||||||
call.respondText(GetGuildRoles(guildId), ContentType.Application.Json)
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user