Juby210 / Aliucord-plugins

Plugins for Aliucord.
Open Software License 3.0
166 stars 23 forks source link

MessageLogger PluralKit Compatibility #34

Open KiARC opened 2 years ago

KiARC commented 2 years ago

To help make sure that PluralKit doesn't jam up the log with unnecessary messages, maybe you could run every message through this before logging it:

fun isProxyTrigger(id: String): Boolean {
  val client = HttpClient.newBuilder().build()
  val request = HttpRequest.newBuilder().uri(URI.create("https://api.PluralKit.me/v2/messages/"+id)).build()
  val response = StringBuilder(client.send(request, HttpResponse.BodyHandlers.ofString()).body())
  val json: JsonObject = Parser.default().parse(response) as JsonObject
  return if (json.int("code") != null) false else json.string("id") != id
}

If the result is true just don't log it. Additionally don't log messages matching the regex /pk;e.*/i to eliminate message-edit commands.