Skip to content

Commit

Permalink
feat: ImageLimit
Browse files Browse the repository at this point in the history
  • Loading branch information
cssxsh committed Aug 28, 2021
1 parent 63c014d commit 1072269
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/xyz/cssxsh/mirai/plugin/BiliUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ internal fun BiliClient.save() {

internal val ImageCache by lazy { File(BiliHelperSettings.cache) }

internal val ImageLimit by lazy { BiliHelperSettings.limit }

internal val SetupSelenium by BiliHelperPlugin::selenium

internal val RemoteWebDriver by BiliHelperPlugin::driver
Expand Down Expand Up @@ -229,6 +231,7 @@ internal suspend fun UserInfo.getFace(contact: Contact): Message {
}

internal suspend fun DynamicInfo.getImages(contact: Contact) = images.mapIndexed { index, picture ->
if (ImageLimit >= 0 && index < ImageLimit) return@mapIndexed "图片[${index + 1}]省略".toPlainText()
Url(picture).runCatching {
cache(
type = CacheType.DYNAMIC,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ object BiliHelperSettings : ReadOnlyPluginConfig("BiliHelperSettings") {
@ValueDescription("图片缓存位置")
val cache: String by value("ImageCache")

@ValueDescription("动态 订阅 输出图片数量,负数表示输出全部")
val limit: Int by value(-1)

@ValueDescription("API 访问间隔时间,单位秒")
val api: Long by value(10L)

Expand Down

0 comments on commit 1072269

Please sign in to comment.