Skip to content

Commit

Permalink
Changed rank and installs to rl api
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark7625 committed Feb 6, 2024
1 parent 580114f commit 677a612
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/com/bot/events/MessageListener.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MessageListener : ListenerAdapter() {
}
event.message.delete().queue()
}
if (message.attachments.count { it.fileName == "client.log" } == 1) {
if (message.attachments.count { it.fileExtension == "log" } == 1) {
val downloadLoc = File("${message.id}.txt")
downloadLoc.mkdirs()
message.attachments[0].proxy.downloadToFile(downloadLoc).thenAccept {
Expand Down
31 changes: 23 additions & 8 deletions src/main/kotlin/com/bot/utils/Stats.kt
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
package com.bot.utils

import org.apache.commons.lang.StringUtils
import org.jsoup.Jsoup
import java.text.NumberFormat

object Stats {
fun getRank(): String {
fun getInstalls(): String {
val runeliteVersion = getRuneliteVerison()
if (runeliteVersion == "ERROR") {
return "0"
}
return try {
return NumberFormat.getIntegerInstance().format(Jsoup.connect("https://api.phstatistics.com/rank/plugin/117hd")
val doc = Jsoup.connect("https://api.runelite.net/runelite-${runeliteVersion}/pluginhub")
.userAgent("Mozilla").timeout(3000).ignoreContentType(true)
.get().body().text().toInt())
.get().body().text()

NumberFormat.getIntegerInstance().format(StringUtils.substringBetween(doc, "\"117hd\":", ",").toInt())
} catch (e: Exception) {
e.printStackTrace()
"2"
""
}
}

fun getInstalls(): String {
fun getRank(): String {
return "2"
}

private fun getRuneliteVerison(): String {
return try {
return NumberFormat.getIntegerInstance().format(Jsoup.connect("https://api.phstatistics.com/installs/plugin/117hd")
val doc = Jsoup.connect("https://static.runelite.net/bootstrap.json")
.userAgent("Mozilla").timeout(3000).ignoreContentType(true)
.get().body().text().toInt())
.get()


StringUtils.substringsBetween(doc.body().text(), "\"version\": \"", "\" }").last()
} catch (e: Exception) {
e.printStackTrace()
"2"
"ERROR"
}
}

}

0 comments on commit 677a612

Please sign in to comment.