Compare commits
No commits in common. "ccf5ef4f0d1ef7c9a27fac70f7c5894e3a62a6b1" and "5a39f498244f4a624b4603eb626e748941bc78df" have entirely different histories.
ccf5ef4f0d
...
5a39f49824
8 changed files with 4 additions and 93 deletions
|
@ -14,7 +14,7 @@ val ownerID = 372703841151614976L
|
|||
group = "net.moonleay.rssbot"
|
||||
version = System.getenv("CI_COMMIT_TAG")?.let { "$it-${System.getenv("CI_COMMIT_SHORT_SHA")}-prod" }
|
||||
?: System.getenv("CI_COMMIT_SHORT_SHA")?.let { "$it-dev" }
|
||||
?: "0.2.1"
|
||||
?: "0.1.0"
|
||||
|
||||
val kordver = "1.5.10-SNAPSHOT"
|
||||
val coroutinesver = "1.7.3"
|
||||
|
|
|
@ -25,7 +25,6 @@ import dev.kord.core.on
|
|||
import net.moonleay.rssbot.data.CredentialManager
|
||||
import net.moonleay.rssbot.data.database.DB
|
||||
import net.moonleay.rssbot.extensions.FeedExtension
|
||||
import net.moonleay.rssbot.extensions.FeedsExtension
|
||||
import net.moonleay.rssbot.extensions.StuffExtension
|
||||
import net.moonleay.rssbot.jobs.FeedUpdater
|
||||
import net.moonleay.rssbot.jobs.component.JobManager
|
||||
|
@ -76,7 +75,6 @@ object Bot {
|
|||
extensions {
|
||||
add(::FeedExtension)
|
||||
add(::StuffExtension)
|
||||
add(::FeedsExtension)
|
||||
}
|
||||
|
||||
this.presence {
|
||||
|
|
|
@ -46,27 +46,6 @@ object SubscriptionRepository {
|
|||
return dataList
|
||||
}
|
||||
|
||||
fun getAllChannel(channelId: Long): List<SubscriptionData> {
|
||||
val dataList = mutableListOf<SubscriptionData>()
|
||||
transaction {
|
||||
SubscriptionsTable.select {
|
||||
SubscriptionsTable.channelId eq channelId
|
||||
}.forEach {
|
||||
dataList.add(
|
||||
SubscriptionData(
|
||||
it[SubscriptionsTable.id],
|
||||
it[SubscriptionsTable.serverId],
|
||||
it[SubscriptionsTable.channelId],
|
||||
EmbedUtil.getColorFromString(it[SubscriptionsTable.subscriptionColor]),
|
||||
it[SubscriptionsTable.subscriptionName],
|
||||
it[SubscriptionsTable.feedUrl]
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
return dataList
|
||||
}
|
||||
|
||||
|
||||
fun get(channelId: Long, feedName: String): SubscriptionData? {
|
||||
var data: SubscriptionData? = null
|
||||
|
@ -87,16 +66,6 @@ object SubscriptionRepository {
|
|||
return data
|
||||
}
|
||||
|
||||
fun existsWithUrl(channelId: Long, feedUrl: String): Boolean {
|
||||
var exists = false
|
||||
transaction {
|
||||
exists = SubscriptionsTable.select {
|
||||
(SubscriptionsTable.channelId eq channelId) and (SubscriptionsTable.feedUrl eq feedUrl)
|
||||
}.count() > 0
|
||||
}
|
||||
return exists
|
||||
}
|
||||
|
||||
fun exists(channelId: Long, feedName: String): Boolean {
|
||||
var exists = false
|
||||
transaction {
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.jetbrains.exposed.sql.Table
|
|||
|
||||
|
||||
object RSSTable : Table(name = "rss") {
|
||||
val guid = text("guid")
|
||||
val guid = text("guid").uniqueIndex()
|
||||
val subscriptionId = integer("subscription_id") references SubscriptionsTable.id
|
||||
override val primaryKey = PrimaryKey(guid, subscriptionId, name = "PK_RSS")
|
||||
}
|
||||
|
|
|
@ -86,19 +86,6 @@ class FeedExtension : Extension() {
|
|||
}
|
||||
return@action
|
||||
}
|
||||
if (SubscriptionRepository.exists(this.channel.id.value.toLong(), feedName) || SubscriptionRepository.existsWithUrl(this.channel.id.value.toLong(), feedUrl)) {
|
||||
this.respond {
|
||||
this.embeds.add(
|
||||
MessageUtil.getEmbed(
|
||||
EmbedColor.ERROR,
|
||||
"Feed already exists",
|
||||
"The feed \"${feedName}\" already exists",
|
||||
user.username
|
||||
)
|
||||
)
|
||||
}
|
||||
return@action
|
||||
}
|
||||
val id = SubscriptionRepository.write(
|
||||
SubscriptionData(
|
||||
0,
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package net.moonleay.rssbot.extensions
|
||||
|
||||
import com.kotlindiscord.kord.extensions.commands.Arguments
|
||||
import com.kotlindiscord.kord.extensions.commands.converters.impl.string
|
||||
import com.kotlindiscord.kord.extensions.extensions.Extension
|
||||
import com.kotlindiscord.kord.extensions.extensions.ephemeralSlashCommand
|
||||
import com.kotlindiscord.kord.extensions.types.respond
|
||||
import net.moonleay.rssbot.data.database.repository.RSSRepository
|
||||
import net.moonleay.rssbot.data.database.repository.SubscriptionRepository
|
||||
import net.moonleay.rssbot.util.EmbedColor
|
||||
import net.moonleay.rssbot.util.MessageUtil
|
||||
|
||||
class FeedsExtension : Extension() {
|
||||
|
||||
override val name = "feeds"
|
||||
override val allowApplicationCommandInDMs: Boolean
|
||||
get() = false
|
||||
|
||||
|
||||
override suspend fun setup() {
|
||||
ephemeralSlashCommand() {
|
||||
name = "feeds"
|
||||
description = "Show all active feeds for this channel"
|
||||
this.action {
|
||||
val user = this.user.asUser()
|
||||
val subscriptions = SubscriptionRepository.getAllChannel(this.channel.id.value.toLong())
|
||||
this.respond {
|
||||
this.embeds.add(
|
||||
MessageUtil.getEmbed(
|
||||
EmbedColor.INFO,
|
||||
"Feeds",
|
||||
subscriptions.joinToString("\n") { it.feedName + " [[feed url](" + it.feedUrl + ")]" },
|
||||
user.username
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -38,7 +38,7 @@ import net.moonleay.rssbot.util.MessageUtil
|
|||
|
||||
object FeedUpdater : ICronjob {
|
||||
override val jobName: String
|
||||
get() = "FeedUpdater"
|
||||
get() = "StatusUpdater"
|
||||
override val jobIncoming: String
|
||||
get() = "0 /20 * * * * 0o *" //Every 20 seconds
|
||||
override val jobType: CronjobType
|
||||
|
|
|
@ -177,9 +177,6 @@ object MessageUtil {
|
|||
): EmbedBuilder {
|
||||
val ebb = EmbedBuilder()
|
||||
val now: LocalDateTime = LocalDateTime.now()
|
||||
if (title.length > 250)
|
||||
ebb.title = title.substring(0, 250) + "[...]"
|
||||
else
|
||||
ebb.title = title
|
||||
ebb.author {
|
||||
this.name = author
|
||||
|
|
Loading…
Reference in a new issue