feat: improved FeedUpdater message
Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
parent
d60b7ba92f
commit
0e2e3c8022
1 changed files with 14 additions and 3 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package net.moonleay.rssbot.jobs
|
package net.moonleay.rssbot.jobs
|
||||||
|
|
||||||
|
import com.overzealous.remark.Remark
|
||||||
import com.prof18.rssparser.RssParser
|
import com.prof18.rssparser.RssParser
|
||||||
import com.prof18.rssparser.model.RssChannel
|
import com.prof18.rssparser.model.RssChannel
|
||||||
import dev.inmo.krontab.KronScheduler
|
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.EmbedUtil
|
||||||
import net.moonleay.rssbot.util.Logger
|
import net.moonleay.rssbot.util.Logger
|
||||||
import net.moonleay.rssbot.util.MessageUtil
|
import net.moonleay.rssbot.util.MessageUtil
|
||||||
|
import net.moonleay.rssbot.util.TimeUtil
|
||||||
|
|
||||||
object FeedUpdater : ICronjob {
|
object FeedUpdater : ICronjob {
|
||||||
override val jobName: String
|
override val jobName: String
|
||||||
|
@ -72,7 +74,13 @@ object FeedUpdater : ICronjob {
|
||||||
if (rss == null)
|
if (rss == null)
|
||||||
continue
|
continue
|
||||||
for (rssData in rss!!.items) {
|
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
|
continue
|
||||||
val channel = Bot.bot.kordRef.getChannel(Snowflake(data.channelId))!!.asChannelOf<MessageChannel>()
|
val channel = Bot.bot.kordRef.getChannel(Snowflake(data.channelId))!!.asChannelOf<MessageChannel>()
|
||||||
channel.createMessage {
|
channel.createMessage {
|
||||||
|
@ -81,11 +89,14 @@ object FeedUpdater : ICronjob {
|
||||||
data.feedColor,
|
data.feedColor,
|
||||||
rssData.author ?: "Anonymous",
|
rssData.author ?: "Anonymous",
|
||||||
rssData.title ?: "Untitled",
|
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.link ?: "https://moonleay.net/",
|
||||||
rssData.image ?: "",
|
rssData.image ?: "",
|
||||||
if (rssData.link != null) EmbedUtil.getSiteLogo(rssData.link!!) else "https://static.moonleay.net/img/no-image.png",
|
if (rssData.link != null) EmbedUtil.getSiteLogo(rssData.link!!) else "https://static.moonleay.net/img/no-image.png",
|
||||||
data.feedName,
|
"Manual Feed",
|
||||||
|
rssData.pubDate ?: "unknown"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue