Move more stuff, start config site development
This commit is contained in:
parent
71b657f108
commit
aa55c21f04
|
@ -24,7 +24,7 @@ dependencies {
|
||||||
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
|
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.1'
|
||||||
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.1'
|
compile group: 'org.apache.logging.log4j', name: 'log4j-slf4j-impl', version: '2.11.1'
|
||||||
compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
compile 'com.github.salomonbrys.kotson:kotson:2.5.0'
|
||||||
compile "com.sparkjava:spark-kotlin:1.0.0-alpha"
|
compile 'io.javalin:javalin:2.1.1'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"httpPort": 7222,
|
||||||
"guildWords": {
|
"guildWords": {
|
||||||
"174602395630829568": {
|
"174602395630829568": {
|
||||||
"list": [
|
"list": [
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package nl.voidcorp.yeetbot
|
package nl.voidcorp.yeetbot
|
||||||
|
|
||||||
data class Config(val guildWords: MutableMap<Long, GuildInfo> = mutableMapOf())
|
data class Config(var httpPort: Int = 7222, val guildWords: MutableMap<Long, GuildInfo> = mutableMapOf())
|
||||||
|
|
||||||
data class GuildInfo(val list: MutableList<Match> = mutableListOf())
|
data class GuildInfo(val list: MutableList<Match> = mutableListOf())
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
package nl.voidcorp.yeetbot
|
package nl.voidcorp.yeetbot
|
||||||
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
import java.util.regex.PatternSyntaxException
|
||||||
|
|
||||||
val gson = GsonBuilder().setPrettyPrinting().create()
|
val gson = GsonBuilder().setPrettyPrinting().create()
|
||||||
|
|
||||||
|
fun Any.toJson():String = gson.toJson(this)
|
||||||
|
|
||||||
|
fun checkRegex(pattern: String): Boolean {
|
||||||
|
var exc: PatternSyntaxException? = null
|
||||||
|
try {
|
||||||
|
Pattern.compile(pattern)
|
||||||
|
} catch (e: PatternSyntaxException) {
|
||||||
|
exc = e
|
||||||
|
}
|
||||||
|
|
||||||
|
return exc == null
|
||||||
|
}
|
|
@ -1,15 +1,19 @@
|
||||||
package nl.voidcorp.yeetbot
|
package nl.voidcorp.yeetbot
|
||||||
|
|
||||||
import com.github.salomonbrys.kotson.fromJson
|
import com.github.salomonbrys.kotson.fromJson
|
||||||
import net.dv8tion.jda.core.*
|
import io.javalin.Javalin
|
||||||
|
import io.javalin.json.FromJsonMapper
|
||||||
|
import io.javalin.json.JavalinJson
|
||||||
|
import io.javalin.json.ToJsonMapper
|
||||||
|
import net.dv8tion.jda.core.AccountType
|
||||||
|
import net.dv8tion.jda.core.JDABuilder
|
||||||
|
import net.dv8tion.jda.core.OnlineStatus
|
||||||
import net.dv8tion.jda.core.entities.Game
|
import net.dv8tion.jda.core.entities.Game
|
||||||
import org.apache.logging.log4j.LogManager
|
import org.apache.logging.log4j.LogManager
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FileReader
|
import java.io.FileReader
|
||||||
import java.io.FileWriter
|
import java.io.FileWriter
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.regex.Pattern
|
|
||||||
import java.util.regex.PatternSyntaxException
|
|
||||||
import kotlin.concurrent.fixedRateTimer
|
import kotlin.concurrent.fixedRateTimer
|
||||||
import kotlin.concurrent.schedule
|
import kotlin.concurrent.schedule
|
||||||
|
|
||||||
|
@ -82,16 +86,24 @@ fun main(args: Array<String>) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JavalinJson.toJsonMapper = object : ToJsonMapper {
|
||||||
|
override fun map(obj: Any): String = obj.toJson()
|
||||||
|
}
|
||||||
|
|
||||||
|
JavalinJson.fromJsonMapper = object : FromJsonMapper {
|
||||||
|
override fun <T> map(json: String, targetClass: Class<T>): T = gson.fromJson(json, targetClass)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
val app = Javalin.create().start(config.httpPort)
|
||||||
|
app.get("/") {
|
||||||
|
it.result("memes!")
|
||||||
|
}
|
||||||
|
|
||||||
|
app.get("/test") {
|
||||||
|
it.json(config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun checkRegex(pattern: String): Boolean {
|
|
||||||
var exc: PatternSyntaxException? = null
|
|
||||||
try {
|
|
||||||
Pattern.compile(pattern)
|
|
||||||
} catch (e: PatternSyntaxException) {
|
|
||||||
exc = e
|
|
||||||
}
|
|
||||||
|
|
||||||
return exc == null
|
|
||||||
}
|
|
Loading…
Reference in a new issue