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 /set_guild_member_role
- Loading branch information
1 parent
c436898
commit 7bfb9b7
Showing
4 changed files
with
75 additions
and
0 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
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/SetGuildMemberRole.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 @@ | ||
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.shamrock.tools.asString | ||
import moe.fuqiuluo.symbols.OneBotHandler | ||
|
||
@OneBotHandler("set_guild_member_role") | ||
internal object SetGuildMemberRole: IActionHandler() { | ||
override suspend fun internalHandle(session: ActionSession): String { | ||
val guildId = session.getString("guild_id").toULong() | ||
val role = session.getString("role_id").toULong() | ||
val set = session.getBooleanOrDefault("set", false) | ||
return if (session.has("user_id")) { | ||
val userId = session.getString("user_id").toULong() | ||
invoke(guildId, userId, role, set, echo = session.echo) | ||
} else if (session.isArray("users")) { | ||
invoke(guildId, session.getArray("users").map { | ||
it.asString.toULong() | ||
}, role, set, echo = session.echo) | ||
} else { | ||
logic("missing user_id or users", echo = session.echo) | ||
} | ||
} | ||
|
||
operator fun invoke(guildId: ULong, users: List<ULong>, roleId: ULong, set: Boolean, echo: JsonElement = EmptyJsonString): String { | ||
users.forEach { | ||
GProSvc.setMemberRole(guildId, it, roleId, set) | ||
} | ||
return ok("success", echo = echo) | ||
} | ||
|
||
operator fun invoke(guildId: ULong, user: ULong, roleId: ULong, set: Boolean, echo: JsonElement = EmptyJsonString): String { | ||
GProSvc.setMemberRole(guildId, user, roleId, set) | ||
return ok("success", echo = echo) | ||
} | ||
|
||
override val requiredParams: Array<String> = arrayOf("guild_id", "role_id") | ||
} |
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