Coder Social home page Coder Social logo

torikushiii / hoyolab-auto Goto Github PK

View Code? Open in Web Editor NEW
44.0 2.0 11.0 389 KB

Auto check-in and others for any Hoyoverse games

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

License: GNU Affero General Public License v3.0

JavaScript 99.06% Dockerfile 0.17% Makefile 0.77%
discord-webhook genshin genshin-impact genshinimpact honkai-star-rail honkai-starrail hoyoverse mihoyo nodejs star-rail

hoyolab-auto's Introduction

HoyoLab Auto Logo
HoyoLab Auto

NodeJS version badge License badge GitHub stars badge

HoyoLab Auto

A multi-purpose tool for any supported Hoyoverse games. This tool is designed to assist with daily check-ins, stamina checks, expedition checks, automatic code-redemption, and more.

Table of Contents

Google App Script

If you don't have a server to run this script and simply just want to use it for checking in, you can use Google App Script.

Supported Games

  • Honkai Impact 3rd (Daily Check-In only)
  • Genshin Impact
  • Honkai: Star Rail
  • Zenless Zone Zero

Features

  • Honkai Impact 3rd:

    • Daily check-in: Runs every midnight local time.
  • Genshin Impact:

    • Daily check-in: Runs every midnight local time.
    • Dailies: Reminds you to do your dailies, such as commissions if you haven't done them at 09:00 (local time).
    • Weeklies: Reminds you to do your weekly bosses/discounted resin if you haven't done them at 09:00 (local time).
    • Stamina check: Reminds you to spend your resin if you're at your set threshold or capped.
    • Expedition check: Check your expeditions and sends a notification if they're done.
    • Realm currency: Sends a notification if your realm currency is capped.
    • Code Redeems: Search for codes and redeem them automatically.
  • Honkai: Star Rail:

    • Daily check-in: Runs every midnight local time.
    • Dailies: Reminds you to do your dailies, such as commissions if you haven't done them at 09:00 (local time).
    • Stamina check: Reminds you to spend your stamina if you're at your set threshold or capped.
    • Expedition check: Check your expeditions and sends a notification if they're done.
    • Code Redeems: Search for codes and redeem them automatically.
  • Zenless Zone Zero:

    • Daily check-in: Runs every midnight local time.
    • Dailies: Reminds you to do your dailies, such as commissions if you haven't done them at 09:00 (local time).
    • Stamina check: Reminds you to spend your stamina if you're at your set threshold or capped.
    • Howl Scracth Card: Notifies you if you haven't scratched the card for the day at 09:00 (local time).
    • Shop Status: Notifies you if the shop has finished selling videos.
    • Code Redeems: Search for codes and redeem them automatically.

Prerequisites

Installation

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

Usage

For a detailed usage guide, refer to this gist: Cookie Guide.

Notifications Setup

For setting up Discord or Telegram notifications, refer to the setup folder.

Running with Docker

This application can be easily managed and run using Docker. We provide a Makefile for convenience, but you can also use Docker commands directly.

1. Prerequisites

2. Configuration

  • Rename default.config.js: Create a copy of default.config.js named config.js and fill in your application's configuration:
    cp default.config.js config.js
    # Edit config.js with your settings 

3. Building and Running with Docker Compose

Using the Makefile (Recommended):

The provided Makefile simplifies common Docker tasks.

  • Build the image:

    make build 
  • Start the application:

    make up
  • Stop the application:

    make down
  • View logs:

    make logs 
  • Rebuild and restart:

    make update 

    For a complete list of available Makefile targets, run:

    make help

Using Docker Compose Directly:

If you prefer not to use the Makefile, you can use the following Docker Compose commands:

  • Build the image:
    docker-compose build
  • Start the application:
    docker-compose up -d
  • Stop the application:
    docker-compose down
  • View logs:
    docker-compose logs -f instance
  • Rebuild and restart:
    docker-compose down && docker-compose build && docker-compose up -d

Contributing

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

If you have any suggestions or ideas, feel free to open an issue.

New to contributing?

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

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

Buy Me a Coffee

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

ko-fi

hoyolab-auto's People

Contributors

flamingfox911 avatar sealldeveloper avatar torikushiii 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

Watchers

 avatar  avatar

hoyolab-auto's Issues

About the Docker auto redeem code

Today there is a new redeem code for Star Rail, but it cannot be redeemed correctly

I am very sure that the account has not redeemed this code before
螢幕擷取1

and I have re-cloned the git repository and re-composed

edit :
I tried running it locally, but the same issue still occurs

Specify which character you would like to redeem on

The config has a message that if you have multiple characters on the same account, eg. different regions. The redemption code will be used but you will not receive any rewards. A simple way around this would be to have an extra option (optional) in the config to specify the uid/region for which character to use the code on.

searchParams: {
t: Date.now(),
lang: "en",
game_biz: "nap_global",
uid: accountData.uid,
region: accountData.region,
cdkey: code
},

Running this on mac

I managed to install Git and Node.js, but running npm install gives me:

jason@Jasons-MacBook ~ % npm install
npm error code EEXIST
npm error syscall mkdir
npm error path /Users/jason/.npm/_cacache/content-v2/sha512/a6/58
npm error errno EEXIST
npm error Invalid response body while trying to fetch https://registry.npmjs.org/graphemer: EACCES: permission denied, mkdir '/Users/jason/.npm/_cacache/content-v2/sha512/a6/58'
npm error File exists: /Users/jason/.npm/_cacache/content-v2/sha512/a6/58
npm error Remove the existing file and try again, or run npm
npm error with --force to overwrite files recklessly.
npm error A complete log of this run can be found in: /Users/jason/.npm/_logs/2024-07-07T09_55_11_511Z-debug-0.log

this is after I copied the 'package.json' file over to User>jason, since the previous error was

jason@Jasons-MacBook ~ % npm install
npm error code ENOENT
npm error syscall open
npm error path /Users/jason/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/Users/jason/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /Users/jason/.npm/_logs/2024-07-07T09_47_54_261Z-debug-0.log

I tried doing some of the solutions online, but none of them fixed anything (Sorry, this is kinda my first time cloning a repository and doing these stuff, so I apologize if this is a stupid question and there's a stupidly easy solution)

Oh yeah running node index.js gives this error:

jason@Jasons-MacBook ~ % node index.js
node:internal/modules/cjs/loader:1148
  throw err;
  ^

Error: Cannot find module '/Users/jason/index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Module._load (node:internal/modules/cjs/loader:986:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.15.0

Ty if you see this (idk how github works)

ZZZ Cookie does not contain account_id_v2 and cookie_token_v2

ZZZ Cookie does not contain account_id_v2 and cookie_token_v2. Adding them manually does not solve the problem.

WARN:HoyoLab No cookie_token_v2 or account_mid_v2 found in cookie for nap. This will disable "redeemCode" functionality.

I suggest to add option to read config in old way as an additional functionality.

			cookie: {
				token: "", // cookie_token_v2
				mid: "", // account_mid_v2
				ltuid: "" // ltuid_v2
			},

Dailies Reminder, Check-in and Expedition [ZZZ]

  1. Expeditions are not supported, it seems.
    image
  2. Is it normal behavior that a daily reminder reminds you even when all the daily tasks are completed? According to starrail-auto, I remember that the notification came only in the case when it was not done by the time of the reminder
    image
  3. Shouldn't there be a notification that if the check-in has already been performed today, then send this notification, and not just write about it in the logs?
    image

Regarding the Docker section of the README

If you only install Docker without installing Make, you will not be able to use the method described in the README to start the Docker container. You might still need to use the previous method to start it

or install make

Discord bot is offline

When I try to set the discord platform to "true" my discord bot is still offline after running the script, but the rest is fine

image

[Bug] Redemption code websites responses

Errors related to inaccessible webpage with redemption codes should be displayed as 1 line:
2024-07-08 14:18:00 <INFO:ReadWrite> Failed to fetch data from ReadWrite.
instead of printing the whole website to terminal.

2024-07-08 12:43:58 <INFO:Client> Initialize completed (3734.898701ms)
2024-07-08 14:18:00 <INFO:ReadWrite> {
  message: 'Failed to fetch data from ReadWrite.',
  statusCode: 500,
  response: '<!DOCTYPE html>\n' +
    "<html dir='ltr'>\n" +
    '<head>\n' +
    '\t<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />\n' +
    '\t<meta name="viewport" content="width=device-width">\n' +
    '\t\t\t<title>Database Error</title>\n' +
    '\t<style type="text/css">\n' +
    '\t\thtml {\n' +
    '\t\t\tbackground: #f1f1f1;\n' +
    '\t\t}\n' +
    '\t\tbody {\n' +
    '\t\t\tbackground: #fff;\n' +
    '\t\t\tborder: 1px solid #ccd0d4;\n' +
    '\t\t\tcolor: #444;\n' +
    '\t\t\tfont-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;\n' +
    '\t\t\tmargin: 2em auto;\n' +
    '\t\t\tpadding: 1em 2em;\n' +
    '\t\t\tmax-width: 700px;\n' +
    '\t\t\t-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, .04);\n' +
    '\t\t\tbox-shadow: 0 1px 1px rgba(0, 0, 0, .04);\n' +
    '\t\t}\n' +
    '\t\th1 {\n' +
    '\t\t\tborder-bottom: 1px solid #dadada;\n' +
    '\t\t\tclear: both;\n' +
    '\t\t\tcolor: #666;\n' +
    '\t\t\tfont-size: 24px;\n' +
    '\t\t\tmargin: 30px 0 0 0;\n' +
    '\t\t\tpadding: 0;\n' +
    '\t\t\tpadding-bottom: 7px;\n' +
    '\t\t}\n' +
    '\t\t#error-page {\n' +
    '\t\t\tmargin-top: 50px;\n' +
    '\t\t}\n' +
    '\t\t#error-page p,\n' +
    '\t\t#error-page .wp-die-message {\n' +
    '\t\t\tfont-size: 14px;\n' +
    '\t\t\tline-height: 1.5;\n' +
    '\t\t\tmargin: 25px 0 20px;\n' +
    '\t\t}\n' +
    '\t\t#error-page code {\n' +
    '\t\t\tfont-family: Consolas, Monaco, monospace;\n' +
    '\t\t}\n' +
    '\t\tul li {\n' +
    '\t\t\tmargin-bottom: 10px;\n' +
    '\t\t\tfont-size: 14px ;\n' +
    '\t\t}\n' +
    '\t\ta {\n' +
    '\t\t\tcolor: #2271b1;\n' +
    '\t\t}\n' +
    '\t\ta:hover,\n' +
    '\t\ta:active {\n' +
    '\t\t\tcolor: #135e96;\n' +
    '\t\t}\n' +
    '\t\ta:focus {\n' +
    '\t\t\tcolor: #043959;\n' +
    '\t\t\tbox-shadow: 0 0 0 2px #2271b1;\n' +
    '\t\t\toutline: 2px solid transparent;\n' +
    '\t\t}\n' +
    '\t\t.button {\n' +

   ...

[GI] Serenitea Pot - Realm Currency

Could you please add Serenitea Pot Realm Currency to track the current count? I believe I saw it in genshin/api/dailyNote as current_home_coin

Getting "/bin/sh: git: not found <WARN:Cron:RealmCurrency> No active accounts to run the cron" while running the Code Redeems

Just trying to use the code redemption for starrail and zzz and getting the following output
Does it mean its working?

2024-07-14 15:55:34 > start
2024-07-14 15:55:34 > node index.js
2024-07-14 15:55:34 
2024-07-14 15:55:35 2024-07-15 06:55:35 <INFO:System> Log level set to info
2024-07-14 15:55:35 2024-07-15 06:55:35 <INFO:Client> Loading configuration data
2024-07-14 15:55:35 2024-07-15 06:55:35 <INFO:Client> Loaded 5 configuration entries
2024-07-14 15:55:35 2024-07-15 06:55:35 <WARN:Client> Skipping discord platform (inactive)
2024-07-14 15:55:35 2024-07-15 06:55:35 <WARN:Client> Skipping telegram platform (inactive)
2024-07-14 15:55:35 2024-07-15 06:55:35 <WARN:Client> Skipping webhook platform (inactive)
2024-07-14 15:55:35 2024-07-15 06:55:35 <INFO:Cron> Initialized 9 cron jobs
2024-07-14 15:55:35 2024-07-15 06:55:35 <WARN:Client> Skipping honkai account (inactive)
2024-07-14 15:55:35 2024-07-15 06:55:35 <WARN:Client> Skipping genshin account (inactive)
2024-07-14 15:55:37 2024-07-15 06:55:37 <INFO:ZenlessZoneZero> Logged into (removed) Phaethon (NA)
2024-07-14 15:55:37 2024-07-15 06:55:37 <INFO:StarRail> Logged into (removed) Trailblazer (NA)
2024-07-14 15:55:37 2024-07-15 06:55:37 <INFO:Client> Initialize completed (2411.33943ms)
2024-07-14 15:56:00 /bin/sh: git: not found
2024-07-14 16:00:00 2024-07-15 07:00:00 <WARN:Cron:RealmCurrency> No active accounts to run the cron

Command Execution Failed (Discord slash commands)

I'm getting command execution failed when I'm trying to execute /note command in Discord; however, the script keeps running, and I have the same error on the bot reply as well

image

Logs:

  message: 'Command execution failed',
  data: {
    command: 'notes',
    invocation: 'notes',
    platform: 1,
    args: [ 'starrail' ],
    error: Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
        at ChatInputCommandInteraction.reply (/root/hoyolab-auto/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:104:46)
        at Command.notes [as code] (/root/hoyolab-auto/commands/notes/index.js:188:23)
        at async Command.checkAndRun (/root/hoyolab-auto/classes/command.js:202:16)
        at async DiscordController.handleCommand (/root/hoyolab-auto/platforms/discord.js:182:21)
        at async Client.<anonymous> (/root/hoyolab-auto/platforms/discord.js:109:4) {
      code: 'InteractionAlreadyReplied'
    }
  }
}

Get more detail Google Script

Can I possibly get the UID and name from this API? Do you have the documentation for the API? I think I can improve it.

fatal: not a git repository (or any of the parent directories): .git

I am using Docker for this project. If I do not include the following command in the Dockerfile:RUN apk add --no-cache git
I get the error:/bin/sh: git: not found
If I add the command, the error changes to:hoyolab-auto | fatal: not a git repository (or any of the parent directories): .git

edit:
I re-cloned the project and added RUN apk add --no-cache git. For now, there haven't been any errors. Also, I want to ask whether the redemption code will automatically redeem the known codes the first time it runs, or will it only redeem new codes thereafter?

Bunch of "invalid request"

Webhook is still working
image

But I'm getting "invalid request" error codes in the console, recently synched my fork to yours

image

Just updated getting error

Just a question, I just updated my files to the latest and since Ive been getting these errors, any explanation? Rather is it anything to be worried about?
NVIDIA_Overlay_EyJ5RjcDXo

Failed to Login

Tried starting, followed the whole install guide to the letter, but this shows up.
Same goes for the other accounts (Star Rail, Zenless)

hoyolab auto check in error

I checked previously resolved issues and found one similar to mine a month ago, and I tested with the other, larger-sized cookie.
Didn't work either.

Auto Code Redemption

Are there any plans to add an auto code redemption feature? The idea is to fetch and redeem codes automatically. I will potentially look into implementing this myself if I get the time.

Failed to log-in

I updated my fork to the latest and subsequently the new cookie structure and it's throwing these please log-in errors which I'm confused about. am I supposed to log into the game?

image

"No default or custom configuration found."

Followed all the usual steps after updating to the latest commit and I keep getting this error, even if I were to leave the config on 'default.config.js' it pushes this same error.
image

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.