Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zenless Zone Zero Login returns error #52

Open
rounak-codes opened this issue Oct 10, 2024 · 34 comments · May be fixed by #55
Open

Zenless Zone Zero Login returns error #52

rounak-codes opened this issue Oct 10, 2024 · 34 comments · May be fixed by #55

Comments

@rounak-codes
Copy link

After attempting to login or run the script , ZZZ login returns the following message in discord via webhook and login does not reflect in the login webpage. All other games' login is working as intended.

  • 活动已结束 (-500012)
@Shomen-ai
Copy link

The same goes for me. I'm running a script for two accounts, and get 活动已结束 (-500012) on first account and 操作频繁,请稍后再试 on second account.

@Chillrend
Copy link
Contributor

+1 they probably changed the endpoint, i'll try looking at it

@Chillrend
Copy link
Contributor

After a quick network inspect, the endpoint indeed changed to https://sg-public-api.hoyolab.com/event/luna/zzz/os/sign it also have a new header "x-rpc-signgame": "zzz"

@Shomen-ai
Copy link

So, it's necessary to declare and use special header for zzz?

@Chillrend
Copy link
Contributor

Haven't tried through the script yet, but this is from network inspect when i clicked the sign button in hoyolab:
image

Also the header specific to ZZZ:
image

@WiLuX-Source
Copy link

WiLuX-Source commented Oct 11, 2024

First of all big shoutout to @rounak-codes for opening this issue and @Chillrend for all the extra details for solving the problem.

The code now requires a specific set of headers for ZZZ and here's how you need to do your requests before I PR.

Change your check out url for ZZZ to https://sg-public-api.hoyolab.com/event/luna/zzz/os/sign?lang=en-us&act_id=e202406031448091
and add one more header when making your request:
"x-rpc-signgame": "zzz",

image

This will break other games but ZZZ will work again.
I'm currently on it making custom headers for every game just in case it breaks again.

@WiLuX-Source WiLuX-Source linked a pull request Oct 11, 2024 that will close this issue
@WiLuX-Source
Copy link

I would appreciate testing of my PR
The Discord chinese version and both telegram versions needs testing waiting for feedback!

@Chillrend
Copy link
Contributor

Thanks @WiLuX-Source, I will try your PR on my script asap.

@ChyrkunArtsiom
Copy link

ChyrkunArtsiom commented Oct 12, 2024

Same thing started for HSR 活动已结束 (-500012) yesterday. For it header's value is hkrpg and request is https://sg-public-api.hoyolab.com/event/luna/hkrpg/os/sign.

@WiLuX-Source
Copy link

HSR worked fine for me just 1 hour ago.

@WiLuX-Source
Copy link

HSR still works fine.

@ChyrkunArtsiom
Copy link

Hm, maybe they are rolling those changes in order for specific regions / accounts. Anyway I just copied your pr and updated for myself.

@WiLuX-Source
Copy link

I created that PR to be able to change headers fast without going in too much detail. Glad it helped you.

@cptmacp
Copy link

cptmacp commented Oct 12, 2024

Updated code to handle game-specific headers


const profiles = [
    {
        token: "ltoken_v2=gBxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxCY; ltuid_v2=26XXXXX20;",
	genshin: true,
        honkai_star_rail: false,
        honkai_3: false,
        zzz: false,
        accountName: "test"
    }

];

const telegram_notify = true
const myTelegramID = "1XXXXXXX0"
const telegramBotToken = ""

/** The above is the config. Please refer to the instructions on https://github.com/canaria3406/hoyolab-auto-sign/ for configuration. **/
/** The following is the script code. Please DO NOT modify. **/

const urlDict = {
    Genshin: 'https://sg-hk4e-api.hoyolab.com/event/sol/sign?lang=en-us&act_id=e202102251931481',
    Star_Rail: 'https://sg-public-api.hoyolab.com/event/luna/os/sign?lang=en-us&act_id=e202303301540311',
    Honkai_3: 'https://sg-public-api.hoyolab.com/event/mani/sign?lang=en-us&act_id=e202110291205111',
    //Zzz-old: 'https://sg-act-nap-api.hoyolab.com/event/luna/zzz/os/sign?lang=us-id&act_id=e202406031448091',
    Zzz: 'https://sg-public-api.hoyolab.com/event/luna/zzz/os/sign?lang=en-us&act_id=e202406031448091'
};

async function main() {
    const messages = await Promise.all(profiles.map(autoSignFunction));
    const hoyolabResp = `${messages.join('\n\n')}`

    if (telegram_notify && telegramBotToken && myTelegramID) {
        postWebhook(hoyolabResp);
    }
}

function autoSignFunction({ token, genshin, honkai_star_rail, honkai_3, zzz, accountName }) {
    const urls = [];

    if (genshin) urls.push(urlDict.Genshin);
    if (honkai_star_rail) urls.push(urlDict.Star_Rail);
    if (honkai_3) urls.push(urlDict.Honkai_3);
    if (zzz) urls.push(urlDict.Zzz);

    const header = {
        Cookie: token,
        'Accept': 'application/json, text/plain, */*',
        'Accept-Encoding': 'gzip, deflate, br',
        'Connection': 'keep-alive',
        'x-rpc-app_version': '2.34.1',
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36',
        'x-rpc-client_type': '4',
        'Referer': 'https://act.hoyolab.com/',
        'Origin': 'https://act.hoyolab.com'
    };

    // Add game-specific headers
    // in future add game specific headers if needed
    if (honkai_star_rail) header['x-rpc-signgame'] = 'hkrpg';
    if (zzz) header['x-rpc-signgame'] = 'zzz';

    const options = {
        method: 'POST',
        headers: header,
        muteHttpExceptions: true,
    };

    let response = `Check-in completed for ${accountName}`;

    const httpResponses = UrlFetchApp.fetchAll(urls.map(url => ({ url, ...options })));

    for (const [i, hoyolabResponse] of httpResponses.entries()) {
        const responseJson = JSON.parse(hoyolabResponse);
        const checkInResult = responseJson.message;
        const gameName = Object.keys(urlDict).find(key => urlDict[key] === urls[i])?.replace(/_/g, ' ');
        const bannedCheck = responseJson.data?.gt_result?.is_risk;

        if (bannedCheck) {
            response += `\n${gameName}: Auto check-in failed due to CAPTCHA blocking.`;
        } else {
            response += `\n${gameName}: ${checkInResult}`;
        }
    }

    return response;
}

function postWebhook(data) {
    let payload = JSON.stringify({
        'chat_id': myTelegramID,
        'text': data,
        'parse_mode': 'HTML'
    });

    const options = {
        method: 'POST',
        contentType: 'application/json',
        payload: payload,
        muteHttpExceptions: true
    };

    UrlFetchApp.fetch('https://api.telegram.org/bot' + telegramBotToken + '/sendMessage', options);
}


just add

    // Add game-specific header
    // in future add game specific headers if needed
    if (honkai_star_rail) header['x-rpc-signgame'] = 'hkrpg';
    if (zzz) header['x-rpc-signgame'] = 'zzz';

before const options to add extra headers in header json

image

@cptmacp
Copy link

cptmacp commented Oct 12, 2024

@WiLuX-Source
#55

Yours approach is fine but
since only a few things have to be added in the REST call's header and most of the part is common
we need not to define duplicated stuff , where we can just append stuff in header's json before passing it to 'options'

@WiLuX-Source
Copy link

@cptmacp I prefer my option better since someone who's using this project might not know coding and you can just tell them to append the header. Currently I have no issues checking out. If I have I'll just add a simple 1 line change and I am done.

@WiLuX-Source
Copy link

Also your approach might not work if users checks out at the same time when using both star rail and zzz correct me If I am wrong.

@ChyrkunArtsiom
Copy link

Also your approach might not work if users checks out at the same time when using both star rail and zzz correct me If I am wrong.

You are right, only the last truthy case will work. The best way either to convert urlDict into objects and use switch or use Map. Too much work refactoring one simple script for no reason tho.

@WiLuX-Source
Copy link

Update HSR still works fine. At least in my region(Europe)
You can always update the header in headerDict.
I think we are fine for a while now. I don't think author of this project is active and will not get merged probably.

@rounak-codes
Copy link
Author

Can confirm HSR still works fine in my region as well (ASIA) , Thanks to @WiLuX-Source , @cptmacp and @Chillrend for the fix.

@rounak-codes
Copy link
Author

I am keeping this as open in case someone needs guidance in the future or endpoints are changed. Also , since canaria is MIA , without the merge , new users are bound to run into this issue.

@WiLuX-Source
Copy link

@rounak-codes please accept my pr. It only needs 1 review to be merged.

@duronald
Copy link

If @canaria3406 is inactive we should probably fork the repo and upstream everything into the forked repo.

@ud4yk
Copy link

ud4yk commented Oct 14, 2024

No coder here, but pretty much tried to follow the thread to letter, HSR gets broken (europe) , tried to add luna/"hkrpg"/os/ (without quotes) in the url too as i thought it might be a troubleshoot. I'm using the discord version of the script if that makes a difference. Can't have both, either hsr gets broken or ZZZ.
image

I followed this instruction #52 (comment) , heck even redid the script copy paste (the bottom most discord ping) omitting the telegram stuff with discord from the original

@Chillrend
Copy link
Contributor

I followed this instruction #52 (comment) , heck even redid the script copy paste (the bottom most discord ping) omitting the telegram stuff with discord from the original

Try #55
https://github.com/canaria3406/hoyolab-auto-sign/blob/5b60da5ac130b7bc8e7dcf155f3e3b8719e02e4a/src/main-discord.gs

@ud4yk
Copy link

ud4yk commented Oct 15, 2024

I followed this instruction #52 (comment) , heck even redid the script copy paste (the bottom most discord ping) omitting the telegram stuff with discord from the original

Try #55 https://github.com/canaria3406/hoyolab-auto-sign/blob/5b60da5ac130b7bc8e7dcf155f3e3b8719e02e4a/src/main-discord.gs

worked! atleast once with manual execution, lets see if it'll hold up! Couldn't figure out those headers on my own :)

@hanthienhai
Copy link

Try code from cptmacp, it's worked with ZZZ but not work with HSR
Star Rail: 活动已结束 (-500012)

@WiLuX-Source
Copy link

WiLuX-Source commented Oct 15, 2024

Try code from cptmacp, it's worked with ZZZ but not work with HSR Star Rail: 活动已结束 (-500012)

This is what happens when you don't refactor the code and use a simple if statement when the change is needed.
Try the code in #55 and add the header if necessary.

@cptmacp
Copy link

cptmacp commented Oct 15, 2024

Try code from cptmacp, it's worked with ZZZ but not work with HSR Star Rail: 活动已结束 (-500012)

As #52 (comment) commented

HSR was needed 'x-rpc-signgame' as 'hkrpg' and it was working in some regions
so I added it in the header

You can comment it out and check

image

@rairulyle
Copy link

rairulyle commented Oct 21, 2024

Hey guys! Just in case you are interested or when OP stop maintaining the script, I am actively maintaining this and adding new features such as pinging each discord users and pretty output (it also goes red when there's an error).

I am also fixing issues encountered ASAP. But I need help maintain the other languages and telegram scripts.

https://github.com/rairulyle/hoyolab-auto-sign
image

@WiLuX-Source
Copy link

No one should ever share their hoyolab token with another person. I hope they are close friend of yours.
Embeds can't be indexed by discord even though they look pretty.
I don't like where this issue is going. Please keep it away from another advertisement as such. If you want your project to be used just keep your fork up to date so it can appear to the others.

@rairulyle
Copy link

Yep. They're all my friends. It's just that some people started forking mine so I did share it.

No one should ever share their hoyolab token with another person. I hope they are close friend of yours. Embeds can't be indexed by discord even though they look pretty. I don't like where this issue is going. Please keep it away from another advertisement as such. If you want your project to be used just keep your fork up to date so it can appear to the others.

@WiLuX-Source
Copy link

Nice promotion both of you.

@rounak-codes
Copy link
Author

Do not use this thread for promotion. If you have any issues , ask about it , if you have a better code , mention the code and initiate a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

11 participants