ig putting it in a val in the post function saves it forever
This commit is contained in:
parent
3d4cfdb1c5
commit
ef4ba23e85
2 changed files with 23 additions and 25 deletions
|
@ -10,9 +10,9 @@ fun getMeow(): String {
|
|||
// source of characters to randomize
|
||||
val mainSrc = "meowrp"
|
||||
// length of meow
|
||||
var meowLength = (0..42).random()
|
||||
val meowLength = (0..42).random()
|
||||
// generate meow based on length and randomized characters
|
||||
var mainMeow =
|
||||
val mainMeow =
|
||||
java.util
|
||||
.Random()
|
||||
.ints(meowLength.toLong(), 0, mainSrc.length)
|
||||
|
@ -114,9 +114,9 @@ fun getMeow(): String {
|
|||
":nkobounce_purple:",
|
||||
)
|
||||
// choose a random cat emote out of list
|
||||
var randomCat = catEmotes.asSequence().shuffled().find { true }
|
||||
val randomCat = catEmotes.asSequence().shuffled().find { true }
|
||||
// choose a random balloon out of list
|
||||
var randomBalloon = balloon.asSequence().shuffled().find { true }
|
||||
val randomBalloon = balloon.asSequence().shuffled().find { true }
|
||||
|
||||
// if the neocat returns empty, don't use a balloon, else return cat and random balloon
|
||||
return if (randomCat == "") {
|
||||
|
@ -132,25 +132,25 @@ fun getBeep(): String {
|
|||
val eSrc = "e"
|
||||
val pSrc = "p"
|
||||
|
||||
var bLength = (1..8).random()
|
||||
var eLength = (1..16).random()
|
||||
var pLength = (1..8).random()
|
||||
val bLength = (1..8).random()
|
||||
val eLength = (1..16).random()
|
||||
val pLength = (1..8).random()
|
||||
|
||||
var bGen =
|
||||
val bGen =
|
||||
java.util
|
||||
.Random()
|
||||
.ints(bLength.toLong(), 0, bSrc.length)
|
||||
.asSequence()
|
||||
.map(bSrc::get)
|
||||
.joinToString("")
|
||||
var eGen =
|
||||
val eGen =
|
||||
java.util
|
||||
.Random()
|
||||
.ints(eLength.toLong(), 0, eSrc.length)
|
||||
.asSequence()
|
||||
.map(eSrc::get)
|
||||
.joinToString("")
|
||||
var pGen =
|
||||
val pGen =
|
||||
java.util
|
||||
.Random()
|
||||
.ints(pLength.toLong(), 0, pSrc.length)
|
||||
|
@ -201,9 +201,9 @@ fun getBeep(): String {
|
|||
":neubot_half_battery_charging:",
|
||||
)
|
||||
|
||||
var randomBot = botEmotes.asSequence().shuffled().find { true }
|
||||
val randomBot = botEmotes.asSequence().shuffled().find { true }
|
||||
// choose a random balloon out of list
|
||||
var randomBalloon = balloon.asSequence().shuffled().find { true }
|
||||
val randomBalloon = balloon.asSequence().shuffled().find { true }
|
||||
|
||||
return if (randomBot == "") {
|
||||
"$bGen$eGen$pGen"
|
||||
|
|
|
@ -64,12 +64,11 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
}
|
||||
// meow button
|
||||
post {
|
||||
var meow = getMeow()
|
||||
if (call.receiveText() == Config().superSecret) {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
makePost(client, meow, Config().instanceDomain)
|
||||
makePost(client, getMeow(), Config().instanceDomain)
|
||||
call.respondText("meowed with bypass")
|
||||
logger.info { "'$meow' with bypass" }
|
||||
logger.info { "meowed with bypass" }
|
||||
} else {
|
||||
if (meowTimedOut) {
|
||||
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||
|
@ -77,10 +76,10 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
logger.info { "failed meow" }
|
||||
} else {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
makePost(client, meow, Config().instanceDomain)
|
||||
makePost(client, getMeow(), Config().instanceDomain)
|
||||
meowTimer()
|
||||
call.respondText("'$meow' sent!")
|
||||
logger.info { "meowed: '$meow'" }
|
||||
call.respondText("meow' sent!")
|
||||
logger.info { "meowed" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -88,7 +87,6 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
|
||||
// beep
|
||||
route("/beep") {
|
||||
var beep = getBeep()
|
||||
// get meow timeout
|
||||
get {
|
||||
if (beepTimedOut) {
|
||||
|
@ -101,13 +99,13 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
logger.debug { "not timed out" }
|
||||
}
|
||||
}
|
||||
// meow button
|
||||
// beep button
|
||||
post {
|
||||
if (call.receiveText() == Config().superSecret) {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
makePost(client, beep, Config().instanceDomain)
|
||||
makePost(client, getBeep(), Config().instanceDomain)
|
||||
call.respondText("beeped with bypass")
|
||||
logger.info { "'$beep' with bypass" }
|
||||
logger.info { "beeped with bypass" }
|
||||
} else {
|
||||
if (beepTimedOut) {
|
||||
call.response.status(HttpStatusCode(423, "Timed Out"))
|
||||
|
@ -115,10 +113,10 @@ fun Application.configureRouting(client: HttpClient) {
|
|||
logger.info { "failed beeped" }
|
||||
} else {
|
||||
call.response.status(HttpStatusCode(201, "Meow Posted"))
|
||||
makePost(client, beep, Config().instanceDomain)
|
||||
makePost(client, getBeep(), Config().instanceDomain)
|
||||
beepTimer()
|
||||
call.respondText("'$beep' sent!")
|
||||
logger.info { "beeped: '$beep'" }
|
||||
call.respondText("beep sent!")
|
||||
logger.info { "beeped" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue