GithubHelp home page GithubHelp logo

torikushiii / starrail-auto Goto Github PK

View Code? Open in Web Editor NEW
102.0 3.0 24.0 281 KB

Auto check-in and others for Honkai: Star Rail

Home Page: https://ko-fi.com/torikushiii

License: GNU Affero General Public License v3.0

JavaScript 98.60% Dockerfile 0.22% Makefile 1.19%
honkai-star-rail honkai-starrail nodejs star-rail starrail google-script discord-webhook telegram

starrail-auto's Introduction

torikushiii 🔭

Hi there 👋

⚡ A person who is passionate about technologies, open-source, reverse engineering, convenience, etc.

  • en-US / jp-JP
  • Programmer / Developer
  • Likes to collect stuff

🌱 Programming Languages

HTML5 Astro JavaScript Java Node.js Python PHP Go

💰 Buy me a Coffee

✨ If you like my projects, you can buy me a coffee at:

💻 Working Environment

Windows 11 Pro Workstation 22H2 Windows Server 2022 Datacenter 21H2 Ubuntu 22.04.1 Android 14 Upside Down Cake iOS 17.2.1

👯 Some of my projects:

starrail-auto's People

Contributors

esmeray6 avatar justarion avatar storm-legacy avatar torikushiii avatar wijayaerick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

starrail-auto's Issues

StarRailError: Account 1 is invalid.

"request":{"statusCode":200,"body":{"data":null,"message":"Please login","retcode":10001}}}
I've try to logout and login again but nothing have change. What should i do?

image
image
image

Telegram notification for expedition and commands

I noticed that with the values: staminaCheck: true, enabled: true, skipCheck: false - notifications about completed expeditions are not sent to telegram, but if I change skipCheck: true, then notifications start coming, but this is not exactly what I would like.

Also, telegram commands for manually requesting the status of expeditions/stamina do not work for me. I thought that maybe the problem is in the language of the requested site in cookies, but by changing mi18nLang: en-us nothing has changed

I can't attach any logs because there aren't any (or I don't know where the output is going). If you have time, then consider running the script in debug mode or something similar so that the user can see for himself what happens in case of errors, as well as provide you with more detailed information. Maybe there is some kind of startup key in nodejs, but I do not know.

Anyway, thanks a lot for your work, your script is very useful even when I run into any problems.

Auto redeem code doesn't work for the newest code

Boothill banner dropped yesterday and we have a new code: FA2CU3P7P6QT
My scritp still running and it doesnt redeem new code, is there something changed? It was working fine for me in the last few month.

webhook still send stamina info even when check stamiona is set to false

at title said, i did not notice that i set the setting to false so when the check stamina notification start anoying me i go into config.json to switch it to false to only found out its already false, also it double send the stamina notification,
Image 406
Image 405

(unrelated to title, is there a way to change the time for check in from 12 am to 4 am?)

Auto code redeem issue

Newest code doesn't seems to for me, 6T3F5HVD6LK7. 19/Jun.
The code from 07/Jun worked just fine.

Edit: Auto redeem worked for me again after making this issue.

docker some problem about code-redeem

I re-pulled the code and ran it using Docker as instructed. I found that if code.js is missing, check-code-redeem will not run or execute. If code.js is present, it runs and helps redeem the code, but it does not write to code.js and there is no notification

fresh install error,

i decided to do a fresh install as i sometime forgot to update but i found an error than new user may or may not get.
the only thing that change is the config.json (same as the old version)
Image 482

API error

out of 4 accounts, only one works as of right now. I tried regenerating tokens by logging out and logging in an incognito tab, but I receive the same error:
2024-05-30 12:28:14 [INFO]: { message: 'API error when getting stamina info', args: { statusCode: 200, body: { data: null, message: '', retcode: 10035 } } }
any clue will be of great help

API error when getting stamina info

I have a server on archlinux, on which the script runs without problems. When migrating config.json to another machine, for example, on wsl2 (ubuntu and arch) or Docker on another hardware, an API error occurs. Both computers have Node v21.6.2 installed.
Here's what the script writes when trying to get data on new computer with wsl2 archlinux:

{
  message: 'API error when getting stamina info',
  args: {
    statusCode: 200,
    body: { data: null, message: 'invalid request', retcode: -10001 }
  }
}

image
image

Here's what the script writes on the old computer without errors

image
image

It would seem that the problem is with cookies, but my friend sent me a token that was made on a completely different hardware in a completely different place, and it works.

Syntax for scheduler

What exactly is the Syntax for the scheduler? From the example I only managed to figure out:

? | hours/minutes | ? | ? | day of week starting at Sunday | ?

Expedition Discord notification has same problem

Adding the missing 'prepareMessage' function similar to 'stamina' will allow the program to run properly

for (const data of expeditionResult) {
const embed = await
sr.Discord.prepareMessage(data, { expedition: true });
await sr.Discord.send(embed);
}

Discord notification for stamina are not sending?

I tested and it seems the daily claims are made at 12:00 am every day (a notification to my discord is sent via web-hooks)

but the stamina one does not seem to send anything>? I see the logs and the cron-job does trigger but I am unable to see any discord notification? even though I set the stamina threshold to a number lower than my current stamina:

example:

Stamina for UID 6XXXXXXXX is above the threshold (137/180) - Capped in 4 hr, 16 min, 57 sec

the threshold does trigger but no notification is sent?

Codes Not Redeeming/ Daily Reminders not sending

Hello, I noticed that codes don't seem to be redeeming for me and reminders to do my dailies don't pop up.

Everything else seems to be functional however (Stamina Threshold/Check In)/Expeditions Reminders)

I have code redemption and check code set to true so i am unsure if I have an issue or something else

Please advise thank you!

Path issue for commands

Commands are unable to be imported on Windows due to a suppressed error. The following error is suppressed in index.js:

Only URLs with a scheme in: file and data are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:

This occurs on Windows 11, Node.js v18.16.1.

image

cant find ltuid to use as account_id

I used to be able to have ltuid in my cookie and my other friends also had it but mine doesnt.

image

I tried ltuid_v2 as well but it doesn't work, got any ideas?

running index.js

So I tried to get this to run for a while and it just doesn't seem to really do anything?
All I get when running node index.js is
PS C:\Users\Anwender\Documents\starrail-auto-master> node index.js
2023-06-08 23:33:44 [INFO]: Starting cronjobs...
2023-06-08 23:33:44 [INFO]: All cronjobs started successfully!

...and nothing else happens, I set up the config with my cookie and discord webhook url as well to see if the notifs were working

anything I'm missing here?

Github Actions workflow integration

First of all, thank you for implementing this automation.
I've been running this for a few months with github action workflow setup.

It'd be nice to have Github Actions integration; people will be able setup their automation by following steps:

  1. Fork repo
  2. Set secrets in the settings
  3. Enable github action workflow

This will be applicable only with --sign flag because the workflow only runs short process.

I'm willing to work on this if it's ok for you.

[Suggestion] Multiple accounts?

There used to be a Genshin Daily Check-in script that had the ability to work with several cookies, separated by commas. I wonder if you'll be able to add the same functionality to this script as well? Thank you for your work!

Can't run index.js

Got this error:
PS E:\starrail-auto-master> node index.js
file:///E:/starrail-auto-master/config.js:18
DISCORD_WEBHOOK: discord.com/api/webhooks/1134598997089210368/roB9lo4X-2VQ82ntHBo-SUl-vg9VhBFKwkZwjZO7a3xDF32snCjbePahKIeiMzF2mHTg, // Discord webhook URL
^

SyntaxError: Invalid or unexpected token
at ESMLoader.moduleStrategy (node:internal/modules/esm/translators:119:18)
at ESMLoader.moduleProvider (node:internal/modules/esm/loader:468:14)

Node.js v18.12.1

Sreenshot:
image

No cookie_token

hello. i'm using Google Apps Script, as i only need the auto check in function, and I've noticed that the text says that the cookie should look like this in the end:
_MHYUUID=xxxx ; mi18nLang=en-us ; ltoken=xxxx ; ltuid=xxxx ; cookie_token=xxxx ; account_id=xxxx

however, there is no cookie_token anywhere in the result i get with document.cookie.
Here's what i get when i type document.cookie in the console (obviously i'm changing values into XXXX):

G_AUTHUSER_H=X; _MHYUUID=XXXX; DEVICEFP_SEED_ID=XXXX; DEVICEFP_SEED_TIME=XXXX; G_ENABLED_IDPS=google; mi18nLang=en-us; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT={XXXX:[]}; account_mid_v2=XXXX; account_id_v2=XXXX; ltmid_v2=XXXX; ltuid_v2=XXXX; DEVICEFP=XXXX; mi18nLang=en-us; HYV_LOGIN_PLATFORM_TRACKING_MAP={XXXX:{XXXX}}; HYV_LOGIN_PLATFORM_LIFECYCLE_ID={XXXX}

no cookie_token anywhere. so i have no idea what i have to put there exactly.

i'm using google chrome, latest version, but i've tried on firefox too and there's even less stuff there... i'm lost. it tells me [Error: Info API error: Not logged in] if i try to run it. nothing i've tried works. what am i supposed to do?
i'm a EU player btw, if it's useful.

i've also tried pasting the cookie exactly as it is and running but it still says the same thing. i am logged in on hoyoverse.

Api error on Stamina

So I followed all instructions, set the stamina threshold = 10 to test.

I run the script and the daily logging works but the stamina notification doesn't seem to work, nothing is sent, I tested the webhook link before and it was working.

is there any way I can test or am I missing something?

edit: I found out I had to use node index.js --stamina to run stamina script, but it gave me this error:

CustomError: API error when getting stamina info
- args: {"statusCode":200,"body":{"data":null,"message":"角色信息错误","retcode":1009}}...

maybe because I am not on the Asia server?

edit2: I figured out by looking at the code: the notification only triggers when it's run by cron. My only issue is the stamina API error.

final edit: After some googling I found out that the api is using a asia server, I only needed to change the server parameters to: server: "prod_official_usa". this solved the issue :)

Can't start index.js

Hello i follow all instruction in the config.js but don't work when i launch command: node index.js

I copied Cookie using Microsoft Edge and pasted into config.js but when i do node index.js give me this error:

node:internal/modules/esm/resolve:255
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\SR Auto\starrail-auto\config.js' imported from D:\SR Auto\starrail-auto\core\classes\config.js
    at finalizeResolution (node:internal/modules/esm/resolve:255:11)
    at moduleResolve (node:internal/modules/esm/resolve:908:10)
    at defaultResolve (node:internal/modules/esm/resolve:1121:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///D:/SR%20Auto/starrail-auto/config.js'
}

Node.js v20.10.0

How i can resolve this problem?

There is no config.js (other than under the classes directory) file only config.json. ReadMe is hard to grasp at first because of it

So I ran into the Issue that I at first couldn't find the config.js because it either no longer exists or its a typo in the readme.
I was also confused by this wording:

Copy name and value (ltoken_v2 and ltuid_v2) and put it in your config.js file like this format name=value;

  • Remember to put "; (semicolon)" at every the end of value, e.g ltoken_v2=abc; ltuid_v2=123

Since it tells me (a developer maybe it's literally just a me being developer issue) to create 2 new variables in the config.js file so something like this:

ltuid_v2 = 123;
ltoken_v2= "abc"

But since it is now under the config.json in the accounts object array in the cookie string I would change the wording to something like this:

Copy name and value (ltoken_v2 and ltuid_v2) and put it in your config.json file under the accounts list into the cookie with the format being name=value
If done correctly it should look similar to this:

  • cookie: "ltuid_v2=123;ltoken_v2=abc"
  • Remember to put "; (semicolon)" at every the end of value, e.g ltoken_v2=abc; ltuid_v2=123

Doubt regarding setting up environmental variables in Google Script

Hello,
I'm using the google script version of this script. I have a question. I heard that cookies data shouldn't be shared with anyone as anyone with my cookie can login into my hoyolab account.

How can we set up environmental variables in google script? Or there is nothing to worry about as my project in google script is private and no one can view my secret values. I have never used Google Script before that's why I am really confused.

Waiting for your response and thankyou.

no account_id in cookie

I copied the output from the console and pasted it in the cookies property but when I run it shows this

2023-08-12 13:22:19 [WARN]: Account 1 has no account_id in cookie. Skipping fetching account data...

TypeError: Cannot read properties of undefined (reading 'name') and API error when signing Error

The complete error code is here

2023-12-31 00:00:00 TypeError: Cannot read properties of undefined (reading 'name')
2023-12-31 00:00:00 at Cron.checkInChecker (file:///usr/src/app/crons/check-in-checker/index.mjs:22:31)
2023-12-31 00:00:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

2024-01-02 00:00:01 message: 'API error when signing',
2024-01-02 00:00:01 args: {
2024-01-02 00:00:01 statusCode: 200,
2024-01-02 00:00:01 body: {
2024-01-02 00:00:01 data: null,
2024-01-02 00:00:01 message: 'Too many attempts. Please try again later.',
2024-01-02 00:00:01 retcode: -500004
2024-01-02 00:00:01 }
2024-01-02 00:00:01 }
2024-01-02 00:00:01 }

Error after adding add checkInChecker

Account is invalid.

I got this error message when try to run
I put the right cookie from hoyolab, but the console alway return please login
`file:///E:/CodeSpace/starrail-auto/core/classes/account.js:94
throw new sr.Error({
^

CustomError: Account 1 is invalid.

  • args: {"account":{"uid":"325711401"},"request":{"statusCode":200,"body":{"data":null,"message":"Please login","retcode":10001}}}
    at Account.validate (file:///E:/CodeSpace/starrail-auto/core/classes/account.js:94:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Account.loadData (file:///E:/CodeSpace/starrail-auto/core/classes/account.js:35:3)
    at async Account.initialize (file:///E:/CodeSpace/starrail-auto/core/classes/account.js:29:3)
    at async default (file:///E:/CodeSpace/starrail-auto/core/index.js:49:15)
    at async file:///E:/CodeSpace/starrail-auto/index.js:10:18 {
    [cause]: undefined
    }

Node.js v20.10.0`
Thank for care and pls help

Discord notification Error

After using the new Discord.js code, I encountered the following error

2023-12-28 11:11:00 RequestError: Response code 400 (Bad Request)
2023-12-28 11:11:00 - args: {"statusCode":400,"statusMessage":"Bad Request","hostname":"discord.com"}
2023-12-28 11:11:00 at Request._destroy (file:///usr/src/app/node_modules/got/dist/source/core/index.js:482:21)
2023-12-28 11:11:00 at _destroy (node:internal/streams/destroy:109:10)
2023-12-28 11:11:00 at Request.destroy (node:internal/streams/destroy:71:5)
2023-12-28 11:11:00 at Request._error (file:///usr/src/app/node_modules/got/dist/source/core/index.js:1012:14)
2023-12-28 11:11:00 at gotModule.extend.hooks.beforeError (file:///usr/src/app/lib/got.js:18:11)
2023-12-28 11:11:00 at Request._error (file:///usr/src/app/node_modules/got/dist/source/core/index.js:1005:35)
2023-12-28 11:11:00 at file:///usr/src/app/node_modules/got/dist/source/core/index.js:402:23
2023-12-28 11:11:00 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
2023-12-28 11:11:00 input: undefined,
2023-12-28 11:11:00 code: 'ERR_GOT_REQUEST_ERROR',

I can run the bot without issues using the old code, but after switching to the new Discord.js code, I encounter errors. I'm having trouble pinpointing the issue. Can you help me? I'm launching it using Docker

Not able to log in

I followed all the steps and assumed there was nothing wrong with the process, but somehow I could not log in with the cookie.

message: 'API error when getting sign info',
  args: {
    statusCode: 200,
    body: { data: null, message: 'Not logged in', retcode: -100 }
  }

Do you have any idea of how this could go wrong? The cookie should be right, I even tried to logout and login again.

Request error: Error when getting stamina info

instead of stopping the script when there is a connection error, why not keep it running?

file:///C:/Users/ferna/Desktop/programming/js/starrail-auto/lib/apps/stamina.js:95
                                throw new Error({
                                      ^

CustomError: Error when getting stamina info
- args: {"statusCode":500,"body":"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n<HTML><HEAD><META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">\n<TITLE>ERROR: The request could not be satisfied</TITLE>\n</HEAD><BODY>\n<H1>500 ERROR</H1>\n<H2>The request could not be satisfied.</H2>\n<HR noshade size=\"1px\">\nThe Lambda@Edge service is currently experiencing problems.\nWe can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.\n<BR clear=\"all\">\nIf you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.\n<BR clear=\"all\">\n<HR noshade size=\"1px\">\n<PRE>\nGenerated by cloudfront (CloudFront)\nRequest ID: OO3WngBLDQnol-i9D-ZpSG6Kxe3bAQ-_qkziAiZHs-AhEXnlOeYogw==\n</PRE>\n<ADDRESS>\n</ADDRESS>\n</BODY></HTML>"}
    at Stamina.run (file:///C:/Users/ferna/Desktop/programming/js/starrail-auto/lib/apps/stamina.js:95:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async CJ.<anonymous> (file:///C:/Users/ferna/Desktop/programming/js/starrail-auto/index.js:49:19) {
  [cause]: undefined
}

Errors on Jul 6 commit

Hi! so i decided to update to the latest commits but so far i am trying to run the code but it keeps giving me errors:

const id = account.cookie.match(/account_id=(\d+)/)[1];

TypeError: Cannot read properties of null (reading '1')

at Account class I think.

all i did was:

  • git clone
  • npm install
  • properly configure the config.js file
  • node index.js

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.