canaria3406 / hoyolab-auto-sign

A lightweight, secure, and free script that automatically collect Hoyolab daily check in rewards. Supports Genshin Impact, Honkai Impact 3rd, and Honkai: Star Rail.
MIT License
332 stars 40 forks source link

Support for multiple hoyolab accounts + a more readable discord/telegram output message #4

Closed cd36th closed 1 year ago

cd36th commented 1 year ago

Created a profiles array containing the token, game booleans and accountName (previously myDiscordName). This allows for multiple hoyolab accounts to be included in the one code, that don't all have to play the same games for the check-ins to work. The main() function loops through the profiles listed.

I have also created urlDict to contain the sign-in URLs. This makes it easier to replace the links if they ever change for whatever reason. I have also used this in autoSignFunction() to create a dynamic array of URLs for the games that should be checked-in for each profile so that the "if (game == true)" statements don't need to be repeated.

Then I created a more structured output message, creating sentences based around accountName, and the check in message for each game being formatted by "gameName: hoyolabResponse" so that the end user can see exactly what happened in the check-in.

Note that as I don't speak Chinese, I wasn't able to translate Check-in completed for ${accountName}, and just left it as ${accountName} in the Chinese versions. Also note that as I don't use Telegram I was unable to test the changes myself, however as I didn't change anything with postWebhook() it should work the same as Discord, which I was able to test both languages for successfully.