reformat code and optimize imports (IntelliJ internal function)
This commit is contained in:
parent
fce192d295
commit
20da6a5dda
@ -10,7 +10,10 @@ import com.github.twitch4j.events.ChannelGoLiveEvent
|
|||||||
import dev.jansel.feixiao.database.collections.StreamerCollection
|
import dev.jansel.feixiao.database.collections.StreamerCollection
|
||||||
import dev.jansel.feixiao.extensions.EventHooks
|
import dev.jansel.feixiao.extensions.EventHooks
|
||||||
import dev.jansel.feixiao.extensions.StreamerCommand
|
import dev.jansel.feixiao.extensions.StreamerCommand
|
||||||
import dev.jansel.feixiao.utils.*
|
import dev.jansel.feixiao.utils.database
|
||||||
|
import dev.jansel.feixiao.utils.token
|
||||||
|
import dev.jansel.feixiao.utils.twitchcid
|
||||||
|
import dev.jansel.feixiao.utils.twitchcs
|
||||||
import dev.kord.core.entity.channel.GuildMessageChannel
|
import dev.kord.core.entity.channel.GuildMessageChannel
|
||||||
import dev.kordex.core.ExtensibleBot
|
import dev.kordex.core.ExtensibleBot
|
||||||
import dev.kordex.core.i18n.SupportedLocales
|
import dev.kordex.core.i18n.SupportedLocales
|
||||||
@ -51,22 +54,26 @@ suspend fun main() {
|
|||||||
|
|
||||||
if (role != null) {
|
if (role != null) {
|
||||||
if (livemessage != null) {
|
if (livemessage != null) {
|
||||||
channel?.createMessage(livemessage
|
channel?.createMessage(
|
||||||
|
livemessage
|
||||||
.replace("{name}", it.channel.name)
|
.replace("{name}", it.channel.name)
|
||||||
.replace("{category}", it.stream.gameName)
|
.replace("{category}", it.stream.gameName)
|
||||||
.replace("{title}", it.stream.title)
|
.replace("{title}", it.stream.title)
|
||||||
.replace("{url}", "https://twitch.tv/${it.channel.name}")
|
.replace("{url}", "https://twitch.tv/${it.channel.name}")
|
||||||
.replace("{role}", "<@&$role>"))
|
.replace("{role}", "<@&$role>")
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
channel?.createMessage("<@&$role> https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
channel?.createMessage("<@&$role> https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (livemessage != null) {
|
if (livemessage != null) {
|
||||||
channel?.createMessage(livemessage
|
channel?.createMessage(
|
||||||
|
livemessage
|
||||||
.replace("{name}", it.channel.name)
|
.replace("{name}", it.channel.name)
|
||||||
.replace("{category}", it.stream.gameName)
|
.replace("{category}", it.stream.gameName)
|
||||||
.replace("{title}", it.stream.title)
|
.replace("{title}", it.stream.title)
|
||||||
.replace("{url}", "https://twitch.tv/${it.channel.name}"))
|
.replace("{url}", "https://twitch.tv/${it.channel.name}")
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
channel?.createMessage("https://twitch.tv/${it.channel.name} went live streaming ${it.stream.gameName}: ${it.stream.title}")
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,13 @@ class StreamerCollection : KordExKoinComponent {
|
|||||||
suspend fun getData(channelName: String): StreamerData? =
|
suspend fun getData(channelName: String): StreamerData? =
|
||||||
collection.findOne(StreamerData::name eq channelName)
|
collection.findOne(StreamerData::name eq channelName)
|
||||||
|
|
||||||
suspend fun updateData(guildId: Snowflake, channelId: Snowflake, streamerName: String, roleId: Snowflake?, liveMessage: String?) {
|
suspend fun updateData(
|
||||||
|
guildId: Snowflake,
|
||||||
|
channelId: Snowflake,
|
||||||
|
streamerName: String,
|
||||||
|
roleId: Snowflake?,
|
||||||
|
liveMessage: String?
|
||||||
|
) {
|
||||||
val coll = collection.findOne(StreamerData::name eq streamerName)
|
val coll = collection.findOne(StreamerData::name eq streamerName)
|
||||||
if (coll != null) {
|
if (coll != null) {
|
||||||
collection.updateOne(
|
collection.updateOne(
|
||||||
@ -34,7 +40,13 @@ class StreamerCollection : KordExKoinComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suspend fun removeData(guildId: Snowflake, channelId: Snowflake, streamerName: String, roleId: Snowflake?, liveMessage: String?) {
|
suspend fun removeData(
|
||||||
|
guildId: Snowflake,
|
||||||
|
channelId: Snowflake,
|
||||||
|
streamerName: String,
|
||||||
|
roleId: Snowflake?,
|
||||||
|
liveMessage: String?
|
||||||
|
) {
|
||||||
val coll = collection.findOne(StreamerData::name eq streamerName)
|
val coll = collection.findOne(StreamerData::name eq streamerName)
|
||||||
if (coll != null) {
|
if (coll != null) {
|
||||||
collection.updateOne(
|
collection.updateOne(
|
||||||
|
@ -7,7 +7,6 @@ import dev.jansel.feixiao.twitchClient
|
|||||||
import dev.kord.core.event.gateway.ReadyEvent
|
import dev.kord.core.event.gateway.ReadyEvent
|
||||||
import dev.kordex.core.extensions.Extension
|
import dev.kordex.core.extensions.Extension
|
||||||
import dev.kordex.core.extensions.event
|
import dev.kordex.core.extensions.event
|
||||||
import org.litote.kmongo.deleteMany
|
|
||||||
import org.litote.kmongo.eq
|
import org.litote.kmongo.eq
|
||||||
|
|
||||||
class EventHooks : Extension() {
|
class EventHooks : Extension() {
|
||||||
|
@ -31,7 +31,13 @@ class StreamerCommand : Extension() {
|
|||||||
}
|
}
|
||||||
action {
|
action {
|
||||||
val streamer = arguments.streamer
|
val streamer = arguments.streamer
|
||||||
StreamerCollection().updateData(guild!!.id, arguments.channel.id, streamer, arguments.role?.id, arguments.message)
|
StreamerCollection().updateData(
|
||||||
|
guild!!.id,
|
||||||
|
arguments.channel.id,
|
||||||
|
streamer,
|
||||||
|
arguments.role?.id,
|
||||||
|
arguments.message
|
||||||
|
)
|
||||||
twitchClient!!.clientHelper.enableStreamEventListener(streamer)
|
twitchClient!!.clientHelper.enableStreamEventListener(streamer)
|
||||||
respond {
|
respond {
|
||||||
content = "Added streamer $streamer"
|
content = "Added streamer $streamer"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user