diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Dynamic.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Dynamic.kt index 8620673..37a6160 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Dynamic.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Dynamic.kt @@ -46,7 +46,9 @@ enum class DynamicType(val text: String) { DYNAMIC_TYPE_LIVE_RCMD("直播"), DYNAMIC_TYPE_PGC("番剧"), DYNAMIC_TYPE_COMMON_SQUARE("动态"), - DYNAMIC_TYPE_NONE("动态被删除") + DYNAMIC_TYPE_COMMON_VERTICAL("动态"), + DYNAMIC_TYPE_NONE("动态被删除"), + DYNAMIC_TYPE_UNKNOWN("未知的动态"), } @@ -75,7 +77,7 @@ data class DynamicItem( * DYNAMIC_TYPE_NONE 动态被删除 */ @SerialName("type") - val type: DynamicType, + val typeStr: String, @SerialName("id_str") val idStr: String?, @@ -89,6 +91,24 @@ data class DynamicItem( val orig: DynamicItem? = null, ) { + val type: DynamicType get() = + when (typeStr){ + "DYNAMIC_TYPE_WORD" -> DynamicType.DYNAMIC_TYPE_WORD + "DYNAMIC_TYPE_DRAW" -> DynamicType.DYNAMIC_TYPE_DRAW + "DYNAMIC_TYPE_ARTICLE" -> DynamicType.DYNAMIC_TYPE_ARTICLE + "DYNAMIC_TYPE_FORWARD" -> DynamicType.DYNAMIC_TYPE_FORWARD + "DYNAMIC_TYPE_AV" -> DynamicType.DYNAMIC_TYPE_AV + "DYNAMIC_TYPE_MUSIC" -> DynamicType.DYNAMIC_TYPE_MUSIC + "DYNAMIC_TYPE_LIVE" -> DynamicType.DYNAMIC_TYPE_LIVE + "DYNAMIC_TYPE_LIVE_RCMD" -> DynamicType.DYNAMIC_TYPE_LIVE_RCMD + "DYNAMIC_TYPE_PGC" -> DynamicType.DYNAMIC_TYPE_PGC + "DYNAMIC_TYPE_COMMON_SQUARE" -> DynamicType.DYNAMIC_TYPE_COMMON_SQUARE + "DYNAMIC_TYPE_COMMON_VERTICAL" -> DynamicType.DYNAMIC_TYPE_COMMON_VERTICAL + "DYNAMIC_TYPE_NONE" -> DynamicType.DYNAMIC_TYPE_NONE + else -> DynamicType.DYNAMIC_TYPE_UNKNOWN + } + + val did: String get() = idStr?:"0" /** diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/draw/LiveDraw.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/draw/LiveDraw.kt index 06eb7ae..2b83895 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/draw/LiveDraw.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/draw/LiveDraw.kt @@ -4,7 +4,9 @@ import org.jetbrains.skia.* import org.jetbrains.skia.paragraph.ParagraphBuilder import org.jetbrains.skia.svg.SVGDOM import top.colter.mirai.plugin.bilibili.BiliConfig +import top.colter.mirai.plugin.bilibili.BiliData import top.colter.mirai.plugin.bilibili.data.LiveInfo +import top.colter.mirai.plugin.bilibili.tasker.DynamicMessageTasker import top.colter.mirai.plugin.bilibili.utils.* @@ -109,7 +111,9 @@ suspend fun LiveInfo.drawAvatar(): Image { y += quality.subTitleFontSize + space * 0.5f drawTextLine(textLineTime, x, y, Paint().apply { color = theme.subTitleColor }) - //drawOrnament(if (BiliConfig.imageConfig.cardOrnament=="QrCode") "QrCode" else "Label", null, link, "") + val color = BiliData.dynamic[uid]?.color ?: BiliConfig.imageConfig.defaultColor + val colors = color.split(";", ";").map { Color.makeRGB(it.trim()) }.first() + drawOrnament(if (BiliConfig.imageConfig.cardOrnament=="QrCode") "QrCode" else "Label", null, "https://live.bilibili.com/$roomId", colors, area) } }.makeImageSnapshot() } \ No newline at end of file diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/DynamicMessageTasker.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/DynamicMessageTasker.kt index 6e329b8..fb51407 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/DynamicMessageTasker.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/DynamicMessageTasker.kt @@ -74,6 +74,7 @@ object DynamicMessageTasker : BiliTasker() { modules.moduleDynamic.major?.pgc?.title!! } + DYNAMIC_TYPE_COMMON_VERTICAL, DYNAMIC_TYPE_COMMON_SQUARE -> { modules.moduleDynamic.major?.common?.title!! } @@ -88,6 +89,7 @@ object DynamicMessageTasker : BiliTasker() { DYNAMIC_TYPE_NONE -> { modules.moduleDynamic.major?.none?.tips!! } + DYNAMIC_TYPE_UNKNOWN -> "未知的动态类型: $typeStr" } } @@ -150,7 +152,10 @@ object DynamicMessageTasker : BiliTasker() { } DYNAMIC_TYPE_NONE, DYNAMIC_TYPE_WORD, - DYNAMIC_TYPE_DRAW -> { + DYNAMIC_TYPE_DRAW, + DYNAMIC_TYPE_COMMON_VERTICAL, + DYNAMIC_TYPE_COMMON_SQUARE, + DYNAMIC_TYPE_UNKNOWN -> { listOf( DynamicMessage.Link("动态", DYNAMIC_LINK(did)) ) @@ -193,12 +198,6 @@ object DynamicMessageTasker : BiliTasker() { ) } - DYNAMIC_TYPE_COMMON_SQUARE -> { - listOf( - DynamicMessage.Link("动态", DYNAMIC_LINK(did)) - ) - } - DYNAMIC_TYPE_LIVE -> { listOf( DynamicMessage.Link( diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/SendTasker.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/SendTasker.kt index 8884a49..6043892 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/SendTasker.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/tasker/SendTasker.kt @@ -144,6 +144,8 @@ object SendTasker : BiliTasker() { DynamicType.DYNAMIC_TYPE_WORD, DynamicType.DYNAMIC_TYPE_DRAW, DynamicType.DYNAMIC_TYPE_COMMON_SQUARE, + DynamicType.DYNAMIC_TYPE_COMMON_VERTICAL, + DynamicType.DYNAMIC_TYPE_UNKNOWN, DynamicType.DYNAMIC_TYPE_NONE -> DynamicFilterType.DYNAMIC DynamicType.DYNAMIC_TYPE_FORWARD -> DynamicFilterType.FORWARD diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/General.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/General.kt index abf2ae0..3809b11 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/General.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/General.kt @@ -72,7 +72,9 @@ val DynamicItem.link: String DYNAMIC_TYPE_WORD, DYNAMIC_TYPE_DRAW, DYNAMIC_TYPE_FORWARD, - DYNAMIC_TYPE_COMMON_SQUARE -> "https://t.bilibili.com/$idStr" + DYNAMIC_TYPE_COMMON_SQUARE, + DYNAMIC_TYPE_COMMON_VERTICAL, + DYNAMIC_TYPE_UNKNOWN -> "https://t.bilibili.com/$idStr" DYNAMIC_TYPE_ARTICLE -> "https://www.bilibili.com/read/cv${modules.moduleDynamic.major?.article?.id}" DYNAMIC_TYPE_AV -> "https://www.bilibili.com/video/${modules.moduleDynamic.major?.archive?.bvid}" diff --git a/src/test/kotlin/PluginTest.kt b/src/test/kotlin/PluginTest.kt index 54d3429..10bd686 100644 --- a/src/test/kotlin/PluginTest.kt +++ b/src/test/kotlin/PluginTest.kt @@ -7,7 +7,6 @@ import org.jetbrains.skia.* import org.junit.Test import top.colter.mirai.plugin.bilibili.client.BiliClient import top.colter.mirai.plugin.bilibili.data.DynamicItem -import top.colter.mirai.plugin.bilibili.data.DynamicType import top.colter.mirai.plugin.bilibili.data.ModuleAuthor import top.colter.mirai.plugin.bilibili.data.ModuleDynamic import top.colter.mirai.plugin.bilibili.draw.* @@ -131,7 +130,7 @@ internal class PluginTest { fun drawDynamicTest(): Unit = runBlocking { val dynamic = DynamicItem( // "DYNAMIC_TYPE_WORD", - DynamicType.DYNAMIC_TYPE_FORWARD, + "DYNAMIC_TYPE_FORWARD", "652271005324017683", true, null, @@ -286,7 +285,7 @@ internal class PluginTest { ), orig = DynamicItem( // "DYNAMIC_TYPE_WORD", - DynamicType.DYNAMIC_TYPE_WORD, + "DYNAMIC_TYPE_WORD", "652271005324017683", true, null,