Files
Nekosu/app/src/main/java/ru/risdeveau/pixeldragon/api/Server.kt
T

23 lines
615 B
Kotlin
Raw Normal View History

2025-02-21 14:44:48 +03:00
/*
* 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
}