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

support OBS auto streamer mode via an arrpc patch #822

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 40 additions & 4 deletions patches/[email protected]
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
diff --git a/src/process/index.js b/src/process/index.js
index 97ea6514b54dd9c5df588c78f0397d31ab5f882a..c2bdbd6aaa5611bc6ff1d993beeb380b1f5ec575 100644
index 97ea651..29e964e 100644
--- a/src/process/index.js
+++ b/src/process/index.js
@@ -5,8 +5,7 @@ import fs from 'node:fs';
import { dirname, join } from 'path';
import { fileURLToPath } from 'url';
@@ -1,12 +1,7 @@
const rgb = (r, g, b, msg) => `\x1b[38;2;${r};${g};${b}m${msg}\x1b[0m`;
const log = (...args) => console.log(`[${rgb(88, 101, 242, 'arRPC')} > ${rgb(237, 66, 69, 'process')}]`, ...args);

-import fs from 'node:fs';
-import { dirname, join } from 'path';
-import { fileURLToPath } from 'url';
-
-const __dirname = dirname(fileURLToPath(import.meta.url));
-const DetectableDB = JSON.parse(fs.readFileSync(join(__dirname, 'detectable.json'), 'utf8'));
+const DetectableDB = require('./detectable.json');

import * as Natives from './native/index.js';
const Native = Natives[process.platform];
diff --git a/update_db.js b/update_db.js
index ed94923..24deace 100644
--- a/update_db.js
+++ b/update_db.js
@@ -1,5 +1,5 @@
#!/usr/bin/env node
-import { createWriteStream, readFileSync } from 'fs';
+import { createWriteStream, readFileSync, writeFileSync } from 'fs';
import { get } from 'https';

import { dirname, join } from 'path';
@@ -25,5 +25,19 @@ get('https://discord.com/api/v9/applications/detectable', res => {
const oldNames = current.map(x => x.name);
const newNames = updated.map(x => x.name);
console.log(newNames.filter(x => !oldNames.includes(x)));
+
+ // append obs for auto streammode
+ updated.push({
+ aliases: ["Obs"],
+ executables: [
+ { is_launcher: false, name: "obs", os: "linux" },
+ { is_launcher: false, name: "obs.exe", os: "win32" },
+ { is_launcher: false, name: "obs.app", os: "darwin" }
+ ],
+ hook: true,
+ id: "STREAMERMODE",
+ name: "OBS"
+ });
+ writeFileSync(path, JSON.stringify(updated), 'utf8');
})
});
\ No newline at end of file
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions scripts/build/build.mts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (c) 2023 Vendicated and Vencord contributors
*/

import { execSync } from "child_process";
import { BuildContext, BuildOptions, context } from "esbuild";
import { copyFile } from "fs/promises";

Expand Down Expand Up @@ -49,8 +50,15 @@ async function copyVenmic() {
]).catch(() => console.warn("Failed to copy venmic. Building without venmic support"));
}

async function updateArrpcDb() {
return Promise.all([execSync("node node_modules/arrpc/update_db.js")]).catch(() =>
console.warn("Error running update_db.js Auto streamermode will not work.")
);
}

await Promise.all([
copyVenmic(),
updateArrpcDb(),
createContext({
...NodeCommonOpts,
entryPoints: ["src/main/index.ts"],
Expand Down
12 changes: 9 additions & 3 deletions src/renderer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import "./themedSplash";
console.log("read if cute :3");

export * as Components from "./components";
import { findByPropsLazy, onceReady } from "@vencord/types/webpack";
import { findByPropsLazy, findStore, onceReady } from "@vencord/types/webpack";
import { Alerts, FluxDispatcher } from "@vencord/types/webpack/common";

import SettingsUi from "./components/settings/Settings";
Expand Down Expand Up @@ -56,8 +56,14 @@ VesktopNative.arrpc.onActivity(async data => {
if (!Settings.store.arRPC) return;

await onceReady;

arRPC.handleEvent(new MessageEvent("message", { data }));
const StreamerModeStore = findStore("StreamerModeStore");
if (JSON.parse(data).socketId === "STREAMERMODE" && StreamerModeStore.autoToggle) {
FluxDispatcher.dispatch({
type: "STREAMER_MODE_UPDATE",
key: "enabled",
value: JSON.parse(data).activity?.application_id === "STREAMERMODE"
});
} else arRPC.handleEvent(new MessageEvent("message", { data }));
});

// TODO: remove soon
Expand Down
1 change: 1 addition & 0 deletions src/renderer/patches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ import "./hideVenmicInput";
import "./screenShareFixes";
import "./spellCheck";
import "./windowsTitleBar";
import "./streamerMode";
20 changes: 20 additions & 0 deletions src/renderer/patches/streamerMode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* SPDX-License-Identifier: GPL-3.0
* Vesktop, a desktop app aiming to give you a snappier Discord Experience
* Copyright (c) 2023 Vendicated and Vencord contributors
*/

import { addPatch } from "./shared";

addPatch({
patches: [
{
find: ".STREAMER_MODE_ENABLE,",
replacement: {
// eslint-disable-next-line no-useless-escape
match: /\i\.isPlatformEmbedded/g,
replace: "true"
}
}
]
});