diff --git a/plugins/hc_replay/index.js b/plugins/hc_replay/index.js new file mode 100644 index 0000000..fcb008d --- /dev/null +++ b/plugins/hc_replay/index.js @@ -0,0 +1,38 @@ +run.replay = async (...args) => { + pushMessage({ + nick: '*', + text: `Createing HCReplay URL...` + }) + try { + const content = [...document.querySelectorAll(".message")].map((msg)=>{ + return msg.querySelector("p") + }).filter((msg)=>{return msg}).map((msg)=>{ + return msg.getAttribute('data-raw') + }).join("\n"); + + const blob = new Blob([content], { type: 'text/plain' }); + const file = new File([blob], "ilove4n0n4me.txt", { type: 'text/plain' }); + const formData = new FormData(); + formData.append('reqtype', 'fileupload'); + formData.append('userhash', ''); + formData.append('fileToUpload', file); + const response = await camoFetch('https://catbox.moe/user/api.php', { + method: 'POST', + body: formData + }); + const box_url = await response.text(); + const replay_url = `https://cmd1152.github.io/hchistory/?t=0&u=${box_url.replace("https://files.catbox.moe/","cb/")}` + if (!box_url.startsWith("http")) { + throw "Failed to Update File" + } + pushMessage({ + nick: '*', + text: replay_url + }) + } catch (err) { + pushMessage({ + nick: '!', + text: `Failed to create HCReplay URL: ${err.message||err}` + }) + } + } \ No newline at end of file diff --git a/plugins/hc_replay/plugin.json b/plugins/hc_replay/plugin.json new file mode 100644 index 0000000..5f5ac81 --- /dev/null +++ b/plugins/hc_replay/plugin.json @@ -0,0 +1,7 @@ +{ + "id":"hc_replay", + "name":"HCReplay", + "description":"Adds a /replay Command to create HCReplay url.", + "author":"cmd1152", + "contact":"cmd1152__@Discord" +} diff --git a/plugins/plugins.json b/plugins/plugins.json index e419f30..b3a475a 100644 --- a/plugins/plugins.json +++ b/plugins/plugins.json @@ -19,6 +19,7 @@ "fast_know_kick_me", "edit_msg", "quit_hc", - "pangu" + "pangu", + "hc_replay" ] }