This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shamrock
: support /create_guild_role
- Loading branch information
1 parent
7bfb9b7
commit fb00e5c
Showing
8 changed files
with
149 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
...erface/src/main/java/com/tencent/qqnt/kernel/nativeinterface/IGProCreateRoleCallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.tencent.qqnt.kernel.nativeinterface; | ||
|
||
public interface IGProCreateRoleCallback { | ||
void onCreateRoleResult(int code, String msg, GProSecurityResult result, GProGuildRole role); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/CreateGuildRole.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@file:Suppress("UNCHECKED_CAST") | ||
|
||
package moe.fuqiuluo.shamrock.remote.action.handlers | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
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.shamrock.tools.asString | ||
import moe.fuqiuluo.symbols.OneBotHandler | ||
|
||
@OneBotHandler("create_guild_role") | ||
internal object CreateGuildRole: IActionHandler() { | ||
override suspend fun internalHandle(session: ActionSession): String { | ||
val guildId = session.getString("guild_id").toULong() | ||
val name = session.getString("name") | ||
val color = session.getLong("color") | ||
val initialUsers = session.getArray("initial_users").map { | ||
it.asString.toULong() | ||
} | ||
return invoke(guildId, color, name, initialUsers, session.echo) | ||
} | ||
|
||
suspend operator fun invoke(guildId: ULong, color: Long, name: String, initialUsers: List<ULong>, echo: JsonElement = EmptyJsonString): String { | ||
val result = GProSvc.createGuildRole(guildId, name, color, initialUsers as ArrayList<Long>).onFailure { | ||
return error(it.message ?: "Unknown error", echo) | ||
}.getOrThrow() | ||
return ok(data = CreateGuildRoleResult( | ||
result.roleId.toULong() | ||
), echo = echo) | ||
} | ||
|
||
override val requiredParams: Array<String> = arrayOf("guild_id", "color", "name", "initial_users") | ||
|
||
@Serializable | ||
data class CreateGuildRoleResult( | ||
@SerialName("role_id") val roleId: ULong | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
xposed/src/main/java/moe/fuqiuluo/shamrock/remote/action/handlers/UpdateGuildRole.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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("update_guild_role") | ||
internal object UpdateGuildRole: IActionHandler() { | ||
override suspend fun internalHandle(session: ActionSession): String { | ||
val guildId = session.getString("guild_id").toULong() | ||
val roleId = session.getString("role_id").toULong() | ||
val name = session.getString("name") | ||
val color = session.getLong("color") | ||
return invoke(guildId, roleId, name, color, session.echo) | ||
} | ||
|
||
suspend operator fun invoke(guildId: ULong, roleId: ULong, name: String, color: Long, echo: JsonElement = EmptyJsonString): String { | ||
val result = GProSvc.updateGuildRole(guildId, roleId, name, color).onFailure { | ||
return error(it.message ?: "Unknown error", echo) | ||
} | ||
return ok("success", echo = echo) | ||
} | ||
|
||
override val requiredParams: Array<String> = arrayOf("role_id", "guild_id", "name", "color") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters