Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic Discord webhook screenshots #28

Open
wants to merge 34 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
da078dc
auto upload screenshots to discord
evilandrex Jul 31, 2023
e8ca488
always upload screenshot on phase transition
evilandrex Jul 31, 2023
530a838
update webhook url setting description
evilandrex Jul 31, 2023
9f2ebdd
attempt to filter out some non-boss fights
evilandrex Aug 1, 2023
8ddeb65
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Aug 2, 2023
fe87277
clean and make upload more consistent
evilandrex Aug 3, 2023
520dd2a
change discord message and upload notify
evilandrex Aug 3, 2023
3d7a30a
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Aug 16, 2023
71d0259
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Sep 14, 2023
352ad5f
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Oct 11, 2023
c6feabb
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Oct 25, 2023
a7e37ef
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Nov 16, 2023
1a1d773
Merge remote-tracking branch 'loa-ark-dev-main/main' into discord-web…
evilandrex Nov 16, 2023
c96bce7
Merge branch 'main' of githubPersonal:lost-ark-dev/loa-details into d…
evilandrex Dec 14, 2023
46996a2
auto upload screenshots to discord
evilandrex Jul 31, 2023
5a8965d
always upload screenshot on phase transition
evilandrex Jul 31, 2023
5020347
update webhook url setting description
evilandrex Jul 31, 2023
700377a
attempt to filter out some non-boss fights
evilandrex Aug 1, 2023
498b0af
clean and make upload more consistent
evilandrex Aug 3, 2023
d24c32e
change discord message and upload notify
evilandrex Aug 3, 2023
e411021
Merge branch 'discord-webhook-screenshots' of githubPersonal:evilandr…
evilandrex Jan 10, 2024
04152ae
Merge remote-tracking branch 'loa-ark-dev-main/main' into discord-web…
evilandrex Jan 14, 2024
38a77d2
auto upload screenshots to discord
evilandrex Jul 31, 2023
5418576
always upload screenshot on phase transition
evilandrex Jul 31, 2023
6c21b8e
update webhook url setting description
evilandrex Jul 31, 2023
964eebf
attempt to filter out some non-boss fights
evilandrex Aug 1, 2023
e920b3e
clean and make upload more consistent
evilandrex Aug 3, 2023
671336e
change discord message and upload notify
evilandrex Aug 3, 2023
5acfed9
Merge branch 'lost-ark-dev:main' into discord-webhook-screenshots
evilandrex Feb 8, 2024
8c01d69
Remove Discord webhook duplicate
evilandrex Feb 8, 2024
b2e9a08
Merge branch 'main' of githubPersonal:lost-ark-dev/loa-details into d…
evilandrex Mar 20, 2024
32556b8
version bump
evilandrex Mar 20, 2024
6fe0989
Merge branch 'main' of githubPersonal:lost-ark-dev/loa-details into d…
evilandrex Mar 27, 2024
e8c62fd
Merge branch 'main' of githubPersonal:lost-ark-dev/loa-details into d…
evilandrex Mar 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src-electron/util/app-settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export type Settings = {
openOnUpload: boolean;
uploadUnlisted: boolean;
includeRegion: boolean;
uploadDiscord: boolean;
discordWebhook: string;
};
damageMeter: {
functionality: {
Expand Down Expand Up @@ -187,6 +189,8 @@ const defaultSettings: Settings = {
openOnUpload: false,
uploadUnlisted: true,
includeRegion: false,
uploadDiscord: false,
discordWebhook: "",
},
damageMeter: {
functionality: {
Expand Down
Binary file added src/assets/images/classes/101.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/102.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/103.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/104.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/105.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/111.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions src/assets/images/classes/111.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/112.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/201.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/202.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/203.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/204.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/205.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/301.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/302.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/303.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/304.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/305.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/311.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/312.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/401.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/402.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/403.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/404.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/501.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/images/classes/502.png
Binary file added src/assets/images/classes/503.png
Binary file added src/assets/images/classes/504.png
Binary file added src/assets/images/classes/505.png
Binary file added src/assets/images/classes/511.png
Binary file added src/assets/images/classes/512.png
Binary file added src/assets/images/classes/601.png
Binary file added src/assets/images/classes/602.png
Binary file added src/assets/images/classes/603.png
Binary file added src/assets/images/classes/604.png
50 changes: 50 additions & 0 deletions src/components/SettingsPage/UploadPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,49 @@
</q-item-section>
</q-item>

<q-item
:disable="settingsStore.settings.uploads.discordWebhook.length == 0"
tag="label"
>
<q-item-section side top>
<q-checkbox
v-model="settingsStore.settings.uploads.uploadDiscord"
:disable="settingsStore.settings.uploads.discordWebhook.length == 0"
/>
</q-item-section>

<q-item-section>
<q-item-label>
Upload Screenshot to Discord
</q-item-label>
<q-item-label caption>
Automatically upload a screenshot of the meter to a Discord webhook
after each encounter.
</q-item-label>
</q-item-section>
</q-item>

<q-item tag="label">
<q-item-section left>
<q-item-label>Discord Webhook</q-item-label>
<q-item-label caption>
A Discord webhook URL to upload screenshots to.<br/>
Go to a Discord Channel's settings, then "Integrations", then
"Webhooks", then "New Webhook".
</q-item-label>
</q-item-section>
<q-item-section right>
<q-input
v-model="discordWebhook"
type=text
label="Discord Webhook URL"
clearable
@clear="discordWebhook = ''"
>
</q-input>
</q-item-section>
</q-item>

<q-separator spaced />

<q-item tag="label">
Expand Down Expand Up @@ -195,6 +238,7 @@ const settingsStore = useSettingsStore();

const isPwd = ref(true);
const uploadKey = ref("");
const discordWebhook = ref("");
const showAdvanced = ref(false);

window.messageApi.receive("settings-changed", (value) => {
Expand All @@ -206,8 +250,14 @@ watch(uploadKey, (newVal, oldVal) => {
settingsStore.settings.uploads.uploadKey = newVal;
});

watch(discordWebhook, (newVal, oldVal) => {
if (newVal.length == 0) settingsStore.settings.uploads.uploadDiscord = false;
settingsStore.settings.uploads.discordWebhook = newVal;
});

onMounted(() => {
uploadKey.value = settingsStore.settings.uploads.uploadKey;
discordWebhook.value = settingsStore.settings.uploads.discordWebhook;
});
/**
* @param {'api' | 'site' | 'endpoint'} type
Expand Down
94 changes: 94 additions & 0 deletions src/layouts/DamageMeter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@
</div>
</div>
<div v-if="!isTakingScreenshot" style="margin-left: auto">
<q-btn
v-if="!isMinimized && settingsStore.settings.uploads.discordWebhook.length !== 0"
round
icon="discord"
@click="toggleDiscordScreenshot"
flat
:glossy=settingsStore.settings.uploads.uploadDiscord
size="sm"
>
<q-tooltip ref="discordScreenshotTooltip">
Toggle Discord screenshot upload
</q-tooltip>
</q-btn>
<q-btn
v-if="!isMinimized"
round
Expand Down Expand Up @@ -299,6 +312,8 @@ import { useSettingsStore } from "src/stores/settings";
import DamageMeterTable from "src/components/DamageMeter/DamageMeterTable.vue";
import { DamageType } from "src/util/helpers";

import axios from "axios";

const logoImg = new URL("../assets/images/logo.png", import.meta.url).href;

const settingsStore = useSettingsStore();
Expand Down Expand Up @@ -396,6 +411,73 @@ async function takeScreenshot() {
});
}

function toggleDiscordScreenshot() {
settingsStore.settings.uploads.uploadDiscord =
!settingsStore.settings.uploads.uploadDiscord;
settingsStore.saveSettings();
}

let lastScreenshotPacket = 0;
async function uploadDiscordScreenshot() {
const oldDamageType = damageType.value;
damageType.value = "dmg";
isTakingScreenshot.value = true;
await sleep(600);
if (damageMeterRef.value === null) return;
const screenshot = await html2canvas(damageMeterRef.value, {
backgroundColor: "#121212",
});

screenshot.toBlob(
(blob) => {
if (!blob) return;

let msg = sessionState.value.currentBoss?.name || "No Boss";
msg += "\n";
msg += "Uploaded by ";
msg += sessionState.value.localPlayer || "Unknown";

void axios.postForm(
settingsStore.settings.uploads.discordWebhook,
{
"payload_json": JSON.stringify({
content: msg,
attachments: [{
id: 0,
filename: "screenshot.png",
content_type: "image/png",
}]
}),
"files[0]": blob,
}
);

},
"image/png",
1
);

damageType.value = oldDamageType;

isTakingScreenshot.value = false;
Notify.create({
message: "<center>Screenshot sent to Discord.</center>",
color: "primary",
html: true,
actions: [
{
label: "Dismiss",
color: "white",
handler: () => {
/* ... */
},
},
],
});

return "Screenshot sent to Discord."
}

function requestSessionRestart() {
window.messageApi.send("window-to-main", { message: "reset-session" });
}
Expand Down Expand Up @@ -526,6 +608,18 @@ onMounted(() => {
});
}
}

if (
!isMinimized.value &&
settingsStore.settings.uploads.uploadDiscord &&
sessionState.value.currentBoss && // Only upload bosses
sessionState.value.lastCombatPacket !== lastScreenshotPacket && // No repeat uploads
sessionState.value.lastCombatPacket -
sessionState.value.currentBoss.lastUpdate < 3000 // Avoids uploading trash mobs
) {
lastScreenshotPacket = sessionState.value.lastCombatPacket;
void uploadDiscordScreenshot()
}
}
} else {
Notify.create({
Expand Down
2 changes: 2 additions & 0 deletions src/stores/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ export const useSettingsStore = defineStore("settings", {
openOnUpload: false,
uploadUnlisted: true,
includeRegion: false,
uploadDiscord: false,
discordWebhook: "",
},
damageMeter: {
functionality: {
Expand Down