feat: improved the length management of RSSEmbeds

This commit is contained in:
moonleay 2023-10-29 11:31:12 +01:00
parent 2f72720ed2
commit a7ee34d865

View file

@ -178,15 +178,27 @@ object MessageUtil {
): EmbedBuilder {
val ebb = EmbedBuilder()
val now: LocalDateTime = LocalDateTime.now()
if (title.length > 25)
ebb.title = title.substring(0, 25) + "..."
var desc = if (description != "No description") description else ""
val articleLink = "\n[[open full article]($url)]"
if (title.length > 255){
ebb.title = title.substring(0, 252) + "..."
if (title != desc)
desc = "..." + title.substring(252, title.length) + "\n\n" + desc
}
else
ebb.title = title
var athr = author
if (author.length > 255) {
athr = author.substring(0, 252) + "..."
}
ebb.author {
this.name = author
this.name = athr
this.icon = logo
}
ebb.description = "${if (description != "No description") description else ""}\n[[open full article]($url)]"
if (desc.length > 4096 - 2 - articleLink.length){
desc = desc.substring(0, 4096 - 2 - articleLink.length) + "..."
}
ebb.description = "${desc}${articleLink}"
ebb.color = color.color.color
ebb.footer {
this.text = "> rssbot, ($feedName) \n/ pub $published \n/ rel ${dtf.format(now)}"