diff --git a/README.md b/README.md index 9c46893..f714079 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ font: Microsoft Yahei # 直播@全体(目前只能全体控制,如果需要对单独的群设置请去开issue) liveAtAll: false -# 图片推送模式文字模板 +# 图片模式下动态/视频推送文字模板 # 配置项: # {name} : 名字 # {uid} : UID @@ -83,6 +83,9 @@ liveAtAll: false # 2.0.4版本之前的模板为 {name}@{uid}@{type}\n{time}\n{link} pushTemplate: "{name}@{type}\n{link}" +# 图片模式下直播推送文字模板, 如果为空则与上方动态推送模板保持一致 +livePushTemplate: "" + # cookie !!必填!! # cookie请包在双引号内 # 如何获取见下文 获取Cookie diff --git a/build.gradle.kts b/build.gradle.kts index 4391198..5bd57bf 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ plugins { } group = "top.colter" -version = "2.0.8" +version = "2.0.9" repositories { mavenLocal() diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliTasker.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliTasker.kt index e7a0e7a..b1b9f3b 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliTasker.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/BiliBiliTasker.kt @@ -204,7 +204,7 @@ object DynamicTasker : CoroutineScope by PluginMain.childScope("DynamicTasker") list.sendMessage { di.build(it, color) } //lastDynamic = di.timestamp } - delay(1000L) + //delay(1000L) } } }.onSuccess { diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/Live.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/Live.kt index 1319c9e..23e5c0a 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/Live.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/Live.kt @@ -41,7 +41,10 @@ suspend fun LiveInfo.buildTextLive(contact: Contact): Message { suspend fun LiveInfo.buildImageLive(contact: Contact): Message { val link = "https://live.bilibili.com/${roomId}" val file = buildLiveImageMessage(title, cover, uname, face, "#d3edfa", "live/${uid}/${liveTime}.png") - val msg = BiliPluginConfig.pushTemplate.replace("{name}", uname).replace("{uid}",uid.toString()) + val template = BiliPluginConfig.livePushTemplate.ifEmpty { + BiliPluginConfig.pushTemplate + } + val msg = template.replace("{name}", uname).replace("{uid}",uid.toString()) .replace("{type}","直播").replace("{time}",time).replace("{link}",link) return (file.uploadAsImage(contact) + msg) } diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/PluginMain.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/PluginMain.kt index 0151156..4979277 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/PluginMain.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/PluginMain.kt @@ -13,7 +13,7 @@ object PluginMain : KotlinPlugin( JvmPluginDescription( id = "top.colter.bilibili-dynamic-mirai-plugin", name = "BilibiliDynamic", - version = "2.0.8" + version = "2.0.9" ) { author("Colter") info( diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/BiliPluginConfig.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/BiliPluginConfig.kt index 1e04816..24206fc 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/BiliPluginConfig.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/data/BiliPluginConfig.kt @@ -27,9 +27,12 @@ object BiliPluginConfig : ReadOnlyPluginConfig("BiliPluginConfig") { @ValueDescription("直播@全体") val liveAtAll: Boolean by value(false) - @ValueDescription("推送文字模板, 参数请看readme") + @ValueDescription("动态/视频推送文字模板, 参数请看readme") val pushTemplate: String by value("{name}@{type}\n{link}") + @ValueDescription("直播推送文字模板, 如不配置则与上面的动态推送模板一致") + val livePushTemplate: String by value("") + //@Suppress(stringSerialization = DOUBLE_QUOTATION) @ValueDescription("cookie, 请使用双引号") val cookie: String by value("") diff --git a/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/ImgUtils.kt b/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/ImgUtils.kt index 0f0c80c..e038bf6 100644 --- a/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/ImgUtils.kt +++ b/src/main/kotlin/top/colter/mirai/plugin/bilibili/utils/ImgUtils.kt @@ -252,15 +252,16 @@ object ImgUtils : CoroutineScope by PluginMain.childScope("ImageTasker"){ val emojis = e.emoji.htmlHexadecimal.split(";").filter{it.isNotEmpty()}.toList() val emoji = emojis.joinToString("-") if (!emojiMap.containsKey(emoji)) { + val emojiImg = try { + ImageIO.read(URL("https://twemoji.maxcdn.com/36x36/$emoji.png")) + }catch (ex: Exception){ + return@parseFromUnicode e.emoji.unicode + } val emojiBi = BufferedImage(30, 30, BufferedImage.TYPE_INT_ARGB) val emojiG2 = emojiBi.createGraphics() emojiG2.setRenderingHints(renderingHints) + emojiG2.drawImage(emojiImg,0,0,30,30,null) - try { - emojiG2.drawImage(ImageIO.read(URL("https://twemoji.maxcdn.com/36x36/$emoji.png")),0,0,30,30,null) - }catch (ex: Exception){ - return@parseFromUnicode e.emoji.unicode - } emojiMap["[$emoji]"] = emojiBi emojiG2.dispose() }