Skip to content
This repository has been archived by the owner on Apr 26, 2021. It is now read-only.

I fixed #31 for you (for the most part) (edit - for PC players) #40

Open
ghost opened this issue Jul 4, 2019 · 9 comments
Open

I fixed #31 for you (for the most part) (edit - for PC players) #40

ghost opened this issue Jul 4, 2019 · 9 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@ghost
Copy link

ghost commented Jul 4, 2019

for reference: #31

I felt like this should be fixed so I found a way to fix it. It's fixed under the assumption that you're running discord, destiny, and this script on the same computer. I say for the most part because there isn't anything you can do when someone is starting up the game. The script sees the game running so it goes to the API to get their status (which is wrong). If they shut down the game or start the script before they launch destiny, it does not claim they are on destiny.

Changes:

  • New utility method called isRunning. It checks if a process is running. It's copy/paste from the example in the stack overflow post in Shows as in orbit when the game isnt running #31, but it has the types defined so the noImplicitAny in your tsconfig can stay enabled. I don't know what the types for this line are so i just put them as any:

exec(cmd, function(err: any, stdout: any, stderr: any)

  • New discordRPC method called clearActivity. That clears the D2 activity in discord for us.
  • The Client's start method now calls isRunning to see if the game is running. If it is, then it does what you had before. If it isn't, it calls the new clearActivity method.

Example output:

C:\code\gitbase\discord-ghost>npm start

> @brakacai/[email protected] start C:\code\gitbase\discord-ghost
> node ./dist/index.js

Config file found
Starting service
Destiny2 is not running.
cleared rpc.
Destiny2 is not running.
cleared rpc.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
D2 is running! Lets do this.
Destiny2 is not running.
cleared rpc.
Destiny2 is not running.
cleared rpc.

Code is here: https://apx.gg/files/discord-ghost-src.zip

disclaimer - i'm a very experienced c# dev who has only dabbled in node.js. i do not know what i am doing, but i can make things work.

@louis-bompart
Copy link
Collaborator

Hey ! I'm quite interested, would you mind opening a PR so I can review that properly?

@louis-bompart louis-bompart added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels Jul 5, 2019
@ghost
Copy link
Author

ghost commented Jul 5, 2019

I haven't used github since college so I might be doing this wrong, but it looks like I need write access to upload the new branch.

@ghost
Copy link
Author

ghost commented Jul 5, 2019

nvm, figured it out. I made the pull request #49

It looks like visual studio's auto formatting messed with the spacing on the lines though so it isnt as easy to compare.

@ghost
Copy link
Author

ghost commented Jul 5, 2019

i tried to make it easier to compare. i'm really just messing around at this point

https://github.com/Akumati1435/discord-ghost/compare/master...Akumati1435:master-with-VS-line-formatting?expand=1

that should show you the oppose of the changes. red is green and green is red

edit: nvm, this comparison thing broke.

@ghost ghost changed the title I fixed #31 for you (for the most part) I fixed #31 for you (for the most part) (edit - for PC players) Jul 5, 2019
@louis-bompart
Copy link
Collaborator

louis-bompart commented Jul 5, 2019

I forked your branch and I'm taking time to thinks this over properly.
This change, semantically speaking, is a breaking change (change in behavior).
So I want to fix this once and for all, for everyone.

My current idea is the following:
Poke the API with an incremental delay (15s,30s,1m,2m,5m,15m,30m,1h,2h).
If activity is detected then reset the delay.
If no activity is detected after reaching the max delay, then start a final countdown of 24hrs. In the mean time, keep poking the API every MAX_DELAY (2hrs I'd say)
If the player is playing on PC (membershipType===4), on destiny 2 exe launch(and only on launch, i.e. first detection), reset the final countdown and the delay.
If the player quit the app (process not detected anymore), I'll certainly try to bust the cache (sorry Bungie!), now that I know it's possible. Thus allowing us to return to the routine (poke the api, increment timer and monitor process)

@louis-bompart
Copy link
Collaborator

Update, this one is almost next on my hit list. Sorry for the long wait, security and privacy were my upmost priorities

@Robinhubbard31
Copy link

It looks like everyone is doing a great job but I need to know what is happening?

@sirloveshatambaya
Copy link

Yes good job

@louis-bompart
Copy link
Collaborator

I'm not sure to understand your question @Robinhubbard31

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants