mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 05:12:17 +00:00
Compare commits
2 Commits
103381c17a
...
a22dc50f14
Author | SHA1 | Date | |
---|---|---|---|
a22dc50f14 | |||
e629981218 |
@ -37,6 +37,7 @@ data class Oidb0xf57Meta(
|
||||
@ProtoNumber(18) val ownerId: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(19) val coverSeq: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(20) val clientId: Int = Int.MIN_VALUE,
|
||||
@ProtoNumber(27) val displayId: String? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@ -72,7 +73,10 @@ data class Oidb0xf57U1(
|
||||
@ProtoNumber(5003) val u18: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(5004) val u19: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(5005) val u20: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(5006) val u23: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(10007) val u21: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(15) val u22: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(30001) val u24: UInt = UInt.MIN_VALUE,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
@ -85,4 +89,11 @@ data class Oidb0xf57U2(
|
||||
@ProtoNumber(15) val u6: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(16) val u7: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(17) val u8: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(32) val u9: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(31) val u10: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(29) val u11: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(26) val u12: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(23) val u13: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(22) val u14: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(18) val u15: UInt = UInt.MIN_VALUE,
|
||||
)
|
||||
|
@ -24,8 +24,6 @@ public final class GProRoleMemberList {
|
||||
}
|
||||
|
||||
public GProRoleMemberList(GProGuildRole gProGuildRole, ArrayList<GProUser> arrayList) {
|
||||
this.role = new GProGuildRole();
|
||||
this.members = new ArrayList<>();
|
||||
this.role = gProGuildRole;
|
||||
this.members = arrayList;
|
||||
}
|
||||
|
@ -3,5 +3,5 @@ package com.tencent.qqnt.kernel.nativeinterface;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface IGProFetchMemberListWithRoleCallback {
|
||||
void onFetchMemberListWithRoleCallback(int result, String reason, boolean finish, long nextIndex, long nextRoleIdIndex, boolean isSmallGuild, int u, ArrayList<GProRoleMemberList> roleList);
|
||||
void onFetchMemberListWithRoleCallback(int result, String reason, boolean finish, long nextIndex, long nextRoleIdIndex, boolean isSmallGuild, int seq, ArrayList<GProRoleMemberList> roleList);
|
||||
}
|
||||
|
@ -4,14 +4,19 @@ package moe.fuqiuluo.qqinterface.servlet
|
||||
|
||||
import com.tencent.mobileqq.qqguildsdk.api.IGPSService
|
||||
import com.tencent.qqnt.kernel.nativeinterface.GProRoleMemberList
|
||||
import com.tencent.qqnt.kernel.nativeinterface.GProUser
|
||||
import com.tencent.qqnt.kernel.nativeinterface.IGProGetUserInfoCallback
|
||||
import com.tencent.qqnt.kernel.nativeinterface.IGProFetchMemberListWithRoleCallback
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.coroutines.withTimeoutOrNull
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.decodeFromByteArray
|
||||
import kotlinx.serialization.encodeToByteArray
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GProChannelInfo
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GetGuildMemberListNextToken
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GuildInfo
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GuildStatus
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.SlowModeInfo
|
||||
import moe.fuqiuluo.shamrock.helper.Level
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
import moe.fuqiuluo.shamrock.tools.slice
|
||||
import moe.fuqiuluo.shamrock.utils.PlatformUtils
|
||||
@ -22,14 +27,13 @@ import moe.whitechi73.protobuf.oidb.cmd0xf88.Oidb0xf88Req
|
||||
import moe.whitechi73.protobuf.oidb.cmd0xf88.Oidb0xf88Rsp
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57Filter
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57GuildInfo
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57Meta
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57MetaInfo
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57Req
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57Rsp
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57U1
|
||||
import moe.whitechi73.protobuf.oidb.cmx0xf57.Oidb0xf57U2
|
||||
import tencent.im.oidb.cmd0xeac.oidb_0xeac
|
||||
import tencent.im.oidb.oidb_sso
|
||||
import kotlin.coroutines.resume
|
||||
|
||||
internal object GProSvc: BaseSvc() {
|
||||
fun getSelfTinyId(): ULong {
|
||||
@ -40,8 +44,8 @@ internal object GProSvc: BaseSvc() {
|
||||
suspend fun getGuildInfo(guildId: ULong): Result<Oidb0xf57MetaInfo> {
|
||||
val respBuffer = sendOidbAW("OidbSvcTrpcTcp.0xf57_9", 0xf57, 9, ProtoBuf.encodeToByteArray(Oidb0xf57Req(
|
||||
filter = Oidb0xf57Filter(
|
||||
u1 = Oidb0xf57U1(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u),
|
||||
u2 = Oidb0xf57U2(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)
|
||||
u1 = Oidb0xf57U1(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u),
|
||||
u2 = Oidb0xf57U2(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u)
|
||||
),
|
||||
guildInfo = Oidb0xf57GuildInfo(guildId = guildId)
|
||||
)))
|
||||
@ -57,11 +61,78 @@ internal object GProSvc: BaseSvc() {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGuildMemberList(guildId: ULong): Result<List<GProRoleMemberList>> {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
//kernelGProService.fetchMemberListWithRole()
|
||||
fun getChannelList(guildId: ULong, refresh: Boolean = false): Result<ArrayList<GProChannelInfo>> {
|
||||
if (refresh) {
|
||||
refreshGuildInfo(guildId)
|
||||
}
|
||||
val result = arrayListOf<GProChannelInfo>()
|
||||
app.getRuntimeService(IGPSService::class.java, "all").getChannelList(guildId.toString()).forEach {
|
||||
result.add(GProChannelInfo(
|
||||
ownerGuildId = guildId,
|
||||
guildId = it.guildId,
|
||||
channelId = it.channelUin.toLong(),
|
||||
channelUin = it.channelUin.toLong(),
|
||||
channelName = it.channelName ?: "",
|
||||
channelType = it.type,
|
||||
createTime = it.createTime,
|
||||
creatorTinyId = it.creatorId.toLong(),
|
||||
talkPermission = it.talkPermission,
|
||||
visibleType = it.visibleType,
|
||||
currentSlowMode = it.slowModeKey,
|
||||
slowModes = it.gProSlowModeInfoList.map {
|
||||
SlowModeInfo(it.slowModeKey, it.slowModeText, it.speakFrequency, it.slowModeCircle)
|
||||
},
|
||||
appIconUrl = it.iconUrl,
|
||||
jumpType = it.appChannelJumpType,
|
||||
jumpSwitch = it.jumpSwitch,
|
||||
jumpUrl = it.appChannelJumpUrl,
|
||||
categoryId = it.categoryId,
|
||||
myTalkPermission = it.myTalkPermissionType,
|
||||
maxMemberCount = it.channelMemberMax
|
||||
))
|
||||
}
|
||||
return Result.success(result)
|
||||
}
|
||||
|
||||
return Result.failure(Exception("todo"))
|
||||
fun refreshGuildInfo(guildId: ULong) {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
kernelGProService.refreshGuildInfo(guildId.toLong(), true, 1)
|
||||
}
|
||||
|
||||
suspend fun getGuildMemberList(
|
||||
guildId: ULong,
|
||||
startIndex: Long = 0,
|
||||
roleIndex: Long = 1,
|
||||
count: Int = 50,
|
||||
fetchAll: Boolean = false,
|
||||
result: ArrayList<GProRoleMemberList> = arrayListOf()
|
||||
): Result<Pair<GetGuildMemberListNextToken, ArrayList<GProRoleMemberList>>> {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
val fetchGuildMemberListResult: Pair<GetGuildMemberListNextToken, ArrayList<GProRoleMemberList>> = (withTimeoutOrNull(5000) {
|
||||
suspendCancellableCoroutine {
|
||||
kernelGProService.fetchMemberListWithRole(guildId.toLong(), 0, startIndex, roleIndex, count, 0) { code, reason, finish, nextIndex, nextRoleIdIndex, _, seq, roleList ->
|
||||
if (code == 0) {
|
||||
it.resume(GetGuildMemberListNextToken(nextIndex, nextRoleIdIndex, seq, finish) to roleList)
|
||||
} else {
|
||||
LogCenter.log("fetchMemberListWithRole failed: $code($reason)", Level.WARN)
|
||||
it.resume(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
}) ?: return Result.failure(Exception("unable to fetch guild member list"))
|
||||
|
||||
val nextToken = fetchGuildMemberListResult.first
|
||||
val roleList = fetchGuildMemberListResult.second
|
||||
result.addAll(roleList)
|
||||
return if (fetchAll) {
|
||||
if (!fetchGuildMemberListResult.first.finish) {
|
||||
getGuildMemberList(guildId, nextToken.startIndex, nextToken.roleIndex, count, true, result)
|
||||
} else {
|
||||
Result.success(nextToken.copy(finish = true) to result)
|
||||
}
|
||||
} else {
|
||||
Result.success(nextToken to result)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getSelfGuildInfo(): Result<GProUserInfo> {
|
||||
@ -91,18 +162,27 @@ internal object GProSvc: BaseSvc() {
|
||||
}
|
||||
}
|
||||
|
||||
fun getGuildList(refresh: Boolean = false): ArrayList<GuildInfo> {
|
||||
PlatformUtils.requireMinQQVersion(version = PlatformUtils.QQ_9_0_8_VER)
|
||||
private fun getGuildListByOldApi(result: ArrayList<GuildInfo>) {
|
||||
app.getRuntimeService(IGPSService::class.java, "all").guildList?.forEach {
|
||||
result.add(GuildInfo(
|
||||
guildId = it.guildID.toLong(),
|
||||
guildName = it.guildName ?: "",
|
||||
guildDisplayId = it.guildNumber ?: "",
|
||||
profile = it.profile ?: "",
|
||||
status = GuildStatus(
|
||||
isEnable = !it.isFrozen && !it.isBanned,
|
||||
isBanned = it.isBanned,
|
||||
isFrozen = it.isFrozen
|
||||
),
|
||||
ownerId = 0,
|
||||
shutUpTime = it.shutUpExpireTime,
|
||||
allowSearch = it.allowSearch
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
private fun getGuildListByNt(result: ArrayList<GuildInfo>) {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
if (refresh) {
|
||||
kernelGProService.refreshGuildList(true)
|
||||
kernelGProService.guildListFromCache.forEach {
|
||||
kernelGProService.refreshGuildInfo(it.guildId, true, 1)
|
||||
}
|
||||
}
|
||||
|
||||
val result = arrayListOf<GuildInfo>()
|
||||
kernelGProService.guildListFromCache.forEach {
|
||||
if (it.result != 0) return@forEach
|
||||
val guildInfo = it.guildInfo
|
||||
@ -121,6 +201,27 @@ internal object GProSvc: BaseSvc() {
|
||||
allowSearch = guildInfo.allowSearch == 1
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fun getGuildList(refresh: Boolean = false, forceOldApi: Boolean): ArrayList<GuildInfo> {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
if (refresh) {
|
||||
kernelGProService.refreshGuildList(true)
|
||||
kernelGProService.guildListFromCache.forEach {
|
||||
refreshGuildInfo(it.guildId.toULong())
|
||||
}
|
||||
}
|
||||
val result = arrayListOf<GuildInfo>()
|
||||
if (PlatformUtils.getQQVersionCode() < PlatformUtils.QQ_9_0_8_VER || forceOldApi) {
|
||||
getGuildListByOldApi(result)
|
||||
} else {
|
||||
runCatching {
|
||||
getGuildListByNt(result)
|
||||
}.onFailure {
|
||||
LogCenter.log("GetGuildListByNt failed: ${it.stackTraceToString()}", Level.ERROR)
|
||||
getGuildListByOldApi(result) // 防止QQ更新API导致无法获取
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
@ -21,3 +21,58 @@ data class GuildStatus(
|
||||
@SerialName("is_banned") var isBanned: Boolean,
|
||||
@SerialName("is_frozen") var isFrozen: Boolean
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GProChannelInfo(
|
||||
@SerialName("owner_guild_id") val ownerGuildId: ULong,
|
||||
@SerialName("channel_id") val channelId: Long,
|
||||
@SerialName("channel_uin") val channelUin: Long,
|
||||
@SerialName("guild_id") val guildId: String,
|
||||
@SerialName("channel_type") val channelType: Int,
|
||||
@SerialName("channel_name") val channelName: String,
|
||||
@SerialName("create_time") val createTime: Long,
|
||||
@SerialName("max_member_count") val maxMemberCount: Int,
|
||||
@SerialName("creator_tiny_id") val creatorTinyId: Long,
|
||||
@SerialName("talk_permission") val talkPermission: Int,
|
||||
@SerialName("visible_type") val visibleType: Int,
|
||||
@SerialName("current_slow_mode") val currentSlowMode: Int,
|
||||
@SerialName("slow_modes") val slowModes: List<SlowModeInfo>,
|
||||
@SerialName("icon_url") val appIconUrl: String? = null,
|
||||
@SerialName("jump_switch") val jumpSwitch: Int = Int.MIN_VALUE,
|
||||
@SerialName("jump_type") val jumpType: Int = Int.MIN_VALUE,
|
||||
@SerialName("jump_url") val jumpUrl: String? = null,
|
||||
@SerialName("category_id") val categoryId: Long = Long.MIN_VALUE,
|
||||
@SerialName("my_talk_permission") val myTalkPermission: Int = Int.MIN_VALUE,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SlowModeInfo(
|
||||
@SerialName("slow_mode_key") val slowModeKey: Int,
|
||||
@SerialName("slow_mode_text") val slowModeText: String,
|
||||
@SerialName("speak_frequency") val speakFrequency: Int,
|
||||
@SerialName("slow_mode_circle") val slowModeCircle: Int
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GetGuildMemberListNextToken(
|
||||
@SerialName("start_index") val startIndex: Long,
|
||||
@SerialName("role_index") val roleIndex: Long,
|
||||
@SerialName("seq") val seq: Int,
|
||||
@SerialName("finish") val finish: Boolean
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class GuildMemberInfo(
|
||||
@SerialName("tiny_id") val tinyId: Long,
|
||||
@SerialName("title") val title: String,
|
||||
@SerialName("nickname") val nickname: String,
|
||||
@SerialName("role_id") val roleId: Long,
|
||||
@SerialName("role_name") val roleName: String,
|
||||
@SerialName("role_color") val roleColor: Long,
|
||||
@SerialName("join_time") val joinTime: Long,
|
||||
@SerialName("robot_type") val robotType: Int,
|
||||
@SerialName("type") val type: Int,
|
||||
@SerialName("in_black") val inBlack: Boolean,
|
||||
@SerialName("platform") val platform: Int,
|
||||
)
|
||||
|
||||
|
@ -0,0 +1,35 @@
|
||||
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.qqinterface.servlet.structures.GProChannelInfo
|
||||
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("get_guild_channel_list")
|
||||
internal object GetGProChannelList: IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
val guildId = session.getString("guild_id")
|
||||
val refresh = session.getBooleanOrDefault("refresh", session.getBooleanOrDefault("no_cache", false))
|
||||
return invoke(guildId.toULong(), refresh, echo = session.echo)
|
||||
}
|
||||
|
||||
operator fun invoke(guildId: ULong, refresh: Boolean, echo: JsonElement = EmptyJsonString): String {
|
||||
val result = GProSvc.getChannelList(guildId, refresh)
|
||||
result.onFailure {
|
||||
return error(it.message ?: "unable to fetch channel list", echo)
|
||||
}
|
||||
return ok(GuildChannelListResult(result.getOrThrow()), echo, "success")
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("guild_id")
|
||||
|
||||
@Serializable
|
||||
data class GuildChannelListResult(
|
||||
@SerialName("channel_list") val channelList: List<GProChannelInfo>
|
||||
)
|
||||
}
|
@ -18,11 +18,13 @@ import mqq.app.MobileQQ
|
||||
@OneBotHandler("get_guild_list")
|
||||
internal object GetGuildList : IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
return invoke(echo = session.echo)
|
||||
val oldSdk = session.getBooleanOrDefault("old_sdk", false)
|
||||
val refresh = session.getBooleanOrDefault("refresh", session.getBooleanOrDefault("no_cache", false))
|
||||
return invoke(refresh, oldSdk, echo = session.echo)
|
||||
}
|
||||
|
||||
operator fun invoke(refresh: Boolean = true, echo: JsonElement = EmptyJsonString): String {
|
||||
val result = GProSvc.getGuildList(refresh)
|
||||
operator fun invoke(refresh: Boolean = true, oldSdk: Boolean, echo: JsonElement = EmptyJsonString): String {
|
||||
val result = GProSvc.getGuildList(refresh, oldSdk)
|
||||
return ok(GuildListResult(result), echo, "success")
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,77 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromByteArray
|
||||
import kotlinx.serialization.encodeToByteArray
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import moe.fuqiuluo.qqinterface.servlet.GProSvc
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GetGuildMemberListNextToken
|
||||
import moe.fuqiuluo.qqinterface.servlet.structures.GuildMemberInfo
|
||||
import moe.fuqiuluo.shamrock.helper.LogCenter
|
||||
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.hex2ByteArray
|
||||
import moe.fuqiuluo.shamrock.tools.toHexString
|
||||
import moe.fuqiuluo.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("get_guild_member_list")
|
||||
internal object GetGuildMemberList: IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
val guildId = session.getString("guild_id")
|
||||
return invoke(guildId.toULong(), session.echo)
|
||||
val all = session.getBooleanOrDefault("all", false)
|
||||
return invoke(guildId.toULong(), all, session.getStringOrNull("next_token") ?: "", session.echo)
|
||||
}
|
||||
|
||||
suspend operator fun invoke(guildId: ULong, echo: JsonElement = EmptyJsonString): String {
|
||||
GProSvc.getGuildMemberList(guildId)
|
||||
return ""
|
||||
suspend operator fun invoke(guildId: ULong, all: Boolean, nextTokenStr: String, echo: JsonElement = EmptyJsonString): String {
|
||||
val curNextToken = if (nextTokenStr.isEmpty()) null else ProtoBuf.decodeFromByteArray<GetGuildMemberListNextToken>(nextTokenStr.hex2ByteArray())
|
||||
val result = GProSvc.getGuildMemberList(
|
||||
guildId = guildId,
|
||||
fetchAll = all,
|
||||
startIndex = curNextToken?.startIndex ?: 0,
|
||||
roleIndex = curNextToken?.roleIndex ?: 1,
|
||||
count = 50
|
||||
)
|
||||
result.onFailure {
|
||||
return error(it.message ?: "unable to fetch guild member list", echo)
|
||||
}
|
||||
val nextToken = result.getOrThrow().first
|
||||
val members = arrayListOf<GuildMemberInfo>()
|
||||
result.getOrThrow().second.forEach {
|
||||
it.members.forEach { user ->
|
||||
members.add(GuildMemberInfo(
|
||||
tinyId = user.tinyId,
|
||||
title = user.memberName,
|
||||
nickname = user.nickName,
|
||||
roleId = user.roleManagementTag.roleId,
|
||||
roleName = user.roleManagementTag.tagName,
|
||||
roleColor = user.roleManagementTag.color,
|
||||
joinTime = user.joinTime,
|
||||
robotType = user.robotType,
|
||||
type = user.type,
|
||||
inBlack = user.inBlack,
|
||||
platform = user.platform
|
||||
))
|
||||
}
|
||||
}
|
||||
return ok(GetGuildMemberListResult(
|
||||
members = members,
|
||||
finish = nextToken.finish,
|
||||
nextToken = ProtoBuf.encodeToByteArray(nextToken).toHexString(),
|
||||
))
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("guild_id")
|
||||
|
||||
@Serializable
|
||||
data class GetGuildMemberListResult(
|
||||
@SerialName("members") val members: List<GuildMemberInfo>,
|
||||
@SerialName("next_token") val nextToken: String,
|
||||
@SerialName("finished") val finish: Boolean
|
||||
)
|
||||
}
|
@ -3,6 +3,7 @@ package moe.fuqiuluo.shamrock.remote.action.handlers
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.JsonElement
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
import moe.fuqiuluo.qqinterface.servlet.GProSvc
|
||||
import moe.fuqiuluo.shamrock.remote.action.ActionSession
|
||||
import moe.fuqiuluo.shamrock.remote.action.IActionHandler
|
||||
@ -35,7 +36,8 @@ internal object GetGuildMetaByGuest: IActionHandler() {
|
||||
maxRobotCount = meta.robotMaxNum,
|
||||
maxAdminCount = meta.adminMaxNum,
|
||||
memberCount = meta.memberCount,
|
||||
ownerId = meta.ownerId
|
||||
ownerId = meta.ownerId,
|
||||
guildDisplayId = meta.displayId ?: ""
|
||||
), echo)
|
||||
}
|
||||
|
||||
@ -52,5 +54,6 @@ internal object GetGuildMetaByGuest: IActionHandler() {
|
||||
@SerialName("max_admin_count") val maxAdminCount: Int,
|
||||
@SerialName("member_count") val memberCount: Long,
|
||||
@SerialName("owner_id") val ownerId: ULong,
|
||||
@SerialName("guild_display_id") val guildDisplayId: String
|
||||
)
|
||||
}
|
@ -4,10 +4,13 @@ import io.ktor.http.ContentType
|
||||
import io.ktor.server.application.call
|
||||
import io.ktor.server.response.respondText
|
||||
import io.ktor.server.routing.Routing
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGProChannelList
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildList
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildMemberList
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildMetaByGuest
|
||||
import moe.fuqiuluo.shamrock.remote.action.handlers.GetGuildServiceProfile
|
||||
import moe.fuqiuluo.shamrock.tools.fetchGetOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrNull
|
||||
import moe.fuqiuluo.shamrock.tools.fetchOrThrow
|
||||
import moe.fuqiuluo.shamrock.tools.getOrPost
|
||||
|
||||
@ -17,16 +20,24 @@ fun Routing.guildAction() {
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_list") {
|
||||
call.respondText(GetGuildList(), ContentType.Application.Json)
|
||||
val refresh = fetchGetOrNull("refresh") ?: fetchOrNull("no_cache")
|
||||
call.respondText(GetGuildList(refresh?.toBoolean() ?: false, false), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_member_list") {
|
||||
val guildId = fetchOrThrow("guild_id")
|
||||
call.respondText(GetGuildMemberList(guildId.toULong()), ContentType.Application.Json)
|
||||
val all = fetchGetOrNull("all")?.toBoolean() ?: false
|
||||
call.respondText(GetGuildMemberList(guildId.toULong(), all, fetchOrNull("next_token") ?: ""), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_meta_by_guest") {
|
||||
val guildId = fetchOrThrow("guild_id")
|
||||
call.respondText(GetGuildMetaByGuest(guildId.toULong()), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_channel_list") {
|
||||
val guildId = fetchOrThrow("guild_id")
|
||||
val refresh = fetchGetOrNull("refresh") ?: fetchOrNull("no_cache")
|
||||
call.respondText(GetGProChannelList(guildId.toULong(), refresh?.toBoolean() ?: false), ContentType.Application.Json)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user