Added isEnabled function.

This commit is contained in:
Erik C. Thauvin 2021-12-05 22:57:33 -08:00
parent 562adec177
commit 0e80f22b4f

View file

@ -36,7 +36,6 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
import net.thauvin.erik.mobibot.FeedReader import net.thauvin.erik.mobibot.FeedReader
import net.thauvin.erik.mobibot.Utils.helpFormat import net.thauvin.erik.mobibot.Utils.helpFormat
import net.thauvin.erik.mobibot.Utils.sendMessage
import org.pircbotx.hooks.types.GenericMessageEvent import org.pircbotx.hooks.types.GenericMessageEvent
class ChannelFeed(channel: String) : AbstractCommand() { class ChannelFeed(channel: String) : AbstractCommand() {
@ -55,16 +54,16 @@ class ChannelFeed(channel: String) : AbstractCommand() {
} }
override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) { override fun commandResponse(channel: String, args: String, event: GenericMessageEvent) {
with(properties[FEED_PROP]) { if (isEnabled()) {
if (!isNullOrBlank()) {
runBlocking { runBlocking {
launch { launch {
FeedReader(this@with, event).run() FeedReader(properties[FEED_PROP]!!, event).run()
} }
} }
} else {
event.sendMessage("There is no feed setup for this channel.")
} }
} }
override fun isEnabled(): Boolean {
return !properties[FEED_PROP].isNullOrBlank()
} }
} }