torikushiii / hoyolab-auto

Auto check-in and others for any Hoyoverse games
https://ko-fi.com/torikushiii
GNU Affero General Public License v3.0
75 stars 17 forks source link

[Question] Commands - how to use them? #19

Closed YozenPL closed 2 months ago

YozenPL commented 2 months ago

In issue #16 you have mentioned "commands". I believe we have 4 of them:

How to use them?

torikushiii commented 2 months ago

It's a Discord bot feature only, so if you have a discord bot set up you can just start using them like this -notes genshin or starrail or zzz to see your in-game status that will looks like this

using -notes starrail

image

using -notes zzz

image

-stamina genshin will display your current genshin stamina -expedition starrail will display your current expedition status at Star Rail -redeem zzz [code] is just a manual way to redeem codes

YozenPL commented 2 months ago

Thank you for explanation. I have one more question but it is not related co commands. Should I ask it here or open new "issue" for it?

torikushiii commented 2 months ago

feel free to ask it here

YozenPL commented 2 months ago

How often the data/cache.json is updated? What is the logic here? I wanted to use the data from this file for my external display, but it seems it is not refreshing when cron job is executed.

torikushiii commented 2 months ago

The cache is stored for 1 hour and will fetch real-time data from Hoyoverse after it expires. During that hour, the cached note data will be internally processed, similar to how Hoyoverse processes stamina and expedition timers, as seen here:

https://github.com/torikushiii/hoyolab-auto/blob/21c298f99d9d3f8a0038454a87e21d95386c0bd2/hoyolab-modules/template.js#L42-L86

The cached data updates every time the notes function is called. For example, if this cron runs every 30 minutes:

https://github.com/torikushiii/hoyolab-auto/blob/21c298f99d9d3f8a0038454a87e21d95386c0bd2/crons/stamina/index.js#L1-L3

then the cached data will be updated 30 minutes later.

If you have any further questions about this, feel free to ask.

YozenPL commented 2 months ago

Hmm my cache.json file is refreshed every 1h and 30mins. After 2 executions of stamina cron the file was still not refreshed. The 3rd one created new cache. But still, for me only the Resin from Genshin was refreshed. Battery from ZZZ and Realm currency from GI are still at the same count as it was 1,5h earlier.

I believe I need to search how to fetch Resin, Battery and Realm currency data in some other way.

torikushiii commented 2 months ago

Oh yeah, my apologies

I totally forgot to add a function to update GI realm currency internally, and for ZZZ battery it should be auto updated every notes call, but ill take a look. Thanks for letting me know.

Forgot to mention, but if you have persistent set to false on any stamina value, the notes will not be updated until your stamina is below the set threshold

torikushiii commented 2 months ago

~After checking around, it seems ZZZ battery is correctly being updated if the stamina cron is called~

I just found out that the note calls does not store into cache file after updated rather it stored at class instead. I should be able to fix this

djdoolky76 commented 2 months ago

It's a Discord bot feature only, so if you have a discord bot set up you can just start using them like this -notes genshin or starrail or zzz to see your in-game status that will looks like this

using -notes starrail

image

using -notes zzz

image

-stamina genshin will display your current genshin stamina -expedition starrail will display your current expedition status at Star Rail -redeem zzz [code] is just a manual way to redeem codes

it's good if you add -help command in the discord bot that tells what available commands to execute like this

-stamina genshin will display your current genshin stamina -expedition starrail will display your current expedition status at Star Rail -redeem zzz [code] is just a manual way to redeem codes

torikushiii commented 2 months ago

it's good if you add -help command in the discord bot that tells what available commands to execute like this

-stamina genshin will display your current genshin stamina -expedition starrail will display your current expedition status at Star Rail -redeem zzz [code] is just a manual way to redeem codes

I will take your suggestion and will implement it for next commit

djdoolky76 commented 2 months ago

it's good if you add -help command in the discord bot that tells what available commands to execute like this -stamina genshin will display your current genshin stamina -expedition starrail will display your current expedition status at Star Rail -redeem zzz [code] is just a manual way to redeem codes

I will take your suggestion and will implement it for next commit

I'm looking forward to that but no need to rush anyway 🫡

torikushiii commented 2 months ago

~After checking around, it seems ZZZ battery is correctly being updated if the stamina cron is called~

I just found out that the note calls does not store into cache file after updated rather it stored at class instead. I should be able to fix this

@YozenPL I've pushed a new commit to potentially fix this https://github.com/torikushiii/hoyolab-auto/commit/5ec145c4cffd99dbcf3e49b9fe8da2e17d13d923 will you try to test it and let me know if it still have a problem

YozenPL commented 2 months ago

~After checking around, it seems ZZZ battery is correctly being updated if the stamina cron is called~ I just found out that the note calls does not store into cache file after updated rather it stored at class instead. I should be able to fix this

@YozenPL I've pushed a new commit to potentially fix this 5ec145c will you try to test it and let me know if it still have a problem

Amazing! I can see the data. Thanks :)