feat: improved FeedUpdater message

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-10-15 15:46:04 +02:00
parent d60b7ba92f
commit 0e2e3c8022

View file

@ -18,6 +18,7 @@
package net.moonleay.rssbot.jobs
import com.overzealous.remark.Remark
import com.prof18.rssparser.RssParser
import com.prof18.rssparser.model.RssChannel
import dev.inmo.krontab.KronScheduler
@ -35,6 +36,7 @@ import net.moonleay.rssbot.jobs.component.ICronjob
import net.moonleay.rssbot.util.EmbedUtil
import net.moonleay.rssbot.util.Logger
import net.moonleay.rssbot.util.MessageUtil
import net.moonleay.rssbot.util.TimeUtil
object FeedUpdater : ICronjob {
override val jobName: String
@ -72,7 +74,13 @@ object FeedUpdater : ICronjob {
if (rss == null)
continue
for (rssData in rss!!.items) {
if (rssData.guid == null || RSSRepository.exists(RSSData(rssData.guid!!, data.id)))
if (rssData.guid == null || RSSRepository.exists(
RSSData(
rssData.guid!!,
data.id
)
) || TimeUtil.getUnixTimeFromStamp(rssData.pubDate!!) < data.subscriptionTimestamp
)
continue
val channel = Bot.bot.kordRef.getChannel(Snowflake(data.channelId))!!.asChannelOf<MessageChannel>()
channel.createMessage {
@ -81,11 +89,14 @@ object FeedUpdater : ICronjob {
data.feedColor,
rssData.author ?: "Anonymous",
rssData.title ?: "Untitled",
rssData.description ?: "No description",
if (rssData.description == null) "No description" else Remark(EmbedUtil.getHTMLtoMarkdownOptions()).convertFragment(
rssData.description!!
),
rssData.link ?: "https://moonleay.net/",
rssData.image ?: "",
if (rssData.link != null) EmbedUtil.getSiteLogo(rssData.link!!) else "https://static.moonleay.net/img/no-image.png",
data.feedName,
"Manual Feed",
rssData.pubDate ?: "unknown"
)
)
}