From abda439511dbba79dcb64bde1f00e9181fe21e12 Mon Sep 17 00:00:00 2001 From: Colter23 Date: Sun, 4 Aug 2024 09:59:58 +0800 Subject: [PATCH] update --- build.gradle.kts | 2 +- .../mirai/plugin/bilibili/BiliBiliDynamic.kt | 2 +- .../mirai/plugin/bilibili/BiliConfig.kt | 22 ++++++++++++++----- .../mirai/plugin/bilibili/data/Video.kt | 8 +++---- .../plugin/bilibili/service/DynamicService.kt | 13 ++++++----- .../bilibili/service/ResolveLinkService.kt | 10 +++++---- src/test/kotlin/PluginTest.kt | 6 +++-- 7 files changed, 40 insertions(+), 23 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 0f25386..7e53112 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ plugins { } group = "top.colter" -version = "3.2.11" +version = "3.2.12" repositories { mavenLocal() diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliDynamic.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliDynamic.kt index 9aee07b..3d95d6d 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliDynamic.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliDynamic.kt @@ -24,7 +24,7 @@ object BiliBiliDynamic : KotlinPlugin( JvmPluginDescription( id = "top.colter.bilibili-dynamic-mirai-plugin", name = "BiliBili Dynamic", - version = "3.2.11", + version = "3.2.12", ) { author("Colter") dependsOn("xyz.cssxsh.mirai.plugin.mirai-skia-plugin", ">= 1.1.0") diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliConfig.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliConfig.kt index a4188a7..99f1e02 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliConfig.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliConfig.kt @@ -280,13 +280,23 @@ data class LinkResolveConfig( val triggerMode: TriggerMode = TriggerMode.At, val returnLink: Boolean = false, val regex: List = listOf( - """(www.bilibili.com/video/)?((BV[0-9A-z]{10})|(av\d{1,10}))""", - """(www.bilibili.com/read/)?(cv\d{1,10})""", - """((www|m).bilibili.com/bangumi/(play|media)/)?((ss|ep|md)\d+)""", - """[tm].bilibili.com/(dynamic/)?(\d+)""", - """live.bilibili.com/(h5/)?(\d+)""", - """b23.tv\\?/([0-9A-z]+)""", + """(www\.bilibili\.com/video/((BV[0-9A-z]{10})|(av\d{1,10})))|^(BV[0-9A-z]{10})|^(av\d{1,10})""", + """(www\.bilibili\.com/read/cv\d{1,10})|^(cv\d{1,10})|(www\.bilibili\.com/read/mobile/\d{1,10})""", + """((www|m)\.bilibili\.com/bangumi/(play|media)/(ss|ep|md)\d+)|^((ss|ep|md)\d+)""", + """([tm]\.bilibili\.com/(dynamic/)?\d+)|(www\.bilibili\.com/opus/\d+)""", + """live\.bilibili\.com/(h5/)?\d+""", + """space\.bilibili\.com/\d+""", + """(b23\.tv|bili2233\.cn)\\?/[0-9A-z]+""", ) ){ val reg: List get() = regex.map { it.toRegex() } } + + +// (www\.bilibili\.com/video/((BV[0-9A-z]{10})|(av\d{1,10})))|^(BV[0-9A-z]{10})|^(av\d{1,10}) +// (www\.bilibili\.com/read/cv\d{1,10})|^(cv\d{1,10}) +// ((www|m)\.bilibili\.com/bangumi/(play|media)/(ss|ep|md)\d+)|^((ss|ep|md)\d+) +// [tm]\.bilibili\.com/(dynamic/)?\d+ +// live\.bilibili\.com/(h5/)?\d+ +// space\.bilibili\.com/\d+ +// (b23\.tv|bili2233\.cn)\\?/[0-9A-z]+ \ No newline at end of file diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Video.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Video.kt index 9bf7eea..65d6bb5 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Video.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/Video.kt @@ -42,7 +42,7 @@ data class VideoDetail( @SerialName("dynamic") val dynamic: String? = null, @SerialName("cid") - val cid: Int? = null, + val cid: Long? = null, @SerialName("dimension") val dimension: Dimension? = null, @SerialName("season_id") @@ -117,7 +117,7 @@ data class VideoDetail( @Serializable data class Stat( @SerialName("aid") - val aid: Int? = null, + val aid: Long? = null, @SerialName("view") val view: Int, @SerialName("danmaku") @@ -168,7 +168,7 @@ data class VideoDetail( @Serializable data class Pages( @SerialName("cid") - val cid: Int? = null, + val cid: Long? = null, @SerialName("page") val page: Int? = null, @SerialName("from") @@ -190,7 +190,7 @@ data class VideoDetail( @Serializable data class UgcSeason( @SerialName("id") - val id: Int? = null, + val id: Long? = null, @SerialName("title") val title: String? = null, @SerialName("cover") diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/DynamicService.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/DynamicService.kt index a00c4b3..a89f498 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/DynamicService.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/DynamicService.kt @@ -63,11 +63,14 @@ object DynamicService { if (dynamic[0]?.contacts?.contains(subject) == true) dynamic[0]?.contacts?.remove(subject) if (!dynamic.containsKey(uid)) { - val m = followUser(uid) - if (m != null) return@withLock m - val un = if (uid == 11783021L) { - "哔哩哔哩番剧出差" - } else client.userInfo(uid)?.name!! + val un = if (BiliBiliDynamic.uid == uid) client.userInfo(uid)?.name!! + else { + val m = followUser(uid) + if (m != null) return@withLock m + if (uid == 11783021L) { + "哔哩哔哩番剧出差" + } else client.userInfo(uid)?.name!! + } dynamic[uid] = SubData(un) } diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/ResolveLinkService.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/ResolveLinkService.kt index d7e0fe1..a105f83 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/ResolveLinkService.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/service/ResolveLinkService.kt @@ -67,18 +67,20 @@ enum class LinkType(val regex: List, var id: String? = null): ResolveLink }, Article(listOf( - """(?:www\.bilibili\.com/read/)?(cv\d{1,10})""".toRegex() + """(?:www\.bilibili\.com/read/)?cv(\d{1,10})""".toRegex(), + """(?:www\.bilibili\.com/read/mobile/)(\d{1,10})""".toRegex() )) { override suspend fun drawGeneral(): String? { - return biliClient.getArticleDetail(id!!)?.run { + return biliClient.getArticleDetail("cv$id")?.run { drawGeneral(id!!, "专栏", time.formatTime, author, toDrawData().drawGeneral()) } } - override suspend fun getLink(): String = ARTICLE_LINK(id!!.removePrefix("cv")) + override suspend fun getLink(): String = ARTICLE_LINK(id!!) }, Dynamic(listOf( - """[tm]\.bilibili\.com/(?:dynamic/)?(\d+)""".toRegex() + """[tm]\.bilibili\.com/(?:dynamic/)?(\d+)""".toRegex(), + """www\.bilibili\.com/opus/(\d+)""".toRegex() )) { override suspend fun drawGeneral(): String? { val color = Color.makeRGB(BiliConfig.imageConfig.defaultColor) diff --git a/src/test/kotlin/PluginTest.kt b/src/test/kotlin/PluginTest.kt index f977267..6568d6e 100644 --- a/src/test/kotlin/PluginTest.kt +++ b/src/test/kotlin/PluginTest.kt @@ -123,6 +123,8 @@ internal class PluginTest { }) y += 30f } + + else -> {} } } @@ -140,7 +142,7 @@ internal class PluginTest { "DYNAMIC_TYPE_FORWARD", "652271005324017683", true, - null, + //null, DynamicItem.Modules( ModuleAuthor( "AUTHOR_TYPE_NORMAL", @@ -296,7 +298,7 @@ internal class PluginTest { "DYNAMIC_TYPE_WORD", "652271005324017683", true, - null, + //null, DynamicItem.Modules( ModuleAuthor( "AUTHOR_TYPE_NORMAL",