-
-
Save iProdigy/53654691a76679221a74fd442dea068a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
async fetch(request, env, ctx) { | |
if (!isValidAgent(request.headers.get("User-Agent"))) { | |
return new Response(); | |
} | |
const form = await request.formData(); | |
const payload = JSON.parse(form.get("payload_json")); | |
const extra = payload.extra; | |
if (payload.type === "KILL_COUNT" && isNoteworthyKc(extra.boss, extra.count, extra.isPersonalBest)) { | |
return Response.redirect("https://discord.com/api/webhooks/redacted/redacted", 307); | |
} | |
return new Response(); | |
}, | |
}; | |
function isNoteworthyKc(boss, kc, pb) { | |
if (pb || kc === 1) return true; | |
if (boss === "TzKal-Zuk") return kc % 5 === 0; | |
if (boss === "Sol Heredit") return kc % 25 === 0; | |
return kc % 100 === 0; | |
} | |
function isValidAgent(ua) { | |
if (typeof ua !== "string") return false; | |
if (!ua.startsWith("RuneLite/") && !ua.startsWith("HDOS/")) return false; | |
return ua.includes("Dink/"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment