Skip to content

Commit

Permalink
Add support for joining games indirectly
Browse files Browse the repository at this point in the history
When joining your friends on Roblox, the presence doesn't start &
doesn't set the rich presence. This commit fixes that, by automatically
updating the presence every 10 seconds if a game isn't detected, until
it detects one.
  • Loading branch information
6ixfalls committed Aug 3, 2022
1 parent b3736d5 commit 1e6f546
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/cominit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ processMonitor.on(
log.error("Multiple Roblox processes running!");
}

log.info(list[0]);

if (list[0].cmd.endsWith("RobloxPlayerBeta.exe")) {
log.info("Roblox process has no arguments! Aborting presence set.");
return;
Expand Down
18 changes: 12 additions & 6 deletions src/richPresence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ async function getGameFromCache(gameid: number) {
}

export async function BeginListener() {
CachedIcons[0] = {
name: "Unknown Game",
by: "Unknown",
iconkey: global.configJSON.defaultIconKey,
id: 0,
}

const process = childprocess.fork(path.join(__dirname, "cominit.js"));

process.on("message", async (msg) => {
Expand All @@ -69,23 +76,23 @@ export async function BeginListener() {

if (cmd.includes("RobloxPlayerBeta")) {
let scriptUrl = util.getScriptUrl(proc.arguments);
let placeId: number | false;
let placeId: number;

if (scriptUrl == false) {
log.info("[Detect:Proc] Couldn't find the script URL");
placeId = false;
placeId = 0;
scriptUrl = "";
} else {
log.info("[Detect:Proc] Script URL", scriptUrl);
}
if (!scriptUrl.includes("placeId=")) {
log.info("[Detect:Proc] Malformed script URL");
placeId = false;
placeId = 0;
}
placeId = parseInt(scriptUrl.split("placeId=")[1]);
if (isNaN(placeId)) {
log.info("[Detect:Proc] Malformed script URL");
placeId = false;
placeId = 0;
}
log.info("[Detect:Proc] Found game ID:", placeId);

Expand All @@ -96,11 +103,10 @@ export async function BeginListener() {
return;
}

if (placeId == false) {
if (placeId === 0) {
global.rpc.clearActivity();
global.tray.setTitle("");
log.info("[Detect:Proc] Couldn't find script URL");
return;
}

let game = await getGameFromCache(placeId);
Expand Down

0 comments on commit 1e6f546

Please sign in to comment.