Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Colter23 committed Aug 4, 2024
1 parent 537fad6 commit abda439
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "top.colter"
version = "3.2.11"
version = "3.2.12"

repositories {
mavenLocal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
22 changes: 16 additions & 6 deletions src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -280,13 +280,23 @@ data class LinkResolveConfig(
val triggerMode: TriggerMode = TriggerMode.At,
val returnLink: Boolean = false,
val regex: List<String> = 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<Regex> 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]+
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,20 @@ enum class LinkType(val regex: List<Regex>, 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)
Expand Down
6 changes: 4 additions & 2 deletions src/test/kotlin/PluginTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ internal class PluginTest {
})
y += 30f
}

else -> {}
}

}
Expand All @@ -140,7 +142,7 @@ internal class PluginTest {
"DYNAMIC_TYPE_FORWARD",
"652271005324017683",
true,
null,
//null,
DynamicItem.Modules(
ModuleAuthor(
"AUTHOR_TYPE_NORMAL",
Expand Down Expand Up @@ -296,7 +298,7 @@ internal class PluginTest {
"DYNAMIC_TYPE_WORD",
"652271005324017683",
true,
null,
//null,
DynamicItem.Modules(
ModuleAuthor(
"AUTHOR_TYPE_NORMAL",
Expand Down

0 comments on commit abda439

Please sign in to comment.