Added auth for position you will stand after signing up
This commit is contained in:
parent
1ea47a9f7c
commit
cef71a5abe
6 changed files with 30 additions and 13 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -42,4 +42,4 @@ bin/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
offers.md
|
offers.md
|
||||||
rooms-scanned.txt
|
.env
|
||||||
|
|
@ -14,6 +14,7 @@ repositories {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1")
|
||||||
implementation("de.thelooter:toml4j:0.8.1")
|
implementation("de.thelooter:toml4j:0.8.1")
|
||||||
|
implementation("io.github.cdimascio:dotenv-kotlin:6.5.1")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.test {
|
tasks.test {
|
||||||
|
|
|
||||||
1
sample.env
Normal file
1
sample.env
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
AUTH=
|
||||||
|
|
@ -1,6 +1,12 @@
|
||||||
package me.koendev
|
package me.koendev
|
||||||
|
|
||||||
|
import io.github.cdimascio.dotenv.Dotenv
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
import java.time.LocalDate
|
||||||
|
import java.time.format.DateTimeFormatter
|
||||||
|
import java.time.temporal.ChronoUnit
|
||||||
|
|
||||||
|
val dotEnv = Dotenv.load()
|
||||||
|
|
||||||
data class ReactableOffer(
|
data class ReactableOffer(
|
||||||
val room: Room,
|
val room: Room,
|
||||||
|
|
@ -9,12 +15,8 @@ data class ReactableOffer(
|
||||||
)
|
)
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
val inputFile = File("rooms-scanned.txt")
|
|
||||||
|
|
||||||
val roomsFound = if (inputFile.exists()) inputFile.readLines() else listOf()
|
|
||||||
|
|
||||||
val rooms = getRooms().filter { room ->
|
val rooms = getRooms().filter { room ->
|
||||||
room.unitType == config.general.unitType && room.wocasId !in roomsFound
|
room.unitType == config.general.unitType
|
||||||
}
|
}
|
||||||
if (rooms.isEmpty()) {
|
if (rooms.isEmpty()) {
|
||||||
println("No suitable offers were found, quitting.")
|
println("No suitable offers were found, quitting.")
|
||||||
|
|
@ -33,13 +35,20 @@ fun main() {
|
||||||
}.filter {
|
}.filter {
|
||||||
val gender = it.floor.floorInfo.genderPreference
|
val gender = it.floor.floorInfo.genderPreference
|
||||||
|
|
||||||
|
val date = it.room.expireBy.take(10)
|
||||||
|
val date1 = LocalDate.now()
|
||||||
|
val date2 = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
||||||
|
val daysLeft = ChronoUnit.DAYS.between(date1, date2)
|
||||||
|
|
||||||
((gender == "female" && config.gender.female) ||
|
((gender == "female" && config.gender.female) ||
|
||||||
(gender == "male" && config.gender.male) ||
|
(gender == "male" && config.gender.male) ||
|
||||||
(gender == "none" && config.gender.none)) &&
|
(gender == "none" && config.gender.none)) &&
|
||||||
|
|
||||||
((config.general.smoking == -1 && !it.floor.floorInfo.smokingAllowed) || (config.general.smoking == 1 && it.floor.floorInfo.smokingAllowed) || config.general.smoking == 0) &&
|
((config.general.smoking == -1 && !(it.floor.floorInfo.smokingAllowed ?: true)) || (config.general.smoking == 1 && it.floor.floorInfo.smokingAllowed ?: true) || config.general.smoking == 0) &&
|
||||||
|
|
||||||
((config.general.pets == -1 && !it.floor.floorInfo.petsAllowed) || (config.general.pets == 1 && it.floor.floorInfo.petsAllowed) || config.general.pets == 0)
|
((config.general.pets == -1 && !it.floor.floorInfo.petsAllowed) || (config.general.pets == 1 && it.floor.floorInfo.petsAllowed) || config.general.pets == 0) &&
|
||||||
|
|
||||||
|
daysLeft == 0L
|
||||||
}
|
}
|
||||||
|
|
||||||
val fileName = "offers.md"
|
val fileName = "offers.md"
|
||||||
|
|
@ -67,16 +76,21 @@ fun main() {
|
||||||
str.append("| Geslacht | ${genderString.padEnd(18, ' ')} |\n")
|
str.append("| Geslacht | ${genderString.padEnd(18, ' ')} |\n")
|
||||||
|
|
||||||
|
|
||||||
str.append("| Roken | ${(if (it.floor.floorInfo.smokingAllowed) "✅ Mag" else "❌ Mag niet").padEnd(17, ' ')} |\n")
|
str.append("| Roken | ${(if (it.floor.floorInfo.smokingAllowed ?: true) "✅ Mag" else "❌ Mag niet").padEnd(17, ' ')} |\n")
|
||||||
str.append("| Huisdieren | ${(if (it.floor.floorInfo.petsAllowed) "✅ Mogen" else "❌ Mogen niet").padEnd(17, ' ')} |\n")
|
str.append("| Huisdieren | ${(if (it.floor.floorInfo.petsAllowed) "✅ Mogen" else "❌ Mogen niet").padEnd(17, ' ')} |\n")
|
||||||
str.append("| Reacties | ${it.floor.applicantCount.toString().padStart(3, ' ')} al gereageerd. |\n")
|
str.append("| Reacties | ${it.floor.potentialPosition} van de ${it.floor.applicantCount.toString().padStart(3, ' ')}. |\n")
|
||||||
|
|
||||||
|
val date = it.room.expireBy.take(10)
|
||||||
|
val date1 = LocalDate.now()
|
||||||
|
val date2 = LocalDate.parse(date, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
|
||||||
|
val daysLeft = ChronoUnit.DAYS.between(date1, date2)
|
||||||
|
str.append("| Tijd over | $daysLeft dagen over. |\n")
|
||||||
|
|
||||||
str.append("\n")
|
str.append("\n")
|
||||||
str.append("### Message: \n\n${it.floor.floorInfo.description ?: "Deze pannekoeken hebben geen bericht achtergelaten"}\n")
|
str.append("### Message: \n\n${it.floor.floorInfo.description ?: "Deze pannekoeken hebben geen bericht achtergelaten"}\n")
|
||||||
|
|
||||||
str.append("\n\n")
|
str.append("\n\n")
|
||||||
}
|
}
|
||||||
out.writeText(out.readText() + "\n\n" + str.toString())
|
out.writeText(str.toString())
|
||||||
inputFile.writeText(roomsFound.joinToString("\n") + "\n" + rooms.joinToString("\n") { it.wocasId })
|
|
||||||
println("${coupled.size} offers found, wrote to $fileName")
|
println("${coupled.size} offers found, wrote to $fileName")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ data class FloorInfo(
|
||||||
@SerialName("WocasId") val wocasId: String,
|
@SerialName("WocasId") val wocasId: String,
|
||||||
@SerialName("Description") val description: String?,
|
@SerialName("Description") val description: String?,
|
||||||
@SerialName("HospiteerDate") val hospiteerDate: String?,
|
@SerialName("HospiteerDate") val hospiteerDate: String?,
|
||||||
@SerialName("PreferenceSmokingAllowed") val smokingAllowed: Boolean,
|
@SerialName("PreferenceSmokingAllowed") val smokingAllowed: Boolean?,
|
||||||
@SerialName("PreferencePetsAllowed") val petsAllowed: Boolean,
|
@SerialName("PreferencePetsAllowed") val petsAllowed: Boolean,
|
||||||
@SerialName("PreferenceGender") val genderPreference: String,
|
@SerialName("PreferenceGender") val genderPreference: String,
|
||||||
@SerialName("NumberOfUnits") val numberOfUnits: Int,
|
@SerialName("NumberOfUnits") val numberOfUnits: Int,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ fun buildRequest(path: String): HttpRequest {
|
||||||
listOf(
|
listOf(
|
||||||
"cookie_consent_analytics=no",
|
"cookie_consent_analytics=no",
|
||||||
"cookie_consent=no",
|
"cookie_consent=no",
|
||||||
|
"SSHContext=${dotEnv["AUTH"]}"
|
||||||
).joinToString("; ")
|
).joinToString("; ")
|
||||||
)
|
)
|
||||||
.GET()
|
.GET()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue