discord-ghost icon indicating copy to clipboard operation
discord-ghost copied to clipboard

checks if destiny is running. if not, clears the activity

Open ghost opened this issue 5 years ago • 14 comments

looks like visual studio messed with stuff a bit so this isnt as easy to compare...

ghost avatar Jul 05 '19 02:07 ghost

This should be optional, as it would make the tool only usable by PC players - console players want the tool to run even though they don't have a Destiny2.exe process...

mrphlip avatar Jul 05 '19 03:07 mrphlip

Yep. you can add a config for that.

Like, if a user puts in a battletag then ask if they want to use this instead?

ghost avatar Jul 05 '19 03:07 ghost

I moved some of the code around so if you have a flag for this in your configs, you can switch between the two.

ghost avatar Jul 05 '19 04:07 ghost

This project might have code to get it working for PS4 players: https://github.com/Frankity/Ps4Rpc

There is probably something similar for xbox. If it requires the user to authenticate to get the info the ROI probably isnt high enough though.

ghost avatar Jul 05 '19 04:07 ghost

As much as I'd like to support Playstation and Xbox exactly the same, the fact they're running the game on a different platform is ofc a big limiter there.

So, what'll be done for now is this for PC. To do so, we can use the membershipInformation that we get in the config. (@Akumati1435 please consider this in the upcoming work you'll do on this)

What'll be done for other platforms will be investigated later (@mrphlip please create an issue to follow up on that).

I'm doing a deep dive review on your code now @Akumati1435 (fair warning, I'm quite a demanding reviewer, I preach for quality over feature)

louis-bompart avatar Jul 05 '19 05:07 louis-bompart

like i said, i am not good with node.js. you really should just get an experienced node.js dev to turn what I wrote into a production quality version. I've written 10s of thousands of lines of c# code to automated my discord community but the bots I made with node.js are extremely basic.

ghost avatar Jul 05 '19 06:07 ghost

👍 Alright, we'll work from what you've done here then, tho, your contribution is much appreciated, I just try to keep the code as clean as it is right now :)

louis-bompart avatar Jul 05 '19 06:07 louis-bompart

Alright! I took me a full day of thinking (in the background), but I think I have a good proposition.

When you'll start up the app, during the setting up phase, a new question will be asked to the user. It'll be something like:

Would you like us to monitor if Destiny 2 is running on this computer to start the service?

If answered yes, we will do something based on this Pull Request, we will start polling Bungie API when we detect Destiny 2 being launched. However, we will remove most part of the logic for an NPM package https://www.npmjs.com/package/ps-list, to have less code to maintain.

If answered no, and that's what shall interest you @mrphlip we will continuously poll the API, but with a delay that'll increase exponentially.

It'll start at 15s, the basic value, then double to 30s, then 1m, 2m, 5m, 15m, 30m, 1h. When we reach the two hours, what I'd name a final countdown/ Doomsday clock will start. We will keep polling every hour. But, 24hrs later after we reached the 1hr delay, the program will ~~ commit seppuku ~~ silently shut down.

What do you think about that?

louis-bompart avatar Jul 06 '19 03:07 louis-bompart

I originally made this with ps-list, but after seeing how abysmal the performance was i switched off it. If you benchmark that vs the method I copy/pasted off stackoverflow, you'll notice a massive difference. I've heard ps-list takes up a lot of ram too for unknown reasons.

If you have the program poll once an hour towards the end of it for console peasants, won't that mean up to an hour of the script not showing the discord integration? It seems like you can safely clear the game activity after some time, but you should still be monitoring the API for new activity at the same interval.

Also, not sure if you have error handling for when bungie throws up, but it throws up a lot. For my stuff I keep a list of error codes to retry for in my configs. It has a min retry time, a max retry time, and a number of retries to attempt. It scales exponentially until it hits the max time, then continues to use the max time until the max number of retries is hit.

ghost avatar Jul 07 '19 06:07 ghost

The performance point is really interesting, thanks to bringing that up to my attention, I'll check this out.

For console users, yes, I know, that's suboptimal, but I feel for Bungie API. If even the inactive user start polling then every 15s, that's hell. One thing I was thinking about to mitigate the problem is that in all case, PC or console, you can stomp on your keyboard (i.e. press any key) and it will trigger a refresh right away.

On Sun., Jul. 7, 2019, 2:15 a.m. Akumati, [email protected] wrote:

I originally made this with ps-list, but after seeing how abysmal the performance was i switched off it. If you benchmark that vs the method I copy/pasted off stackoverflow, you'll notice a massive difference. I've heard ps-list takes up a lot of ram too for unknown reasons.

If you have the program poll once an hour towards the end of it for console peasants, won't that mean up to an hour of the script not showing the discord integration? It seems like you can safely clear the game activity after some time, but you should still be monitoring the API for new activity at the same interval.

Also, not sure if you have error handling for when bungie throws up, but it throws up a lot. For my stuff I keep a list of error codes to retry for in my configs. It has a min retry time, a max retry time, and a number of retries to attempt. It scales exponentially until it hits the max time, then continues to use the max time until the max number of retries is hit.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brakacai/discord-ghost/pull/49?email_source=notifications&email_token=AC6LESW3CPYBKUVFPHUZFQLP6GCXPA5CNFSM4H6EIZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLFK6Y#issuecomment-508974459, or mute the thread https://github.com/notifications/unsubscribe-auth/AC6LESWANOKXFFW35VY2B2LP6GCXPANCNFSM4H6EIZPQ .

louis-bompart avatar Jul 07 '19 08:07 louis-bompart

For the retries, Darkscared is working on logs, which will by essence include try catches. What we aim to do certainly is that if it fail during an interval execution, just keep going, we will try next time.

On Sun., Jul. 7, 2019, 4:35 a.m. Louis Bompart, < [email protected]> wrote:

The performance point is really interesting, thanks to bringing that up to my attention, I'll check this out.

For console users, yes, I know, that's suboptimal, but I feel for Bungie API. If even the inactive user start polling then every 15s, that's hell. One thing I was thinking about to mitigate the problem is that in all case, PC or console, you can stomp on your keyboard (i.e. press any key) and it will trigger a refresh right away.

On Sun., Jul. 7, 2019, 2:15 a.m. Akumati, [email protected] wrote:

I originally made this with ps-list, but after seeing how abysmal the performance was i switched off it. If you benchmark that vs the method I copy/pasted off stackoverflow, you'll notice a massive difference. I've heard ps-list takes up a lot of ram too for unknown reasons.

If you have the program poll once an hour towards the end of it for console peasants, won't that mean up to an hour of the script not showing the discord integration? It seems like you can safely clear the game activity after some time, but you should still be monitoring the API for new activity at the same interval.

Also, not sure if you have error handling for when bungie throws up, but it throws up a lot. For my stuff I keep a list of error codes to retry for in my configs. It has a min retry time, a max retry time, and a number of retries to attempt. It scales exponentially until it hits the max time, then continues to use the max time until the max number of retries is hit.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brakacai/discord-ghost/pull/49?email_source=notifications&email_token=AC6LESW3CPYBKUVFPHUZFQLP6GCXPA5CNFSM4H6EIZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLFK6Y#issuecomment-508974459, or mute the thread https://github.com/notifications/unsubscribe-auth/AC6LESWANOKXFFW35VY2B2LP6GCXPANCNFSM4H6EIZPQ .

louis-bompart avatar Jul 07 '19 08:07 louis-bompart

The API can handle it. Just know the error codes that tell you to back off and you're fine.

To put that into perspective... I've got 10 threads pulling character data for my clan and another 8 for activity data. These jobs sometimes even overlap and I don't have issues. The website I run uses the same VM and that hits the API too. Because I have so many clans, the only way to get some of the webpages to load in a reasonable amount of time is to thread the crap out of them.

I'm slamming the API and I don't have problems. 1 call every 15 seconds is nothing.

ghost avatar Jul 07 '19 16:07 ghost

I wouldn't be worried if one person was polling every 15sec. I'm way more concerned due to the alarming number of people that have reacted on Reddit and the analytics of the GitHub.

It'd be like that we reach 100query per second or even more with the current user base.

Keep in mind that due to privacy issue, the API key requirements will soon be removed because we're gonna use one API Key and OAuth.

However, you're right that I might be underestimating the capacity of Bungie's API. Instead of 2hrs, we will refresh every minutes, and go from there.

What do you think of that?

We would keep the autoshut off tho. On Sun., Jul. 7, 2019, 12:22 p.m. Akumati, [email protected] wrote:

The API can handle it. Just know the error codes that tell you to back off and you're fine.

To put that into perspective... I've got 10 threads pulling character data for my clan and another 8 for activity data. These jobs sometimes even overlap and I don't have issues. The website I run uses the same VM and that hits the API too. Because I have so many clans, the only way to get some of the webpages to load in a reasonable amount of time is to thread the crap out of them.

I'm slamming the API and I don't have problems. 1 call every 15 seconds is nothing.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/brakacai/discord-ghost/pull/49?email_source=notifications&email_token=AC6LESR3XVX27XF3EONUZOTP6IJ4RA5CNFSM4H6EIZP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZLOV5I#issuecomment-509012725, or mute the thread https://github.com/notifications/unsubscribe-auth/AC6LESSPEE7DJLM532XBHUDP6IJ4RANCNFSM4H6EIZPQ .

louis-bompart avatar Jul 07 '19 17:07 louis-bompart

Every minute seems good. I dont think anyone would complain about it not showing their status correctly for a minute. Heck it might even help because until the user gets to orbit the information is wrong.

If you switch to running the script as a service, the auto shut off might interfere with things.

ghost avatar Jul 09 '19 21:07 ghost