Switched to using e-z.gg
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { $, S3Client } from "bun";
|
||||
import { $ } from "bun";
|
||||
import { configDotenv } from "dotenv";
|
||||
import { homedir } from "os";
|
||||
import { readdirSync, readFileSync, statSync } from "fs";
|
||||
import { join } from "path";
|
||||
import { setConsoleTitle } from "@ocbwoy3/libocbwoy3";
|
||||
import { UploadToEZ } from "../lib/EZUploader";
|
||||
|
||||
setConsoleTitle("R2 Uploader");
|
||||
setConsoleTitle("Screenshot Uploader");
|
||||
|
||||
try {
|
||||
const start = Date.now();
|
||||
@@ -14,15 +15,6 @@ try {
|
||||
path: `${homedir()}/.ocbwoy3-dotfiles-SECRET-DO-NOT-TOUCH.env`
|
||||
});
|
||||
|
||||
const bucket = new S3Client({
|
||||
accessKeyId: process.env.S3_ACCESS_KEY,
|
||||
secretAccessKey: process.env.S3_SECRET_KEY,
|
||||
bucket: process.env.S3_BUCKET_NAME,
|
||||
endpoint: process.env.S3_ENDPOINT_URL,
|
||||
});
|
||||
|
||||
let urlParams = "";
|
||||
|
||||
const screenshotsDir = join(homedir(), "Pictures", "Screenshots");
|
||||
const files = readdirSync(screenshotsDir);
|
||||
|
||||
@@ -35,29 +27,11 @@ try {
|
||||
|
||||
const filePath = join(screenshotsDir, latestFile);
|
||||
|
||||
let [ _, regretevator, floorNum ] = latestFile.match(/\-(regretevator)\-?([0-9]+)?\.png$/) || [];
|
||||
const url = await UploadToEZ(readFileSync(filePath));
|
||||
|
||||
// the devs changed rich presence, what's the point of parsing the filename if tuxstrap doesn't update the state file anymore?
|
||||
if (regretevator === "regretevator") {
|
||||
latestFile = latestFile.replace(`-regretevator${floorNum ? `-${floorNum}` : ""}.png`,".png")
|
||||
// OR i could keep the filename and have my worker parse the filename
|
||||
if (floorNum) {
|
||||
urlParams = `?floor=${floorNum}`
|
||||
}
|
||||
}
|
||||
|
||||
const file = bucket.file(latestFile)
|
||||
await file.write(readFileSync(filePath), {
|
||||
type: "image/png"
|
||||
})
|
||||
$`echo "https://i.darktru.win/${encodeURIComponent(latestFile)}${urlParams}" | wl-copy -n`.nothrow().catch(a => { });
|
||||
$`notify-send "Screenshot" "Uploaded in ${Date.now() - start}ms<br/><small>${latestFile}</small>"`.nothrow().catch(a => { });
|
||||
$`echo "${url}" | wl-copy -n`.nothrow().catch(a => { });
|
||||
$`notify-send "Screenshot" "Uploaded to e-z.host in ${Date.now() - start}ms, URL copied to clipboard"`.nothrow().catch(a => { });
|
||||
} catch (e_) {
|
||||
const cx = `${e_}`.toLowerCase();
|
||||
if (cx.includes("enable r2") && cx.includes("cloudflare dashboard")) {
|
||||
$`notify-send "Screenshot" "YOU OWE CLOUDFLARE MONEY!!!!"`.nothrow().catch(a => { });
|
||||
process.exit(0);
|
||||
}
|
||||
$`notify-send "Screenshot" "${`${e_}`}"`.nothrow().catch(a => { });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user