mirror of
https://github.com/whitechi73/OpenShamrock.git
synced 2024-08-14 13:12:17 +08:00
Shamrock
: support /get_guild_meta_by_guest
This commit is contained in:
parent
7540ef04bb
commit
103381c17a
@ -38,8 +38,8 @@ data class GProUserInfo(
|
||||
@ProtoNumber(15) var msgHeadInfo: GProHeadInfo? = null,
|
||||
@ProtoNumber(16) var joinTime: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(17) var memberRole: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(18) var member_type: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(19) var be_admin_time: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(18) var memberType: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(19) var beAdminTime: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(20) var memberName: String? = null,
|
||||
//@ProtoNumber(21) var clientPresence: Any? = null,
|
||||
//@ProtoNumber(22) var client_archive: ArrayList<>? = null,
|
||||
|
@ -0,0 +1,88 @@
|
||||
@file:OptIn(ExperimentalSerializationApi::class)
|
||||
|
||||
package moe.whitechi73.protobuf.oidb.cmx0xf57
|
||||
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.protobuf.ProtoNumber
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57Req(
|
||||
@ProtoNumber(1) val filter: Oidb0xf57Filter,
|
||||
@ProtoNumber(2) val guildInfo: Oidb0xf57GuildInfo,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57Rsp(
|
||||
@ProtoNumber(1) val metaInfo: Oidb0xf57MetaInfo,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57MetaInfo(
|
||||
@ProtoNumber(3) val guildId: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(4) val meta: Oidb0xf57Meta? = null,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57Meta(
|
||||
@ProtoNumber(2) val guildCode: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(4) val createTime: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(5) val maxMemberCount: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(6) val memberCount: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(8) val name: String? = null,
|
||||
@ProtoNumber(11) val robotMaxNum: Int = Int.MIN_VALUE,
|
||||
@ProtoNumber(12) val adminMaxNum: Int = Int.MIN_VALUE,
|
||||
@ProtoNumber(13) val profile: String? = null,
|
||||
@ProtoNumber(14) val avatarSeq: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(18) val ownerId: ULong = ULong.MIN_VALUE,
|
||||
@ProtoNumber(19) val coverSeq: Long = Long.MIN_VALUE,
|
||||
@ProtoNumber(20) val clientId: Int = Int.MIN_VALUE,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57GuildInfo(
|
||||
@ProtoNumber(1) val guildId: ULong = ULong.MIN_VALUE
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57Filter(
|
||||
@ProtoNumber(1) val u1: Oidb0xf57U1,
|
||||
@ProtoNumber(2) val u2: Oidb0xf57U2,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57U1(
|
||||
@ProtoNumber(2) val u1: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(4) val u2: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(5) val u3: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(6) val u4: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(7) val u5: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(8) val u6: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(11) val u7: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(12) val u8: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(13) val u9: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(14) val u10: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(45) val u11: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(18) val u12: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(19) val u13: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(20) val u14: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(22) val u15: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(23) val u16: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(5002) val u17: UInt = UInt.MIN_VALUE,
|
||||
@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(10007) val u21: UInt = UInt.MIN_VALUE,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class Oidb0xf57U2(
|
||||
@ProtoNumber(3) val u1: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(4) val u2: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(6) val u3: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(11) val u4: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(14) val u5: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(15) val u6: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(16) val u7: UInt = UInt.MIN_VALUE,
|
||||
@ProtoNumber(17) val u8: UInt = UInt.MIN_VALUE,
|
||||
)
|
@ -1,5 +1,5 @@
|
||||
package com.tencent.qqnt.kernel.nativeinterface;
|
||||
|
||||
public interface IGProFetchGuildInfoCallback {
|
||||
void onFetchGuildInfo(int i2, String str, GProGuild gProGuild);
|
||||
void onFetchGuildInfo(int code, String reason, GProGuild gProGuild);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
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);
|
||||
}
|
@ -23,25 +23,31 @@ public interface IKernelGuildService {
|
||||
|
||||
void fetchAddGuildInfo(int appId, long guildId, IGProAddGuildInfoCallBack iGProAddGuildInfoCallBack);
|
||||
|
||||
void fetchGuildInfo(long j2, int i2, IGProFetchGuildInfoCallback iGProFetchGuildInfoCallback);
|
||||
void fetchGuildInfo(long guildId, int seq, IGProFetchGuildInfoCallback iGProFetchGuildInfoCallback);
|
||||
|
||||
//void fetchGuildInfoByAppIdentity(GProGuildIdentity gProGuildIdentity, String str, String str2, IGProFetchGuildInfoByAppIdentityCallback iGProFetchGuildInfoByAppIdentityCallback);
|
||||
|
||||
void fetchGuildInfoForGuest(long j2, int i2, IGProFetchGuildInfoCallback iGProFetchGuildInfoCallback);
|
||||
void fetchGuildInfoForGuest(long guildId, int seq, IGProFetchGuildInfoCallback cb);
|
||||
|
||||
//void fetchGuestGuildInfoWithChannelList(String guildId, String str2, int i2, int seq, String str3,
|
||||
// IGProFetchGuestGuildInfoWithChannelListCallback iGProFetchGuestGuildInfoWithChannelListCallback);
|
||||
|
||||
GProGuild getGuildInfoFromCache(long j2);
|
||||
|
||||
void refreshGuildInfo(long guildId, boolean force, int appId);
|
||||
// 第一次请求: startIndex = 0 , roleIdIndex = 2
|
||||
void fetchMemberListWithRole(long guildId, long channelId, long startIndex, long roleIndex, int count, int seq, IGProFetchMemberListWithRoleCallback cb);
|
||||
|
||||
void refreshGuildInfo(long guildId, boolean force, int seq);
|
||||
|
||||
void refreshGuildInfoOnly(long j2, boolean z, int i2);
|
||||
|
||||
void fetchUserInfo(long j2, long j3, ArrayList<Long> tinyIdList, int i2, IGProGetUserInfoCallback iGProGetUserInfoCallback);
|
||||
|
||||
GProSimpleProfile getSimpleProfile(long guildId, long tinyId, int aid);
|
||||
GProSimpleProfile getSimpleProfile(long guildId, long tinyId, int seq);
|
||||
|
||||
GProFaceAuthInfo getFaceAuthInfo();
|
||||
|
||||
String getGuildUserAvatarUrl(long guildId, long tinyId, int aid);
|
||||
String getGuildUserAvatarUrl(long guildId, long tinyId, int seq);
|
||||
|
||||
String getGuildUserNickname(long guildId);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
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 kotlinx.serialization.ExperimentalSerializationApi
|
||||
@ -19,30 +20,64 @@ import moe.whitechi73.protobuf.oidb.cmd0xf88.GProFilter
|
||||
import moe.whitechi73.protobuf.oidb.cmd0xf88.GProUserInfo
|
||||
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
|
||||
|
||||
internal object GProSvc: BaseSvc() {
|
||||
fun getSelfTinyId(): Long {
|
||||
fun getSelfTinyId(): ULong {
|
||||
val service = app.getRuntimeService(IGPSService::class.java, "all")
|
||||
return service.selfTinyId.toLong()
|
||||
return service.selfTinyId.toULong()
|
||||
}
|
||||
|
||||
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)
|
||||
),
|
||||
guildInfo = Oidb0xf57GuildInfo(guildId = guildId)
|
||||
)))
|
||||
val body = oidb_sso.OIDBSSOPkg()
|
||||
if (respBuffer == null) {
|
||||
return Result.failure(Exception("unable to send packet"))
|
||||
}
|
||||
body.mergeFrom(respBuffer.slice(4))
|
||||
return runCatching {
|
||||
ProtoBuf.decodeFromByteArray<Oidb0xf57Rsp>(
|
||||
body.bytes_bodybuffer.get().toByteArray()
|
||||
).metaInfo
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getGuildMemberList(guildId: ULong): Result<List<GProRoleMemberList>> {
|
||||
val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
//kernelGProService.fetchMemberListWithRole()
|
||||
|
||||
return Result.failure(Exception("todo"))
|
||||
}
|
||||
|
||||
suspend fun getSelfGuildInfo(): Result<GProUserInfo> {
|
||||
PlatformUtils.requireMinQQVersion(version = PlatformUtils.QQ_9_0_8_VER)
|
||||
//val kernelGProService = NTServiceFetcher.kernelService.wrapperSession.guildService
|
||||
//val service = app.getRuntimeService(IGPSService::class.java, "all")
|
||||
val selfTinyId = getSelfTinyId()
|
||||
//LogCenter.log(kernelGProService.faceAuthInfo.toString())
|
||||
//kernelGProService.fetchUserInfo(0, 0, arrayListOf(selfTinyId), 0) { result, reason, userInfoList, tinyIdList ->
|
||||
// LogCenter.log("selfTinyId: $selfTinyId, $result $reason profile: $userInfoList")
|
||||
//}
|
||||
//LogCenter.log(kernelGProService.getGuildUserNickname(0))
|
||||
return getUserGuildInfo(0u, selfTinyId)
|
||||
}
|
||||
|
||||
suspend fun getUserGuildInfo(
|
||||
guildId: ULong,
|
||||
memberTinyId: ULong
|
||||
): Result<GProUserInfo> {
|
||||
val respBuffer = sendOidbAW("OidbSvcTrpcTcp.0xf88_1", 0xf88, 1, ProtoBuf.encodeToByteArray(Oidb0xf88Req(
|
||||
filter = GProFilter(1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u, 1u),
|
||||
memberId = 0uL,
|
||||
tinyId = selfTinyId.toULong(),
|
||||
guildId = 0uL
|
||||
tinyId = memberTinyId,
|
||||
guildId = guildId
|
||||
)))
|
||||
val body = oidb_sso.OIDBSSOPkg()
|
||||
if (respBuffer == null) {
|
||||
|
@ -0,0 +1,23 @@
|
||||
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("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)
|
||||
}
|
||||
|
||||
suspend operator fun invoke(guildId: ULong, echo: JsonElement = EmptyJsonString): String {
|
||||
GProSvc.getGuildMemberList(guildId)
|
||||
return ""
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("guild_id")
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
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.symbols.OneBotHandler
|
||||
|
||||
@OneBotHandler("get_guild_meta_by_guest")
|
||||
internal object GetGuildMetaByGuest: IActionHandler() {
|
||||
override suspend fun internalHandle(session: ActionSession): String {
|
||||
val guildId = session.getString("guild_id").toULong()
|
||||
return invoke(guildId, session.echo)
|
||||
}
|
||||
|
||||
suspend operator fun invoke(guildId: ULong, echo: JsonElement = EmptyJsonString): String {
|
||||
val result = GProSvc.getGuildInfo(guildId)
|
||||
result.onFailure {
|
||||
return error(it.message ?: "unable to fetch guild info", echo)
|
||||
}
|
||||
val info = result.getOrThrow()
|
||||
if (info.meta == null) {
|
||||
return error("unable to fetch guild meta", echo)
|
||||
}
|
||||
val meta = info.meta!!
|
||||
return ok(GetGuildMetaByGuestResponse(
|
||||
guildId = info.guildId,
|
||||
guildName = meta.name ?: "",
|
||||
guildProfile = meta.profile ?: "",
|
||||
createTime = meta.createTime,
|
||||
maxMemberCount = meta.maxMemberCount,
|
||||
maxRobotCount = meta.robotMaxNum,
|
||||
maxAdminCount = meta.adminMaxNum,
|
||||
memberCount = meta.memberCount,
|
||||
ownerId = meta.ownerId
|
||||
), echo)
|
||||
}
|
||||
|
||||
override val requiredParams: Array<String> = arrayOf("guild_id")
|
||||
|
||||
@Serializable
|
||||
data class GetGuildMetaByGuestResponse(
|
||||
@SerialName("guild_id") val guildId: ULong,
|
||||
@SerialName("guild_name") val guildName: String,
|
||||
@SerialName("guild_profile") val guildProfile: String,
|
||||
@SerialName("create_time") val createTime: Long,
|
||||
@SerialName("max_member_count") val maxMemberCount: Long,
|
||||
@SerialName("max_robot_count") val maxRobotCount: Int,
|
||||
@SerialName("max_admin_count") val maxAdminCount: Int,
|
||||
@SerialName("member_count") val memberCount: Long,
|
||||
@SerialName("owner_id") val ownerId: ULong,
|
||||
)
|
||||
}
|
@ -22,7 +22,7 @@ internal object GetGuildServiceProfile : IActionHandler() {
|
||||
return error(it.message ?: "unable to fetch self guild info", echo)
|
||||
}
|
||||
val info = result.getOrThrow()
|
||||
LogCenter.log(info.toString())
|
||||
//LogCenter.log(info.toString())
|
||||
return ok(GuildServiceProfile(
|
||||
nickName = info.nickName ?: info.memberName ?: "",
|
||||
tinyId = info.memberTinyid,
|
||||
|
@ -5,7 +5,10 @@ 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.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.fetchOrThrow
|
||||
import moe.fuqiuluo.shamrock.tools.getOrPost
|
||||
|
||||
fun Routing.guildAction() {
|
||||
@ -16,4 +19,14 @@ fun Routing.guildAction() {
|
||||
getOrPost("/get_guild_list") {
|
||||
call.respondText(GetGuildList(), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_member_list") {
|
||||
val guildId = fetchOrThrow("guild_id")
|
||||
call.respondText(GetGuildMemberList(guildId.toULong()), ContentType.Application.Json)
|
||||
}
|
||||
|
||||
getOrPost("/get_guild_meta_by_guest") {
|
||||
val guildId = fetchOrThrow("guild_id")
|
||||
call.respondText(GetGuildMetaByGuest(guildId.toULong()), ContentType.Application.Json)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user