Skip to content

Commit 4ce581e

Browse files
cssxshStageGuard
authored and
StageGuard
committed
[core] 支持获取群公告图片 URL (mamoe#2619)
* fix: announcement protocol * add: api dump
1 parent 9236146 commit 4ce581e

File tree

7 files changed

+14
-65
lines changed

7 files changed

+14
-65
lines changed

mirai-core-api/compatibility-validation/android/api/android.api

+1
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ public final class net/mamoe/mirai/contact/announcement/AnnouncementImage {
803803
public fun equals (Ljava/lang/Object;)Z
804804
public final fun getHeight ()I
805805
public final fun getId ()Ljava/lang/String;
806+
public final fun getUrl ()Ljava/lang/String;
806807
public final fun getWidth ()I
807808
public fun hashCode ()I
808809
public fun toString ()Ljava/lang/String;

mirai-core-api/compatibility-validation/jvm/api/jvm.api

+1
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ public final class net/mamoe/mirai/contact/announcement/AnnouncementImage {
803803
public fun equals (Ljava/lang/Object;)Z
804804
public final fun getHeight ()I
805805
public final fun getId ()Ljava/lang/String;
806+
public final fun getUrl ()Ljava/lang/String;
806807
public final fun getWidth ()I
807808
public fun hashCode ()I
808809
public fun toString ()Ljava/lang/String;

mirai-core-api/src/commonMain/kotlin/contact/announcement/AnnouncementImage.kt

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Mamoe Technologies and contributors.
2+
* Copyright 2019-2023 Mamoe Technologies and contributors.
33
*
44
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
55
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -31,6 +31,11 @@ public class AnnouncementImage private constructor(
3131
) {
3232
// For stability, do not make it `data class`.
3333

34+
/**
35+
* @since 2.15
36+
*/
37+
public val url: String get() = "https://gdynamic.qpic.cn/gdynamic/$id/628"
38+
3439
public companion object {
3540
public const val SERIAL_NAME: String = "AnnouncementImage"
3641

mirai-core/src/commonMain/kotlin/contact/announcement/AnnouncementsImpl.kt

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Mamoe Technologies and contributors.
2+
* Copyright 2019-2023 Mamoe Technologies and contributors.
33
*
44
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
55
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -48,12 +48,7 @@ import net.mamoe.mirai.utils.*
4848
import net.mamoe.mirai.utils.Either.Companion.onLeft
4949
import net.mamoe.mirai.utils.Either.Companion.rightOrNull
5050

51-
internal expect class AnnouncementsImpl(
52-
group: GroupImpl,
53-
logger: MiraiLogger,
54-
) : CommonAnnouncementsImpl
55-
56-
internal abstract class CommonAnnouncementsImpl(
51+
internal class AnnouncementsImpl(
5752
protected val group: GroupImpl,
5853
protected val logger: MiraiLogger,
5954
) : Announcements {
@@ -412,6 +407,7 @@ internal object AnnouncementProtocol {
412407
showPopup = settings.tipWindowType == 0
413408
requireConfirmation = settings.confirmRequired == 1
414409
showEditCard = settings.isShowEditCard == 1
410+
image = msg.images.firstOrNull()?.toPublic()
415411
},
416412
fid = fid,
417413
allConfirmed = isAllConfirm != 0,

mirai-core/src/commonMain/kotlin/contact/announcement/GroupAnnouncement.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2021 Mamoe Technologies and contributors.
2+
* Copyright 2019-2023 Mamoe Technologies and contributors.
33
*
44
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
55
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
@@ -63,7 +63,8 @@ internal class GroupAnnouncementImage @MiraiInternalApi constructor(
6363
@Serializable
6464
internal data class GroupAnnouncementMsg(
6565
val text: String,
66-
val text_face: String? = null,
66+
@SerialName("text_face") val textFace: String? = null,
67+
@SerialName("pics") val images: List<GroupAnnouncementImage> = emptyList(),
6768
// val title: String? = null // no title any more
6869
)
6970

mirai-core/src/jvmBaseMain/kotlin/contact/announcement/AnnouncementsImpl.kt

-37
This file was deleted.

mirai-core/src/nativeMain/kotlin/contact/announcement/AnnouncementsImpl.kt

-18
This file was deleted.

0 commit comments

Comments
 (0)