Compare commits
No commits in common. "d9282580281daa1d45b1f41f9fcca5fd4f062f38" and "4dceef6a1fa39cdd636d5d4fe7fa7c54c60671cc" have entirely different histories.
d928258028
...
4dceef6a1f
2 changed files with 4 additions and 145 deletions
|
@ -19,7 +19,6 @@
|
|||
package net.moonleay.lilJudd
|
||||
|
||||
import com.kotlindiscord.kord.extensions.ExtensibleBot
|
||||
import com.kotlindiscord.kord.extensions.utils.dm
|
||||
import dev.kord.common.entity.PresenceStatus
|
||||
import dev.kord.core.behavior.interaction.response.respond
|
||||
import dev.kord.core.event.gateway.ReadyEvent
|
||||
|
@ -35,20 +34,22 @@ import kotlinx.coroutines.Job
|
|||
import kotlinx.coroutines.launch
|
||||
import net.moonleay.lilJudd.buttons.component.EditButtonManager
|
||||
import net.moonleay.lilJudd.data.CredentialManager
|
||||
import net.moonleay.lilJudd.data.NewsManager
|
||||
import net.moonleay.lilJudd.data.StacktraceSaver
|
||||
import net.moonleay.lilJudd.data.api.splatoon3ink.Splatoon3Api
|
||||
import net.moonleay.lilJudd.data.database.DB
|
||||
import net.moonleay.lilJudd.extensions.*
|
||||
import net.moonleay.lilJudd.features.AvailabilityManager
|
||||
import net.moonleay.lilJudd.features.MatchManager
|
||||
import net.moonleay.lilJudd.features.TimeManager
|
||||
import net.moonleay.lilJudd.jobs.Splatoon3ApiScheduleUpdateScheduler
|
||||
import net.moonleay.lilJudd.jobs.StatusUpdater
|
||||
import net.moonleay.lilJudd.jobs.component.JobManager
|
||||
import net.moonleay.lilJudd.util.EmbedColor
|
||||
import net.moonleay.lilJudd.util.Logger
|
||||
import net.moonleay.lilJudd.util.MessageUtil
|
||||
import net.moonleay.liljudd.build.BuildConstants
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
|
||||
object Bot {
|
||||
//The kord object gets set at app launch
|
||||
lateinit var bot: ExtensibleBot
|
||||
|
@ -184,28 +185,6 @@ object Bot {
|
|||
bot.kordRef.on<ReadyEvent> {
|
||||
AvailabilityManager.runThread() // Update Availabilities
|
||||
MatchManager.update() // Update Matches
|
||||
// Load news
|
||||
NewsManager.load()
|
||||
if(NewsManager.shouldPost == "yes"){
|
||||
bot.kordRef.guilds.collect {
|
||||
val owner = it.owner.asUser()
|
||||
Logger.out("Sent News to ${owner.username} from ${it.name}")
|
||||
owner.dm {
|
||||
this.embed {
|
||||
this.title = NewsManager.title
|
||||
this.description = NewsManager.news
|
||||
this.footer {
|
||||
this.icon = bot.kordRef.getSelf().avatar?.cdnUrl?.toUrl()
|
||||
this.text = MessageUtil.getFooter()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
NewsManager.shouldPost = "no"
|
||||
NewsManager.update()
|
||||
}
|
||||
|
||||
|
||||
// Make the bot update the status every 6 seconds
|
||||
// JobManager.addJob(StatusUpdater)
|
||||
}
|
||||
|
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* lilJudd
|
||||
* Copyright (C) 2024 moonleay
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.moonleay.lilJudd.data
|
||||
|
||||
import java.io.*
|
||||
import java.util.*
|
||||
|
||||
object NewsManager {
|
||||
private const val foldername = "data"
|
||||
private const val filename = "news.nick"
|
||||
lateinit var shouldPost: String
|
||||
lateinit var title: String
|
||||
lateinit var news: String
|
||||
|
||||
///Load the needed credentials, generate a config if there is none
|
||||
fun load() {
|
||||
val folder = File(foldername)
|
||||
if (!folder.exists()) {
|
||||
save()
|
||||
return
|
||||
}
|
||||
val configFile = File(folder, filename)
|
||||
if (!configFile.exists()) {
|
||||
save()
|
||||
return
|
||||
}
|
||||
try {
|
||||
val input: InputStream = FileInputStream(foldername + File.separator + filename)
|
||||
val prop = Properties()
|
||||
prop.load(input)
|
||||
shouldPost = prop.getProperty("shouldPost")
|
||||
title = prop.getProperty("title")
|
||||
news = prop.getProperty("news")
|
||||
input.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
fun update(){
|
||||
val folder = File(foldername)
|
||||
if (!folder.exists()) {
|
||||
try {
|
||||
folder.mkdirs()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
val configFile = File(foldername + File.separator + filename)
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
configFile.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
try {
|
||||
val output: OutputStream = FileOutputStream(foldername + File.separator + filename)
|
||||
val prop = Properties()
|
||||
prop.setProperty("shouldPost", shouldPost)
|
||||
prop.setProperty("title", title)
|
||||
prop.setProperty("news", news)
|
||||
prop.store(output, null)
|
||||
output.close()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
///generate a new sample config
|
||||
private fun save() {
|
||||
val folder = File(foldername)
|
||||
if (!folder.exists()) {
|
||||
try {
|
||||
folder.mkdirs()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
val configFile = File(foldername + File.separator + filename)
|
||||
if (!configFile.exists()) {
|
||||
try {
|
||||
configFile.createNewFile()
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
try {
|
||||
val output: OutputStream = FileOutputStream(foldername + File.separator + filename)
|
||||
val prop = Properties()
|
||||
prop.setProperty("shouldPost", "no")
|
||||
prop.setProperty("title", "empty")
|
||||
prop.setProperty("news", "empty")
|
||||
prop.store(output, null)
|
||||
output.close()
|
||||
|
||||
shouldPost = "no"
|
||||
title = "empty"
|
||||
news = "empty"
|
||||
} catch (e: IOException) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue