Closed the-jason-json closed 2 months ago
it seems your errors are related to directory issue, are you sure you're running the commands at the hoyolab-auto
folder? Because currently you're running the commands outside the hoyolab-auto
folder
Oh that does get past some stuff, but now there's this:
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module 'keyv'
Require stack:
- /Users/jason/hoyolab-auto/singleton/cache.js
- /Users/jason/hoyolab-auto/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/Users/jason/hoyolab-auto/singleton/cache.js:1:14)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/jason/hoyolab-auto/singleton/cache.js',
'/Users/jason/hoyolab-auto/index.js'
]
}
Node.js v20.15.0
now try running npm install
and it should be good to go
Uh, I'm not sure how to read this all, but I tried install keyv, and tried npm install again:
jason@Jasons-MacBook hoyolab-auto % npm install
npm error code EACCES
npm error syscall open
npm error path /Users/jason/.npm/_cacache/index-v5/fd/0c/a4b3accc4f18b725fff2647e76f009d3f015e7ad7584ee188e4cb0526cca
npm error errno EACCES
npm error
npm error Your cache folder contains root-owned files, due to a bug in
npm error previous versions of npm which has since been addressed.
npm error
npm error To permanently fix this problem, please run:
npm error sudo chown -R 501:20 "/Users/jason/.npm"
npm error A complete log of this run can be found in: /Users/jason/.npm/_logs/2024-07-07T11_27_34_401Z-debug-0.log
jason@Jasons-MacBook hoyolab-auto % sudo chown -R 501:20 "/Users/jason/.npm"
Password:
jason@Jasons-MacBook hoyolab-auto % npm install
npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
npm warn deprecated @humanwhocodes/config-array@0.11.14: Use @eslint/config-array instead
npm warn deprecated rimraf@3.0.2: Rimraf versions prior to v4 are no longer supported
npm warn deprecated glob@7.2.3: Glob versions prior to v9 are no longer supported
npm warn deprecated @humanwhocodes/object-schema@2.0.3: Use @eslint/object-schema instead
added 312 packages, and audited 313 packages in 2s
71 packages are looking for funding
run `npm fund` for details
3 vulnerabilities (1 low, 2 high)
To address all issues, run:
npm audit fix --force
Run `npm audit` for details.
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
/Users/jason/hoyolab-auto/index.js:23
throw new Error({ message: "No default or custom configuration found." });
^
Error: No default or custom configuration found.
at Object.<anonymous> (/Users/jason/hoyolab-auto/index.js:23:9)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[cause]: undefined
}
Node.js v20.15.0
Idk if i messed up something by install a ton of random stuff ;-;
You're doing just fine! npm install
means it's installing the required packages to run this script, and you've successfully installed all the necessary packages.
Regarding the last error that says No default or custom configuration found
, do you see any file named default.config.js
or did you create a file named config.js
?
Thank you for being so patient with me btw
I did rename the original default.config.js
file to config.js
Interesting... can you go to the index.js file which is this one
and find then find this line if you're comfortable with it https://github.com/torikushiii/hoyolab-auto/blob/a9484777248a5fabdf15b49988ba4ca821c0a630/index.js#L14-L25
then edit/paste this code to the mentioned line above
let config;
try {
config = require("./config.js");
}
catch {
try {
config = require("./default.config.js");
}
catch (e) {
throw new Error({ message: "No default or custom configuration found.", args: { e } });
}
}
Alright done, I edited /Users/jason/hoyolab-auto/index.js
to change the error message to the new one
let config;
try {
config = require("./config.js");
}
catch {
try {
config = require("./default.config.js");
}
catch {
throw new Error({ message: "No default or custom configuration found.", args: { e } });
}
}
uh, you're missing (e) at the catch
it should like this catch (e)
or you can just select all, remove everything from that file, then paste this one and try running it again.
const Command = require("./classes/command.js");
const Config = require("./classes/config.js");
const Got = require("./classes/got.js");
const Cache = require("./singleton/cache.js");
const Logger = require("./singleton/logger.js");
const Utils = require("./singleton/utils.js");
const HoyoLab = require("./hoyolab-modules/template.js");
const Platform = require("./platforms/template.js");
const Error = require("./object/error.js");
let config;
try {
config = require("./config.js");
}
catch {
try {
config = require("./default.config.js");
}
catch (e) {
throw new Error({ message: "No default or custom configuration found.", args: { e } });
}
}
(async () => {
const start = process.hrtime.bigint();
const platformsConfig = config.platforms;
if (!platformsConfig || platformsConfig.length === 0) {
console.warn("No platforms configured! Exiting.");
process.exit(0);
}
globalThis.app = {
Error,
Config,
Command,
Got: await Got.initialize(),
Cache: new Cache(),
Logger: new Logger(config.loglevel),
Utils: new Utils()
};
app.Logger.info("Client", "Loading configuration data");
Config.load(config);
app.Logger.info("Client", `Loaded ${Config.data.size} configuration entries`);
const platforms = new Set();
for (const definition of platformsConfig) {
if (!definition.active) {
app.Logger.warn("Client", `Skipping ${definition.type} platform (inactive)`);
continue;
}
platforms.add(Platform.create(definition.type, definition));
}
const { loadCommands } = require("./commands/index.js");
const commands = await loadCommands();
await Command.importData(commands.definitions);
const { initCrons } = require("./crons/index.js");
initCrons();
const accountsConfig = config.accounts;
if (!accountsConfig || accountsConfig.length === 0) {
app.Logger.warn("Client", "No accounts configured! Exiting.");
process.exit(0);
}
const accounts = new Set();
for (const definition of accountsConfig) {
if (!definition.active) {
app.Logger.warn("Client", `Skipping ${definition.type} account (inactive)`);
continue;
}
accounts.add(HoyoLab.create(definition.type, definition));
}
const definitions = require("./gots/index.js");
await app.Got.importData(definitions);
globalThis.app = {
...app,
Platform,
HoyoLab
};
const promises = [];
for (const platform of platforms) {
promises.push(platform.connect());
}
const hoyoPromises = [];
for (const account of accounts) {
hoyoPromises.push(account.login());
}
await Promise.all(promises);
await Promise.all(hoyoPromises);
const end = process.hrtime.bigint();
app.Logger.info("Client", `Initialize completed (${Number(end - start) / 1e6}ms)`);
process.on("unhandledRejection", (reason) => {
if (!(reason instanceof Error)) {
return;
}
app.Logger.log("Client", {
message: "Unhandled promise rejection",
args: { reason }
});
});
})();
Ah I didn't see that, mb
let config;
try {
config = require("./config.js");
}
catch {
try {
config = require("./default.config.js");
}
catch (e) {
throw new Error({ message: "No default or custom configuration found.", args: { e } });
}
}
now can you try running it again and see what error does it says?
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
/Users/jason/hoyolab-auto/index.js:23
throw new Error({ message: "No default or custom configuration found.", args: { e } });
^
Error: No default or custom configuration found.
- args: {"e":{"code":"MODULE_NOT_FOUND","requireStack":["/Users/jason/hoyolab-auto/index.js"]}}
at Object.<anonymous> (/Users/jason/hoyolab-auto/index.js:23:9)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[cause]: undefined
}
Node.js v20.15.0
it seems that node doesn't detect the config file correctly for some reason. How about this, can you try creating default.config.js
but keep your config.js
file then paste your values from config.js
file to default.config.js
file
I made a copy of config.js
, and then renamed it default.config.js
(both files are in /Users/jason/hoyolab-auto
)
That should be fine right?
Also I ran it again and got this:
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
/Users/jason/hoyolab-auto/index.js:23
throw new Error({ message: "No default or custom configuration found.", args: { e } });
^
Error: No default or custom configuration found.
- args: {"e":{}}
at Object.<anonymous> (/Users/jason/hoyolab-auto/index.js:23:9)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[cause]: undefined
}
Node.js v20.15.0
does running node index.js
instead npm start
still give you the same issue? I'm starting to think this is a mac related issue and im currently trying to find a mac platform to debug it.
I think so
jason@Jasons-MacBook hoyolab-auto % node index.js
/Users/jason/hoyolab-auto/index.js:23
throw new Error({ message: "No default or custom configuration found.", args: { e } });
^
Error: No default or custom configuration found.
- args: {"e":{}}
at Object.<anonymous> (/Users/jason/hoyolab-auto/index.js:23:9)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49 {
[cause]: undefined
}
Node.js v20.15.0
here's a quick work-around for the config file while i'm looking for solutions.
paste all of this code into index.js and fill your configs at the config object and let me know the result
const Command = require("./classes/command.js");
const Config = require("./classes/config.js");
const Got = require("./classes/got.js");
const Cache = require("./singleton/cache.js");
const Logger = require("./singleton/logger.js");
const Utils = require("./singleton/utils.js");
const HoyoLab = require("./hoyolab-modules/template.js");
const Platform = require("./platforms/template.js");
const Error = require("./object/error.js");
const config = {
prefix: "-", // Command prefix, if you enable and have Discord bot
loglevel: "info",
userAgent: "Custom fork of HoyoLabAuto: github.com/torikushiii/hoyolab-auto",
platforms: [
{
id: 1,
active: true,
type: "discord", // This platform is optional, only use this if you have want to access commands via Discord bot
botId: "123", // Your Discord bot ID
token: "(YOUR_DISCORD_BOT_TOKEN)"
},
{
id: 2,
active: false, // Set to true if you want to enable Telegram bot
type: "telegram",
chatId: 123, // You can follow this guide to create a bot: https://github.com/torikushiii/hoyolab-auto/blob/main/setup/TELEGRAM.md
token: "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
disableNotification: false // Set to true if you want to disable notification for Telegram bot (sounds, vibration, etc.)
},
{
id: 3,
active: true, // Set to true if you want to send notification to Discord webhook
type: "webhook",
url: "(YOUR_WEBHOOK_URL)" // You can follow this guide to create a webhook: https://github.com/torikushiii/hoyolab-auto/blob/main/setup/DISCORD_WEBHOOK.md
}
],
accounts: [
{
id: 1,
active: false, // Set to true if you want to enable Honkai Impact 3rd
type: "honkai",
data: [
{
cookie: ""
}
]
},
{
id: 2,
active: true, // Set to true if you want to enable Genshin Impact
type: "genshin",
data: [
{
cookie: "",
// Enable this if you want to automatically redeem codes
// Please note that if you have multiple accounts in the different regions
// the code will be redeemed but you won't get the reward
// so please be careful when enabling this, and only enable it on the account that you want to redeem the code
redeemCode: false,
dailiesCheck: true, // Enable this if you want to get reminded to do your daily commissions
weekliesCheck: true, // Enable this if you want to get reminded to do your weeklies
realm: {
check: true,
persistent: false
},
stamina: {
check: false, // Enable this if you want to get notified when your stamina is above the threshold
threshold: 150, // Your stamina threshold, only fires notification when your stamina is above this value
persistent: false // Set to true if you want to get notified every time your stamina is above the threshold
},
expedition: {
check: false, // Enable this if you want to get notified when your expedition is done
persistent: false // Set to true if you want to get notified every time your expedition is done
}
}
]
},
{
id: 3,
active: true, // Set to true if you want to enable Honkai: Star Rail
type: "starrail",
data: [
// If you have same account for both genshin and starrail
// You can copy the cookie values from the genshin account
// Same goes for any other game that will be supported in the future
// Support multi-account for every type of game
// Just add another object inside the data array
// Account #1
{
cookie: "",
redeemCode: false,
dailiesCheck: true,
weekliesCheck: true,
stamina: {
check: true,
threshold: 230,
persistent: true
},
expedition: {
check: true,
persistent: false
}
},
// Account #2
// Delete this if you only have one account
{
cookie: "",
dailiesCheck: false,
weekliesCheck: false,
stamina: {
check: false,
threshold: 150,
persistent: false
},
expedition: {
check: false,
persistent: false
}
}
]
},
{
id: 4,
active: false,
type: "zenless",
data: [
{
cookie: "",
redeemCode: false,
shopStatus: false, // This will check if your shop has finished selling videos
dailiesCheck: true,
stamina: {
check: true,
threshold: 200,
persistent: false
}
}
]
}
]
};
(async () => {
const start = process.hrtime.bigint();
const platformsConfig = config.platforms;
if (!platformsConfig || platformsConfig.length === 0) {
console.warn("No platforms configured! Exiting.");
process.exit(0);
}
globalThis.app = {
Error,
Config,
Command,
Got: await Got.initialize(),
Cache: new Cache(),
Logger: new Logger(config.loglevel),
Utils: new Utils()
};
app.Logger.info("Client", "Loading configuration data");
Config.load(config);
app.Logger.info("Client", `Loaded ${Config.data.size} configuration entries`);
const platforms = new Set();
for (const definition of platformsConfig) {
if (!definition.active) {
app.Logger.warn("Client", `Skipping ${definition.type} platform (inactive)`);
continue;
}
platforms.add(Platform.create(definition.type, definition));
}
const { loadCommands } = require("./commands/index.js");
const commands = await loadCommands();
await Command.importData(commands.definitions);
const { initCrons } = require("./crons/index.js");
initCrons();
const accountsConfig = config.accounts;
if (!accountsConfig || accountsConfig.length === 0) {
app.Logger.warn("Client", "No accounts configured! Exiting.");
process.exit(0);
}
const accounts = new Set();
for (const definition of accountsConfig) {
if (!definition.active) {
app.Logger.warn("Client", `Skipping ${definition.type} account (inactive)`);
continue;
}
accounts.add(HoyoLab.create(definition.type, definition));
}
const definitions = require("./gots/index.js");
await app.Got.importData(definitions);
globalThis.app = {
...app,
Platform,
HoyoLab
};
const promises = [];
for (const platform of platforms) {
promises.push(platform.connect());
}
const hoyoPromises = [];
for (const account of accounts) {
hoyoPromises.push(account.login());
}
await Promise.all(promises);
await Promise.all(hoyoPromises);
const end = process.hrtime.bigint();
app.Logger.info("Client", `Initialize completed (${Number(end - start) / 1e6}ms)`);
process.on("unhandledRejection", (reason) => {
if (!(reason instanceof Error)) {
return;
}
app.Logger.log("Client", {
message: "Unhandled promise rejection",
args: { reason }
});
});
})();
Alright, I added my cookies and settings to /Users/jason/hoyolab-auto/index.js
, then ran npm start
again
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
/Users/jason/hoyolab-auto/index.js:94
cookie: "
^
SyntaxError: Invalid or unexpected token
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
Node.js v20.15.0
Node index also doesn't work
Node.js v20.15.0
jason@Jasons-MacBook hoyolab-auto % node index.js
/Users/jason/hoyolab-auto/index.js:94
cookie: "
^
SyntaxError: Invalid or unexpected token
at wrapSafe (node:internal/modules/cjs/loader:1281:20)
at Module._compile (node:internal/modules/cjs/loader:1321:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
at node:internal/main/run_main_module:28:49
Node.js v20.15.0
that error mean that the account cookie that you provided is not pasted correctly, make sure it looks like this
cookie: "mi18nLang=xxxx; _MHYUUID=xxxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxxx; e_nap_token=xxxx; cookie_token_v2=xxxx; account_mid_v2=xxxx; account_id_v2=xxxx; ltoken_v2=xxxx; ltmid_v2=xxxx; ltuid_v2=xxxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxxx; DEVICEFP_SEED_ID=xxxx; DEVICEFP_SEED_TIME=xxxx; DEVICEFP=xxxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxxx"
not like this
cookie: "
mi18nLang=xxxx; _MHYUUID=xxxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxxx; e_nap_token=xxxx; cookie_token_v2=xxxx; account_mid_v2=xxxx; account_id_v2=xxxx; ltoken_v2=xxxx; ltmid_v2=xxxx; ltuid_v2=xxxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxxx; DEVICEFP_SEED_ID=xxxx; DEVICEFP_SEED_TIME=xxxx; DEVICEFP=xxxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxxx"
Ah I see. There's this now though
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
2024-07-07 20:46:59 <INFO:System> Log level set to info
2024-07-07 20:46:59 <INFO:Client> Loading configuration data
2024-07-07 20:46:59 <INFO:Client> Loaded 5 configuration entries
2024-07-07 20:46:59 <WARN:Client> Skipping discord platform (inactive)
2024-07-07 20:46:59 <WARN:Client> Skipping telegram platform (inactive)
2024-07-07 20:46:59 <INFO:Cron> Initialized 8 cron jobs
2024-07-07 20:46:59 <WARN:Client> Skipping honkai account (inactive)
2024-07-07 20:46:59 <WARN:Client> Skipping genshin account (inactive)
Failed to create platform starrail.
Error: No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.
- args: {"cookie":""}
at #parseCookie (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:305:10)
at new HoyoLab (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:244:42)
at new StarRail (/Users/jason/hoyolab-auto/hoyolab-modules/starrail.js:26:3)
at HoyoLab.create (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:561:11)
at /Users/jason/hoyolab-auto/index.js:202:24 {
[cause]: undefined
}
/Users/jason/hoyolab-auto/index.js:221
hoyoPromises.push(account.login());
^
TypeError: Cannot read properties of undefined (reading 'login')
at /Users/jason/hoyolab-auto/index.js:221:29
Node.js v20.15.0
The cookies seem correct however, as they have the ltoken_v2, ltuid_v2 and ltmid_v2 in it
are you using Star Rail account? If you don't set active to false, if you do, then you didn't add any cookie the the Star Rail config account.
it should look like this:
{
id: 3,
active: true, // Set to true if you want to enable Honkai: Star Rail
type: "starrail",
data: [
{
// Your whole cookie
cookie: "mi18nLang=xxxx; _MHYUUID=xxxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxxx; e_nap_token=xxxx; cookie_token_v2=xxxx; account_mid_v2=xxxx; account_id_v2=xxxx; ltoken_v2=xxxx; ltmid_v2=xxxx; ltuid_v2=xxxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxxx; DEVICEFP_SEED_ID=xxxx; DEVICEFP_SEED_TIME=xxxx; DEVICEFP=xxxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxxx",
redeemCode: false,
dailiesCheck: true,
weekliesCheck: true,
stamina: {
check: true,
threshold: 230,
persistent: true
},
expedition: {
check: true,
persistent: false
}
}
]
}
Yes, starrail is currently set to this
id: 3,
active: true, // Set to true if you want to enable Honkai: Star Rail
type: "starrail",
data: [
// If you have same account for both genshin and starrail
// You can copy the cookie values from the genshin account
// Same goes for any other game that will be supported in the future
// Support multi-account for every type of game
// Just add another object inside the data array
// Account #1
{
cookie: "[I put my cookie here don't worry]",
redeemCode: true,
dailiesCheck: true,
weekliesCheck: true,
stamina: {
check: true,
threshold: 230,
persistent: true
},
expedition: {
check: true,
persistent: false
}
},
// Account #2
// Delete this if you only have one account
{
cookie: "",
dailiesCheck: false,
weekliesCheck: false,
stamina: {
check: false,
threshold: 150,
persistent: false
},
expedition: {
check: false,
persistent: false
}
}
]
},
{
For reference, the ZZZ one looks like this:
id: 4,
active: true,
type: "zenless",
data: [
{
cookie: "[yeah the cookie's here]",
redeemCode: true,
shopStatus: true, // This will check if your shop has finished selling videos
dailiesCheck: true,
stamina: {
check: true,
threshold: 200,
persistent: false
}
}
]
}
]
};
Interesting, because what this error says is that there's no cookie being passed to the parser
Error: No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.
- args: {"cookie":""} <- No cookie at all
at #parseCookie (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:305:10)
at new HoyoLab (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:244:42)
at new StarRail (/Users/jason/hoyolab-auto/hoyolab-modules/starrail.js:26:3)
at HoyoLab.create (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:561:11)
at /Users/jason/hoyolab-auto/index.js:202:24 {
[cause]: undefined
}
that error should print out your current hsr cookie but it print out nothing instead
Which file does it use to retrieve the cookie? I could double check it
can you got to hoyolab-modules/template.js
and find this line and see if it prints out anything at all.
This function will print out your entire cookie if there's any but the values will be replaced with "xxx"
const replacedCookie = cookie.replace(/=([^;]+)/g, "=xxx");
console.log(replacedCookie);
#parseCookie (cookie) {
const replacedCookie = cookie.replace(/=([^;]+)/g, "=xxx"); // Add this
console.log(replacedCookie); // And this
const cookies = cookie.split("; ");
const cookieMap = Object.fromEntries(
cookies.map(c => {
const [key, value] = c.split("=");
return [key, value];
})
);
const {
ltoken_v2,
ltuid_v2,
ltmid_v2,
cookie_token_v2,
account_mid_v2,
account_id_v2
} = cookieMap;
if (!ltoken_v2 || !ltuid_v2 || !ltmid_v2) {
throw new app.Error({
message: "No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.",
args: { cookie }
});
}
if (cookie_token_v2 && account_mid_v2 && account_id_v2) {
return {
cookie: this.#buildCookie(cookieMap, { token: true }),
codeRedeem: true
};
}
if (this.name !== "honkai") {
app.Logger.warn("HoyoLab", `No cookie_token_v2 or account_mid_v2 found in cookie for ${this.name}. This will disable "redeemCode" functionality.`);
}
return {
cookie: this.#buildCookie(cookieMap),
codeRedeem: false
};
}
Ok I added those 2 lines
the error changed to this:
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
2024-07-07 21:28:08 <INFO:System> Log level set to info
2024-07-07 21:28:08 <INFO:Client> Loading configuration data
2024-07-07 21:28:08 <INFO:Client> Loaded 5 configuration entries
2024-07-07 21:28:08 <WARN:Client> Skipping discord platform (inactive)
2024-07-07 21:28:08 <WARN:Client> Skipping telegram platform (inactive)
2024-07-07 21:28:08 <INFO:Cron> Initialized 8 cron jobs
2024-07-07 21:28:08 <WARN:Client> Skipping honkai account (inactive)
2024-07-07 21:28:08 <WARN:Client> Skipping genshin account (inactive)
_MHYUUID=xxx; mi18nLang=xxx; DEVICEFP_SEED_ID=xxx; DEVICEFP_SEED_TIME=xxx; DEVICEFP=xxx; account_mid_v2=xxx; account_id_v2=xxx; ltmid_v2=xxx; ltuid_v2=xxx; cookie_token_v2=xxx; ltoken_v2=xxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxx
Failed to create platform starrail.
Error: No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.
- args: {"cookie":""}
at #parseCookie (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:308:10)
at new HoyoLab (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:244:42)
at new StarRail (/Users/jason/hoyolab-auto/hoyolab-modules/starrail.js:26:3)
at HoyoLab.create (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:564:11)
at /Users/jason/hoyolab-auto/index.js:202:24 {
[cause]: undefined
}
_MHYUUID=xxx; mi18nLang=xxx; DEVICEFP_SEED_ID=xxx; DEVICEFP_SEED_TIME=xxx; DEVICEFP=xxx; account_mid_v2=xxx; account_id_v2=xxx; ltmid_v2=xxx; ltuid_v2=xxx; cookie_token_v2=xxx; ltoken_v2=xxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxx
/Users/jason/hoyolab-auto/index.js:221
hoyoPromises.push(account.login());
^
TypeError: Cannot read properties of undefined (reading 'login')
at /Users/jason/hoyolab-auto/index.js:221:29
Node.js v20.15.0
I forgot to add one more log point to the code, let me know what value being printed (cookieMap does not replace your actual cookie values unlike replacedCookie)
#parseCookie (cookie) {
const replacedCookie = cookie.replace(/=([^;]+)/g, "=xxx"); // Add this
console.log(replacedCookie); // And this
const cookies = cookie.split("; ");
const cookieMap = Object.fromEntries(
cookies.map(c => {
const [key, value] = c.split("=");
return [key, value];
})
);
console.log({ cookieMap }) // <---- This one
const {
ltoken_v2,
ltuid_v2,
ltmid_v2,
cookie_token_v2,
account_mid_v2,
account_id_v2
} = cookieMap;
if (!ltoken_v2 || !ltuid_v2 || !ltmid_v2) {
throw new app.Error({
message: "No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.",
args: { cookie }
});
}
if (cookie_token_v2 && account_mid_v2 && account_id_v2) {
return {
cookie: this.#buildCookie(cookieMap, { token: true }),
codeRedeem: true
};
}
if (this.name !== "honkai") {
app.Logger.warn("HoyoLab", `No cookie_token_v2 or account_mid_v2 found in cookie for ${this.name}. This will disable "redeemCode" functionality.`);
}
return {
cookie: this.#buildCookie(cookieMap),
codeRedeem: false
};
}
Wait send the entire error, including the actual cookie values from cookieMap?
No, just let me know if it prints anything, if it does it should look like this at your console
{
cookieMap: {
mi18nLang: 'xxx',
HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT: '123',
_MHYUUID: '123123',
cookie_token_v2: 'xxx',
account_mid_v2: 'xxx',
account_id_v2: 'xxx',
ltoken_v2: 'xxx',
ltmid_v2: 'xxx',
ltuid_v2: 'xxx',
HYV_LOGIN_PLATFORM_LOAD_TIMEOUT: '{}',
DEVICEFP_SEED_ID: 'xxx',
DEVICEFP_SEED_TIME: 'xxx',
DEVICEFP: 'xxx',
HYV_LOGIN_PLATFORM_TRACKING_MAP: '{}',
HYV_LOGIN_PLATFORM_LIFECYCLE_ID: 'xxxx'
}
}
starting from cookie map it looks like this
cookieMap: {
_MHYUUID: 'xxx',
mi18nLang: 'en-us',
DEVICEFP_SEED_ID: 'xxx',
DEVICEFP_SEED_TIME: 'xxx',
DEVICEFP: 'xxx',
account_mid_v2: 'xxx',
account_id_v2: 'xxx',
ltmid_v2: 'xxx',
ltuid_v2: 'xxx',
cookie_token_v2: 'xxx',
ltoken_v2: 'xxx',
HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT: '{%22content%22:[]}',
HYV_LOGIN_PLATFORM_LOAD_TIMEOUT: '{}',
HYV_LOGIN_PLATFORM_TRACKING_MAP: '{}',
HYV_LOGIN_PLATFORM_LIFECYCLE_ID: '{xxx}'
}
}
/Users/jason/hoyolab-auto/index.js:221
hoyoPromises.push(account.login());
^
TypeError: Cannot read properties of undefined (reading 'login')
at /Users/jason/hoyolab-auto/index.js:221:29
Node.js v20.15.0
I'm assuming this error still persist?
Failed to create platform starrail.
Error: No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.
- args: {"cookie":""}
at #parseCookie (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:308:10)
at new HoyoLab (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:244:42)
at new StarRail (/Users/jason/hoyolab-auto/hoyolab-modules/starrail.js:26:3)
at HoyoLab.create (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:564:11)
at /Users/jason/hoyolab-auto/index.js:202:24 {
[cause]: undefined
}
which is weird because there's value being passed....
Yes, that's still here
jason@Jasons-MacBook hoyolab-auto % npm start
> start
> node index.js
2024-07-07 21:45:05 <INFO:System> Log level set to info
2024-07-07 21:45:05 <INFO:Client> Loading configuration data
2024-07-07 21:45:05 <INFO:Client> Loaded 5 configuration entries
2024-07-07 21:45:05 <WARN:Client> Skipping discord platform (inactive)
2024-07-07 21:45:05 <WARN:Client> Skipping telegram platform (inactive)
2024-07-07 21:45:05 <INFO:Cron> Initialized 8 cron jobs
2024-07-07 21:45:05 <WARN:Client> Skipping honkai account (inactive)
2024-07-07 21:45:05 <WARN:Client> Skipping genshin account (inactive)
_MHYUUID=xxx; mi18nLang=xxx; DEVICEFP_SEED_ID=xxx; DEVICEFP_SEED_TIME=xxx; DEVICEFP=xxx; account_mid_v2=xxx; account_id_v2=xxx; ltmid_v2=xxx; ltuid_v2=xxx; cookie_token_v2=xxx; ltoken_v2=xxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxx
{
cookieMap: {
[insert the cookie map stuff]
}
}
{ cookieMap: { '': undefined } }
Failed to create platform starrail.
Error: No ltoken_v2, ltuid_v2, or ltmid_v2 found in cookie.
- args: {"cookie":""}
at #parseCookie (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:310:10)
at new HoyoLab (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:244:42)
at new StarRail (/Users/jason/hoyolab-auto/hoyolab-modules/starrail.js:26:3)
at HoyoLab.create (/Users/jason/hoyolab-auto/hoyolab-modules/template.js:566:11)
at /Users/jason/hoyolab-auto/index.js:202:24 {
[cause]: undefined
}
_MHYUUID=xxx; mi18nLang=xxx; DEVICEFP_SEED_ID=xxx; DEVICEFP_SEED_TIME=xxx; DEVICEFP=xxx; account_mid_v2=xxx; account_id_v2=xxx; ltmid_v2=xxx; ltuid_v2=xxx; cookie_token_v2=xxx; ltoken_v2=xxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxx
{
cookieMap: {
[insert same cookiemap stuff]
}
}
/Users/jason/hoyolab-auto/index.js:221
hoyoPromises.push(account.login());
^
TypeError: Cannot read properties of undefined (reading 'login')
at /Users/jason/hoyolab-auto/index.js:221:29
Node.js v20.15.0
I see an undefined values there { cookieMap: { '': undefined } }
after the first cookieMap
, I think I know what it is, did you remove the second account object at Star Rail?
{
id: 3,
active: true,
type: "starrail",
data: [
// Account #1
{
cookie: "",
redeemCode: false,
dailiesCheck: true,
weekliesCheck: true,
stamina: {
check: true,
threshold: 230,
persistent: true
},
expedition: {
check: true,
persistent: false
}
},
// Account #2
// Remove this one
{
cookie: "",
dailiesCheck: false,
weekliesCheck: false,
stamina: {
check: false,
threshold: 150,
persistent: false
},
expedition: {
check: false,
persistent: false
}
}
]
}
so after the first one, it goes directly to zzz?
redeemCode: true,
dailiesCheck: true,
weekliesCheck: true,
stamina: {
check: true,
threshold: 230,
persistent: true
},
expedition: {
check: true,
persistent: false
}
},
]
},
{
id: 4,
active: true,
type: "zenless",
data: [
yes, it should be go to ZZZ after checking the HSR account has a valid configurations, and if all goes good, the script should run just fine
oh huh I think it's working now currently stopped here how do i know if it's done? and so after this, i can just close terminal, and it'll just auto claim daily every day? i don't have to keep anything open or something?
Yes, you've successfully run the script.
Regarding the previous one, unfortunately, you'll need to keep it running for it to function. However, if you only need it for daily check-ins, I have a guide for using Google Apps Script that's very simple to follow at https://github.com/torikushiii/hoyolab-auto/tree/main/services/google-script.
The one you're currently using is the full project that can check almost anything: stamina, expeditions, etc that needs to run indefinitely
So basically, just keep the terminal tab open, and I can just relaunch it with npm if it closes right What happens if my laptop is asleep? Also is it possible to integrate webhooks with the Google Apps Script one?
So basically, just keep the terminal tab open, and I can just relaunch it with npm if it closes right What happens if my laptop is asleep?
Unfortunately no, You'll need to keep your laptop awake for it. There's a program called Caffeine (GitHub) for Mac so your Mac does not go to sleep for your specified time or indefinitely
Also is it possible to integrate webhooks with the Google Apps Script one?
webhooks already integrated at the Google App Script as you can see right here
Ah I couldn't find the app script, ty If it does fall asleep and I wake it up, it'll continue working as normal right? also, for
// "account_cookie_1",
// "account_cookie_2",
// ... more account cookies
I just replace that entire part with the copy pasted cookie blob right?
starrail: {
data: [
"xxx copied cookie yadda"
]
}
};
And I don't change anything if I don't need the login for that one? (genshin)
just paste your entire cookie just like what you did at config file, so like this
starrail: {
data: [
"mi18nLang=xxxx; _MHYUUID=xxxx; HYV_LOGIN_PLATFORM_OPTIONAL_AGREEMENT=xxxx; e_nap_token=xxxx; cookie_token_v2=xxxx; account_mid_v2=xxxx; account_id_v2=xxxx; ltoken_v2=xxxx; ltmid_v2=xxxx; ltuid_v2=xxxx; HYV_LOGIN_PLATFORM_LOAD_TIMEOUT=xxxx; DEVICEFP_SEED_ID=xxxx; DEVICEFP_SEED_TIME=xxxx; DEVICEFP=xxxx; HYV_LOGIN_PLATFORM_TRACKING_MAP=xxxx; HYV_LOGIN_PLATFORM_LIFECYCLE_ID=xxxx",
// and so on
]
}
If it does fall asleep and I wake it up, it'll continue working as normal right?
I'm not sure how does Mac does this, but usually it should start working immediately after you turning on your laptop again unless there's no internet or there's an error occurred.
ok, I did this
const config = {
genshin: {
data: [
// "account_cookie_1",
// "account_cookie_2",
// ... more account cookies
]
},
honkai: {
data: [
"// "account_cookie_1",
// "account_cookie_2",
// ... more account cookies"
]
},
starrail: {
data: [
"mi18nLang=en-us;
This makes it so Genshin and HI3 aren't activated, and it only claims for hsr + zzz right? Also, I added an icon for the ZZZ webhook, and this should work hopefully (edit: nvm the icon doesn't work like that xd)
zenless: {
ACT_ID: "e202406031448091",
successMessage: "En-nah! (There, I checked in for you, be grateful!)",
signedMessage: "Nah-nu... (You have already checked in today Jason...)",
game: "Zenless Zone Zero",
assets: {
author: "Sharkboo",
game: "Zenless Zone Zero"
icon: "https://www.prydwen.gg/static/1b169239f763dc0d1e18d8e13d3a2f1e/15e42/category_bangboo.png"
},
url: {
And the webhook url goes like this correct?
const DISCORD_WEBHOOK = "https://discord.com/api/webhooks/webhookid";
const DEFAULT_CONSTANTS = {
genshin: {
Yep, you're absolutely correct, everything seems to check out!
I've tried your modified code and it work just fine
just don't forget the missing comma at the game
value before icon
zenless: {
ACT_ID: "e202406031448091",
successMessage: "En-nah! (There, I checked in for you, be grateful!)",
signedMessage: "Nah-nu... (You have already checked in today Jason...)",
game: "Zenless Zone Zero",
assets: {
author: "Sharkboo",
game: "Zenless Zone Zero", // <- You missed comma there
icon: "https://www.prydwen.gg/static/1b169239f763dc0d1e18d8e13d3a2f1e/15e42/category_bangboo.png"
},
url: {
Ah yeah your right wow i didn't see that Ok i setup the rest of the stuff
Idk if i screwed up somewhere oh yeah btw, after this is setup I can just close the tab and ignore it? my laptop can be closed and everything and it'll still work? (as long as my google account isn't deleted xd)
that error is related to account cookies, try to follow the cookie guide again and see if its help
oh yeah i think i didn't copy paste it correctly at first there's no webhook message though, is that normal? also, after running it once i can close the tab and ignore it right?
there will be no webhook message if you've already checked-in today, but if you want to see if it works or not, you can just comment this line as show below and run it again
async checkAndExecute () {
const accounts = this.data;
if (accounts.length === 0) {
console.warn(`No active accounts found for ${this.fullName}`);
return [];
}
const success = [];
for (const cookie of accounts) {
try {
const info = await this.getSignInfo(cookie);
if (!info.success) {
continue;
}
const awardsData = await this.getAwardsData(cookie);
if (!awardsData.success) {
continue;
}
const awards = awardsData.data;
const data = {
total: info.data.total,
today: info.data.today,
isSigned: info.data.isSigned
};
// if (data.isSigned) {
// console.info(`${this.fullName}:CheckIn`, "Already signed in today");
// continue;
// }
const totalSigned = data.total;
const awardObject = {
name: awards[totalSigned].name,
count: awards[totalSigned].cnt,
icon: awards[totalSigned].icon
};
const sign = await this.sign(cookie);
// if (!sign.success) {
// continue;
// }
console.info(
`${this.fullName}:CheckIn`,
`Today's Reward: ${awardObject.name} x${awardObject.count}`
);
success.push({
platform: this.name,
total: data.total + 1,
result: this.config.successMessage,
assets: { ...this.config.assets },
award: awardObject
});
}
catch (e) {
console.error(`${this.fullName}:CheckIn`, e);
}
}
return success;
}
Not like this?
nope, you'll need to change it above, there's already function called checkAndExecute
at this line https://github.com/torikushiii/hoyolab-auto/blob/80ebab84722bc21b415a8b376abcb0bd6fb39c39/services/google-script/index.js#L117-L180
Ok I think it works So now I can just close the tab and never have to interact with it again?
I managed to install Git and Node.js, but running
npm install
gives me:this is after I copied the 'package.json' file over to User>jason, since the previous error was
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:Ty if you see this (idk how github works)