Skip to content

Commit

Permalink
Consolidate Hoyolab API Requests
Browse files Browse the repository at this point in the history
- Unified all Hoyolab API requests to use a single `HoYoLab` Got instance.
- Replaced the deprecated `MiHoYo` Got instance with the updated `HoYoLab` instance for consistency.
  • Loading branch information
torikushiii committed Jul 23, 2024
1 parent 0090da4 commit a043718
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 45 deletions.
6 changes: 3 additions & 3 deletions crons/code-redeem/resolvers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const redeemGenshin = async (account, codeList) => {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: "https://sg-hk4e-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey",
searchParams: {
uid: account.uid,
Expand Down Expand Up @@ -110,7 +110,7 @@ const redeemStarRail = async (account, codeList) => {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: "https://sg-hkrpg-api.hoyoverse.com/common/apicdkey/api/webExchangeCdkey",
responseType: "json",
throwHttpErrors: false,
Expand Down Expand Up @@ -189,7 +189,7 @@ const redeemZenless = async (account, codeList) => {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: "https://public-operation-nap.hoyoverse.com/common/apicdkey/api/webExchangeCdkey",
searchParams: {
t: Date.now(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports.fetch = async () => {
}
}

const res = await app.Got("HoyoLab", {
const res = await app.Got("API", {
url: "https://api.ennead.cc/starrail/code",
responseType: "json",
throwHttpErrors: false,
Expand Down
8 changes: 6 additions & 2 deletions gots/hoyolab/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const definition = {
name: "HoyoLab",
name: "HoYoLab",
optionsType: "object",
options: {
headers: {
"User-Agent": app.Config.get("userAgent")
Referer: "https://act.hoyolab.com",
"x-rpc-app_version": "1.5.0",
"x-rpc-client_type": 5,
"x-rpc-language": "en-us",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
}
},
parent: "Global"
Expand Down
16 changes: 0 additions & 16 deletions gots/mihoyo/index.js

This file was deleted.

6 changes: 3 additions & 3 deletions hoyolab-modules/genshin/check-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = class CheckIn {
}

async #sign (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.sign,
method: "POST",
responseType: "json",
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = class CheckIn {
}

async #getSignInfo (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.info,
responseType: "json",
searchParams: {
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports = class CheckIn {
}

async #getAwardsData (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.home,
responseType: "json",
searchParams: {
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/genshin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = class Genshin extends require("../template.js") {
const cookieData = account.cookie;
const ltuid = account.ltuid;

const { body, statusCode } = await app.Got("MiHoYo", {
const { body, statusCode } = await app.Got("HoYoLab", {
url: "https://bbs-api-os.hoyolab.com/game_record/card/wapi/getGameRecordCard",
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/genshin/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = class RealtimeNotes {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.notes,
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/genshin/redeem-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = class RedeemCode {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.redemption,
responseType: "json",
throwHttpErrors: false,
Expand Down
6 changes: 3 additions & 3 deletions hoyolab-modules/honkai/check-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = class CheckIn {
}

async #sign (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.sign,
method: "POST",
responseType: "json",
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = class CheckIn {
}

async #getSignInfo (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.info,
responseType: "json",
searchParams: {
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports = class CheckIn {
}

async #getAwardsData (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.home,
responseType: "json",
searchParams: {
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/honkai/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = class HonkaiImpact extends require("../template.js") {
const cookieData = account.cookie;
const ltuid = account.ltuid;

const { body, statusCode } = await app.Got("MiHoYo", {
const { body, statusCode } = await app.Got("HoYoLab", {
url: "https://bbs-api-os.hoyolab.com/game_record/card/wapi/getGameRecordCard",
responseType: "json",
throwHttpErrors: false,
Expand Down
6 changes: 3 additions & 3 deletions hoyolab-modules/starrail/check-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = class CheckIn {
}

async #sign (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.sign,
method: "POST",
responseType: "json",
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = class CheckIn {
}

async #getSignInfo (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.info,
responseType: "json",
searchParams: {
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports = class CheckIn {
}

async #getAwardsData (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.home,
responseType: "json",
searchParams: {
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/starrail/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ module.exports = class StarRail extends require("../template.js") {
const cookieData = account.cookie;
const ltuid = account.ltuid;

const { body, statusCode } = await app.Got("MiHoYo", {
const { body, statusCode } = await app.Got("HoYoLab", {
url: "https://bbs-api-os.hoyolab.com/game_record/card/wapi/getGameRecordCard",
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/starrail/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = class RealtimeNotes {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.notes,
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/starrail/redeem-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = class RedeemCode {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.redemption,
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ module.exports = class HoyoLab {
}

async updateCookie (accountData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.webAPI,
responseType: "json",
throwHttpErrors: false,
Expand Down
6 changes: 3 additions & 3 deletions hoyolab-modules/zenless/check-in.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ module.exports = class CheckIn {
}

async #sign (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.sign,
method: "POST",
responseType: "json",
Expand Down Expand Up @@ -137,7 +137,7 @@ module.exports = class CheckIn {
}

async #getSignInfo (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.info,
responseType: "json",
searchParams: {
Expand Down Expand Up @@ -187,7 +187,7 @@ module.exports = class CheckIn {
}

async #getAwardsData (cookieData) {
const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.home,
responseType: "json",
searchParams: {
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/zenless/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ module.exports = class ZenlessZoneZero extends require("../template.js") {
const cookieData = account.cookie;
const ltuid = account.ltuid;

const { body, statusCode } = await app.Got("MiHoYo", {
const { body, statusCode } = await app.Got("HoYoLab", {
url: "https://bbs-api-os.hoyolab.com/game_record/card/wapi/getGameRecordCard",
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/zenless/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = class RealtimeNotes {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.notes,
responseType: "json",
throwHttpErrors: false,
Expand Down
2 changes: 1 addition & 1 deletion hoyolab-modules/zenless/redeem-code.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = class RedeemCode {
]
});

const res = await app.Got("MiHoYo", {
const res = await app.Got("HoYoLab", {
url: this.#instance.config.url.redemption,
responseType: "json",
throwHttpErrors: false,
Expand Down

0 comments on commit a043718

Please sign in to comment.