main #8

Closed
limepotato wants to merge 183 commits from main into blog-drafts
2 changed files with 23 additions and 25 deletions
Showing only changes of commit ef4ba23e85 - Show all commits

View file

@ -10,9 +10,9 @@ fun getMeow(): String {
// source of characters to randomize // source of characters to randomize
val mainSrc = "meowrp" val mainSrc = "meowrp"
// length of meow // length of meow
var meowLength = (0..42).random() val meowLength = (0..42).random()
// generate meow based on length and randomized characters // generate meow based on length and randomized characters
var mainMeow = val mainMeow =
java.util java.util
.Random() .Random()
.ints(meowLength.toLong(), 0, mainSrc.length) .ints(meowLength.toLong(), 0, mainSrc.length)
@ -114,9 +114,9 @@ fun getMeow(): String {
":nkobounce_purple:", ":nkobounce_purple:",
) )
// choose a random cat emote out of list // 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 // 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 // if the neocat returns empty, don't use a balloon, else return cat and random balloon
return if (randomCat == "") { return if (randomCat == "") {
@ -132,25 +132,25 @@ fun getBeep(): String {
val eSrc = "e" val eSrc = "e"
val pSrc = "p" val pSrc = "p"
var bLength = (1..8).random() val bLength = (1..8).random()
var eLength = (1..16).random() val eLength = (1..16).random()
var pLength = (1..8).random() val pLength = (1..8).random()
var bGen = val bGen =
java.util java.util
.Random() .Random()
.ints(bLength.toLong(), 0, bSrc.length) .ints(bLength.toLong(), 0, bSrc.length)
.asSequence() .asSequence()
.map(bSrc::get) .map(bSrc::get)
.joinToString("") .joinToString("")
var eGen = val eGen =
java.util java.util
.Random() .Random()
.ints(eLength.toLong(), 0, eSrc.length) .ints(eLength.toLong(), 0, eSrc.length)
.asSequence() .asSequence()
.map(eSrc::get) .map(eSrc::get)
.joinToString("") .joinToString("")
var pGen = val pGen =
java.util java.util
.Random() .Random()
.ints(pLength.toLong(), 0, pSrc.length) .ints(pLength.toLong(), 0, pSrc.length)
@ -201,9 +201,9 @@ fun getBeep(): String {
":neubot_half_battery_charging:", ":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 // choose a random balloon out of list
var randomBalloon = balloon.asSequence().shuffled().find { true } val randomBalloon = balloon.asSequence().shuffled().find { true }
return if (randomBot == "") { return if (randomBot == "") {
"$bGen$eGen$pGen" "$bGen$eGen$pGen"

View file

@ -64,12 +64,11 @@ fun Application.configureRouting(client: HttpClient) {
} }
// meow button // meow button
post { post {
var meow = getMeow()
if (call.receiveText() == Config().superSecret) { if (call.receiveText() == Config().superSecret) {
call.response.status(HttpStatusCode(201, "Meow Posted")) call.response.status(HttpStatusCode(201, "Meow Posted"))
makePost(client, meow, Config().instanceDomain) makePost(client, getMeow(), Config().instanceDomain)
call.respondText("meowed with bypass") call.respondText("meowed with bypass")
logger.info { "'$meow' with bypass" } logger.info { "meowed with bypass" }
} else { } else {
if (meowTimedOut) { if (meowTimedOut) {
call.response.status(HttpStatusCode(423, "Timed Out")) call.response.status(HttpStatusCode(423, "Timed Out"))
@ -77,10 +76,10 @@ fun Application.configureRouting(client: HttpClient) {
logger.info { "failed meow" } logger.info { "failed meow" }
} else { } else {
call.response.status(HttpStatusCode(201, "Meow Posted")) call.response.status(HttpStatusCode(201, "Meow Posted"))
makePost(client, meow, Config().instanceDomain) makePost(client, getMeow(), Config().instanceDomain)
meowTimer() meowTimer()
call.respondText("'$meow' sent!") call.respondText("meow' sent!")
logger.info { "meowed: '$meow'" } logger.info { "meowed" }
} }
} }
} }
@ -88,7 +87,6 @@ fun Application.configureRouting(client: HttpClient) {
// beep // beep
route("/beep") { route("/beep") {
var beep = getBeep()
// get meow timeout // get meow timeout
get { get {
if (beepTimedOut) { if (beepTimedOut) {
@ -101,13 +99,13 @@ fun Application.configureRouting(client: HttpClient) {
logger.debug { "not timed out" } logger.debug { "not timed out" }
} }
} }
// meow button // beep button
post { post {
if (call.receiveText() == Config().superSecret) { if (call.receiveText() == Config().superSecret) {
call.response.status(HttpStatusCode(201, "Meow Posted")) call.response.status(HttpStatusCode(201, "Meow Posted"))
makePost(client, beep, Config().instanceDomain) makePost(client, getBeep(), Config().instanceDomain)
call.respondText("beeped with bypass") call.respondText("beeped with bypass")
logger.info { "'$beep' with bypass" } logger.info { "beeped with bypass" }
} else { } else {
if (beepTimedOut) { if (beepTimedOut) {
call.response.status(HttpStatusCode(423, "Timed Out")) call.response.status(HttpStatusCode(423, "Timed Out"))
@ -115,10 +113,10 @@ fun Application.configureRouting(client: HttpClient) {
logger.info { "failed beeped" } logger.info { "failed beeped" }
} else { } else {
call.response.status(HttpStatusCode(201, "Meow Posted")) call.response.status(HttpStatusCode(201, "Meow Posted"))
makePost(client, beep, Config().instanceDomain) makePost(client, getBeep(), Config().instanceDomain)
beepTimer() beepTimer()
call.respondText("'$beep' sent!") call.respondText("beep sent!")
logger.info { "beeped: '$beep'" } logger.info { "beeped" }
} }
} }
} }