Code Monkey home page Code Monkey logo

starrail-auto's Introduction


Honkai: Star Rail Helper

Alt

Honkai: Star Rail Helper

A multi-purpose tool for the Honkai Impact: Star Rail that can be used to automate the daily check-in process, check stamina and expedition status.

Services

If you don't want to use Node.js and simply only want to use it for auto check-in, you can use one of the following services:

Features

  • Auto Check-in

    image

  • Multiple accounts
  • Stamina check (Node only)
    • Will send you notification if your stamina is above set threshold (default: 170)
  • Expedition check (Node only)
    • Will send you notification if your expedition is done
  • Reminders (Node only)
    • Dailies
      • Remind you to do your daily commission every day at 09:00 PM or your specified time (Only if you haven't done it yet)
    • Weeklies
      • Remind you to do your weekly boss every your specified time or Sunday 09:00 PM (Only if you haven't done it yet)
      • Remind you to do your Simulated Universe points every your specified time or Sunday 09:00 PM (Only if you haven't done it yet)
  • Code Redeem (Node only)
    • Will send you notification if there's a new code available
    • Will automatically redeem the code for you
  • Discord notifications
  • Telegram notifications (Node only)
    • Commands
      • Check stamina
      • Check expedition status

Pre-requisites

  • Node.js (You will need to run your computer 24/7 if you want to use this, Google Apps Script is recommended if you don't want to run your computer 24/7 but you can only use it for auto check-in)

Installation

  1. Clone the repository.
  2. Run npm install to install the dependencies.
  3. Create a config.json or rename default.config.json to config.json.
  4. Follow the instructions in the config.json file.

Usage

  1. Go to the Daily Check-In page here.
  2. Log in with your miHoYo account.
  3. Open the browser console (F12).
  4. Click on the "Application" tab.
  5. Type "lt" in the "Filter" bar. image
  6. Copy name and value (ltoken_v2 and ltuid_v2) and put it in your newly created config.json or default.config.json file.
  7. Run index.js with node index.js if you want to run it indefinitely everytime the daily reset occurs.
  8. Run index.js with node index.js --sign if you want to run it once.
  9. Additonal arguments:
    • --stamina to check all accounts stamina. (You need to set your in-game uid for it to work)
    • --expedition to check all accounts expedition status. (You need to set your in-game uid for it to work)
    • --help to show the help menu.

Notifications

For Discord notifications or Telegram setup, refer to this folder: setup

Docker

To start the project, you can use Docker.

How to run

For the application to work, the configuration file must be mounted under /app/config.json or /app/default.config.json, respectively (refer to docker-compose.yml for details).

  1. Prepare the configuration file as described in the Installation and Usage sections.
  2. Build the base image with docker compose build or without cache with docker compose build --no-cache.
  3. Start the container with docker compose up -d.
  4. Check logs with docker compose logs -f.

Makefile

There is a handy Makefile that can be used with GNU Make or GNU Make for Windows.

List of generally used commands:

  • make run - Start application.
  • make run-once - Start application once.
  • make install - Download node modules.
  • make start - Start the Docker container instance.
  • make stop - Stop the Docker container instance.
  • make logs - Read logs generated by the Docker container.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. If there's any bugs, please open an issue.

New here?

To get started, fork the repo, make your changes, add, commit and push your changes to your fork, then come back here and open a pull request. If you're new to GitHub, this tutorial may help.

You can support the project by giving it a star, sharing it with your friends, contributing to the project, and report any bugs you find.

Buy me a coffee

If this repo is useful to you, you can buy me a coffee to support me. Thank you!

ko-fi

starrail-auto's People

Contributors

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

Watchers

 avatar  avatar  avatar

starrail-auto's Issues

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
}

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...

[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!

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

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?)

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?

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

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

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.

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!

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 :)

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

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

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.

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);
}

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 | ?

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.

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

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.

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?

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.

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

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?

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.

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?

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.