diff --git a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt index 02248167a..9f1139d34 100644 --- a/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt +++ b/mirai-core-qqandroid/src/commonMain/kotlin/net/mamoe/mirai/qqandroid/QQAndroidBot.kt @@ -10,12 +10,9 @@ package net.mamoe.mirai.qqandroid import io.ktor.client.HttpClient +import io.ktor.client.request.* import io.ktor.client.request.forms.MultiPartFormDataContent import io.ktor.client.request.forms.formData -import io.ktor.client.request.get -import io.ktor.client.request.headers -import io.ktor.client.request.post -import io.ktor.client.request.url import io.ktor.client.statement.HttpResponse import kotlinx.coroutines.CoroutineName import kotlinx.coroutines.async @@ -319,7 +316,7 @@ internal abstract class QQAndroidBotBase constructor( } } - @OptIn(LowLevelAPI::class) + @LowLevelAPI @MiraiExperimentalAPI override suspend fun _lowLevelGetAnnouncement(groupId: Long, fid: String): GroupAnnouncement { val data = network.async { @@ -345,6 +342,26 @@ internal abstract class QQAndroidBotBase constructor( return json.parse(GroupAnnouncement.serializer(), rep) } + @LowLevelAPI + @MiraiExperimentalAPI + override suspend fun _lowLevelGetGroupActiveData(groupId: Long): GroupActiveData { + val data = network.async { + HttpClient().get { + url("https://qqweb.qq.com/c/activedata/get_mygroup_data") + parameter("bkn",bkn) + parameter("gc",groupId) + + headers { + append( + "cookie", + "uin=o${selfQQ.id}; skey=${client.wLoginSigInfo.sKey.data.encodeToString()}; p_uin=o${selfQQ.id};" + ) + } + } + } + val rep = data.await() + return json.parse(GroupActiveData.serializer(), rep) + } override suspend fun queryImageUrl(image: Image): String = when (image) { is OnlineFriendImageImpl -> image.originUrl diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupActiveData.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupActiveData.kt new file mode 100644 index 000000000..1d71ba9b7 --- /dev/null +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/data/GroupActiveData.kt @@ -0,0 +1,135 @@ +package net.mamoe.mirai.data + + +import kotlinx.serialization.SerialName +import kotlinx.serialization.Serializable + + +/** + * 群统计信息 + * + * + * */ + +@Serializable +data class GroupActiveData( + + @SerialName("ec") + val ec: Int? = null, + + @SerialName("em") + val msg: String?, + + @SerialName("errcode") + val errCode: Int?, + + @SerialName("ginfo") + val info: Ginfo? = null, + + @SerialName("role") + val role: Int? +) { + @Serializable + data class Ginfo( + + + @SerialName("g_act_num") + val actNum: List?, //发言人数列表 + + @SerialName("g_createtime") + val createTime: Int?, + + @SerialName("g_exit_num") + val exitNum: List?, //退群人数列表 + + @SerialName("g_join_num") + val joinNum: List?, + + @SerialName("g_mem_num") + val memNum: List?, //人数变化 + + @SerialName("g_most_act") + val mostAct: List?, //发言排行 + + @SerialName("g_sentences") + val sentences: List?, + + @SerialName("gc") + val gc: Int?, + + @SerialName("gn") + val gn: String?, + + @SerialName("gowner") + val gowner: String?, + + @SerialName("isEnd") + val isEnd: Int? + ) { + @Serializable + data class GActNum( + + @SerialName("date") + val date: String?, + + @SerialName("num") + val num: Int? + ) + + @Serializable + data class GExitNum( + + @SerialName("date") + val date: String?, + + @SerialName("num") + val num: Int? + ) + + @Serializable + data class GJoinNum( + + @SerialName("date") + val date: String?, + + @SerialName("num") + val num: Int? + ) + + @Serializable + data class GMemNum( + + @SerialName("date") + val date: String?, + + @SerialName("num") + val num: Int? + ) + + @Serializable + data class GMostAct( + + @SerialName("name") + val name: String?, // 名称 不完整 + + @SerialName("sentences_num") + val sentencesNum: Int?, // 发言数 + + @SerialName("sta") + val sta: Int?, + + @SerialName("uin") + val uin: Long? + ) + + @Serializable + data class GSentence( + + @SerialName("date") + val date: String?, + + @SerialName("num") + val num: Int? + ) + } +} \ No newline at end of file diff --git a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt index 94976d8e8..58c4925ea 100644 --- a/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt +++ b/mirai-core/src/commonMain/kotlin/net.mamoe.mirai/lowLevelApi.kt @@ -132,6 +132,14 @@ interface LowLevelBotAPIAccessor { @MiraiExperimentalAPI suspend fun _lowLevelGetAnnouncement(groupId: Long, fid: String): GroupAnnouncement + + /** + * 获取群活跃信息 + * + * */ + @LowLevelAPI + @MiraiExperimentalAPI + suspend fun _lowLevelGetGroupActiveData(groupId: Long): GroupActiveData } /**