23 lines
615 B
Kotlin
23 lines
615 B
Kotlin
|
|
/*
|
||
|
|
* Created by sweetbread on 21.02.2025, 12:01
|
||
|
|
* Copyright (c) 2025. All rights reserved.
|
||
|
|
* Last modified 21.02.2025, 12:01
|
||
|
|
*/
|
||
|
|
|
||
|
|
package ru.risdeveau.pixeldragon.api
|
||
|
|
|
||
|
|
import io.ktor.client.request.get
|
||
|
|
import io.ktor.client.statement.bodyAsText
|
||
|
|
import org.json.JSONException
|
||
|
|
import org.json.JSONObject
|
||
|
|
import ru.risdeveau.pixeldragon.client
|
||
|
|
|
||
|
|
suspend fun isMatrixServer(url: String): Boolean {
|
||
|
|
val r = try { client.get("https://$url/.well-known/matrix/client") }
|
||
|
|
catch (_: Exception) { return false }
|
||
|
|
|
||
|
|
try { JSONObject(r.bodyAsText()) }
|
||
|
|
catch (_: JSONException) { return false }
|
||
|
|
|
||
|
|
return true
|
||
|
|
}
|