diff --git a/gradle.properties b/gradle.properties
index 1bf976a..ea6d8a6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -5,7 +5,7 @@ MORNY_ARCHIVE_NAME = morny-coeur
MORNY_CODE_STORE = https://github.com/Eyre-S/Coeur-Morny-Cono
MORNY_COMMIT_PATH = https://github.com/Eyre-S/Coeur-Morny-Cono/commit/%s
-VERSION = 1.4.0
+VERSION = 1.4.1-alpha.1
USE_DELTA = false
VERSION_DELTA =
diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/event/OnGetSocial.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/event/OnGetSocial.scala
index ce69f34..2a63020 100644
--- a/src/main/scala/cc/sukazyo/cono/morny/bot/event/OnGetSocial.scala
+++ b/src/main/scala/cc/sukazyo/cono/morny/bot/event/OnGetSocial.scala
@@ -7,17 +7,14 @@ import cc.sukazyo.cono.morny.data.TelegramStickers
import cc.sukazyo.cono.morny.extra.{twitter, weibo, BilibiliForms}
import cc.sukazyo.cono.morny.util.tgapi.TelegramExtensions.Bot.exec
import cc.sukazyo.cono.morny.Log.{exceptionLog, logger}
-import cc.sukazyo.cono.morny.data.social.{SocialTwitterParser, SocialWeiboParser}
+import cc.sukazyo.cono.morny.data.social.{SocialBilibiliParser, SocialTwitterParser, SocialWeiboParser}
import cc.sukazyo.cono.morny.extra.BilibiliForms.{BiliB23, BiliVideoId}
import cc.sukazyo.cono.morny.extra.bilibili.XWebAPI
import cc.sukazyo.cono.morny.util.tgapi.TelegramExtensions.Message.entitiesSafe
-import cc.sukazyo.cono.morny.util.CommonFormat.formatDurationTimers
import com.pengrad.telegrambot.model.Chat
import com.pengrad.telegrambot.model.request.ParseMode
import com.pengrad.telegrambot.request.{SendMessage, SendPhoto, SendSticker}
-import java.time.Duration
-
class OnGetSocial (using coeur: MornyCoeur) extends EventListener {
override def onMessage (using event: EventEnv): Unit = {
@@ -95,7 +92,6 @@ object OnGetSocial {
}
private def tryFetchSocialOfBilibili (video: BiliVideoId)(using replyChat: Long, replyToMessage: Int)(using coeur: MornyCoeur) = {
- import cc.sukazyo.cono.morny.util.tgapi.formatting.TelegramParseEscape.escapeHtml as h
val video_info = XWebAPI.get_view(video)
coeur.account exec new SendPhoto(
@@ -103,11 +99,7 @@ object OnGetSocial {
video_info.data.pic
).replyToMessageId(replyToMessage)
.caption(
- // language=html
- s"""${h(video_info.data.title)}
- | ${formatDurationTimers(Duration.ofSeconds(video_info.data.duration))} @${h(video_info.data.owner.name)}
- |
- |${h(video_info.data.desc)}""".stripMargin
+ SocialBilibiliParser.printsBilibiliVideoCaption(video, video_info.data)
).parseMode(ParseMode.HTML)
}
diff --git a/src/main/scala/cc/sukazyo/cono/morny/bot/query/ShareToolSocialContent.scala b/src/main/scala/cc/sukazyo/cono/morny/bot/query/ShareToolSocialContent.scala
index 3d123ba..e1eaf8e 100644
--- a/src/main/scala/cc/sukazyo/cono/morny/bot/query/ShareToolSocialContent.scala
+++ b/src/main/scala/cc/sukazyo/cono/morny/bot/query/ShareToolSocialContent.scala
@@ -1,18 +1,14 @@
package cc.sukazyo.cono.morny.bot.query
-import cc.sukazyo.cono.morny.data.social.{SocialTwitterParser, SocialWeiboParser}
+import cc.sukazyo.cono.morny.data.social.{SocialBilibiliParser, SocialTwitterParser, SocialWeiboParser}
import cc.sukazyo.cono.morny.extra.{twitter, weibo}
import cc.sukazyo.cono.morny.extra.twitter.FXApi
import cc.sukazyo.cono.morny.extra.weibo.MApi
import cc.sukazyo.cono.morny.extra.BilibiliForms.{BiliB23, BiliVideoId}
import cc.sukazyo.cono.morny.extra.bilibili.XWebAPI
-import cc.sukazyo.cono.morny.util.tgapi.formatting.TelegramParseEscape.escapeHtml as h
-import cc.sukazyo.cono.morny.util.CommonFormat.formatDurationTimers
import com.pengrad.telegrambot.model.Update
import com.pengrad.telegrambot.model.request.{InlineQueryResultPhoto, ParseMode}
-import java.time.Duration
-
class ShareToolSocialContent extends ITelegramQuery {
override def query (event: Update): List[InlineQueryUnit[_]] | Null = {
@@ -41,11 +37,7 @@ class ShareToolSocialContent extends ITelegramQuery {
).description(
s"av${video.av} / BV${video.bv} - Preview"
).caption(
- // language=html
- s"""${h(video_info.data.title)}
- | ${formatDurationTimers(Duration.ofSeconds(video_info.data.duration))} @${h(video_info.data.owner.name)}
- |
- |${h(video_info.data.desc)}""".stripMargin
+ SocialBilibiliParser.printsBilibiliVideoCaption(video, video_info.data)
).parseMode(ParseMode.HTML))
}
diff --git a/src/main/scala/cc/sukazyo/cono/morny/data/social/SocialBilibiliParser.scala b/src/main/scala/cc/sukazyo/cono/morny/data/social/SocialBilibiliParser.scala
new file mode 100644
index 0000000..82f13bc
--- /dev/null
+++ b/src/main/scala/cc/sukazyo/cono/morny/data/social/SocialBilibiliParser.scala
@@ -0,0 +1,21 @@
+package cc.sukazyo.cono.morny.data.social
+
+import cc.sukazyo.cono.morny.extra.BilibiliForms.BiliVideoId
+import cc.sukazyo.cono.morny.extra.bilibili.XWebView
+import cc.sukazyo.cono.morny.util.CommonFormat.formatDurationTimers
+import cc.sukazyo.cono.morny.util.tgapi.formatting.TelegramParseEscape.escapeHtml as h
+
+import cc.sukazyo.cono.morny.util.StringEnsure.ensureNotExceed
+
+import java.time.Duration
+
+object SocialBilibiliParser {
+
+ def printsBilibiliVideoCaption (vid: BiliVideoId, info: XWebView): String =
+ // language=html
+ s"""${h(info.title)}
+ | ${formatDurationTimers(Duration.ofSeconds(info.duration))} @${h(info.owner.name)}
+ |
+ |${h(info.desc.ensureNotExceed(900))}""".stripMargin
+
+}