feat: started working on Status, added TokenManager
Changes by Redtronics123
This commit is contained in:
parent
0c3cee73a1
commit
e01f5be61e
2 changed files with 98 additions and 0 deletions
30
src/main/kotlin/de/limited_dev/botendo/util/Status.kt
Normal file
30
src/main/kotlin/de/limited_dev/botendo/util/Status.kt
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Botendo
|
||||||
|
* Copyright (C) 2023 limited_dev
|
||||||
|
*
|
||||||
|
* 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 de.limited_dev.botendo.util
|
||||||
|
|
||||||
|
import de.limited_dev.botendo.Bot
|
||||||
|
|
||||||
|
object Status {
|
||||||
|
suspend fun updateStatus() {
|
||||||
|
Bot.kord!!.editPresence {
|
||||||
|
this.playing("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
68
src/main/kotlin/de/limited_dev/botendo/util/TokenManager.kt
Normal file
68
src/main/kotlin/de/limited_dev/botendo/util/TokenManager.kt
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
/*
|
||||||
|
* Botendo
|
||||||
|
* Copyright (C) 2023 limited_dev
|
||||||
|
*
|
||||||
|
* 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 de.limited_dev.botendo.util
|
||||||
|
|
||||||
|
import java.io.*
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object TokenManager {
|
||||||
|
private const val filename = "token.nils"
|
||||||
|
var token: String = "empty"
|
||||||
|
|
||||||
|
///Load the bot token, generate a config if there is none
|
||||||
|
fun load() {
|
||||||
|
val configFile = File(filename)
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
save()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val input: InputStream = FileInputStream(filename)
|
||||||
|
val prop = Properties()
|
||||||
|
prop.load(input)
|
||||||
|
token = if (prop.getProperty("token").equals("empty")) "empty" else prop.getProperty("token")
|
||||||
|
input.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///generate a new sample config
|
||||||
|
private fun save() {
|
||||||
|
val configFile = File(filename)
|
||||||
|
if (!configFile.exists()) {
|
||||||
|
try {
|
||||||
|
configFile.createNewFile()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
val output: OutputStream = FileOutputStream(filename)
|
||||||
|
val prop = Properties()
|
||||||
|
prop.setProperty("token", "empty")
|
||||||
|
prop.store(output, null)
|
||||||
|
output.close()
|
||||||
|
} catch (e: IOException) {
|
||||||
|
e.printStackTrace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue