From bf4a2a05d4dc3706f246c201ceba33d346a24c06 Mon Sep 17 00:00:00 2001 From: Akatsuki-Misaki Date: Mon, 29 May 2023 12:11:38 +0800 Subject: [PATCH] Updata Script from hoyolab --- Auto-Js/README.md | 11 +++++ Auto-Js/hoyolab/README.md | 17 +++++++ Auto-Js/hoyolab/hoyolab.js | 97 ++++++++++++++++++++++++++++++++++++++ README.md | 1 - 4 files changed, 125 insertions(+), 1 deletion(-) create mode 100644 Auto-Js/README.md create mode 100644 Auto-Js/hoyolab/README.md create mode 100644 Auto-Js/hoyolab/hoyolab.js diff --git a/Auto-Js/README.md b/Auto-Js/README.md new file mode 100644 index 0000000..5e34797 --- /dev/null +++ b/Auto-Js/README.md @@ -0,0 +1,11 @@ +
logo

Akatsuki SASO

+
+ +# SASO-Static-API + +来自SASO的静态资源API库 + +## 说明 +hoyolab为国际版米游社的自动签到脚本 \ No newline at end of file diff --git a/Auto-Js/hoyolab/README.md b/Auto-Js/hoyolab/README.md new file mode 100644 index 0000000..4adea8c --- /dev/null +++ b/Auto-Js/hoyolab/README.md @@ -0,0 +1,17 @@ +
logo

Akatsuki SASO

+
+ +# SASO-Static-API + +来自SASO的静态资源API库 + +## 脚本说明 +本脚本使用node运行 +需要拉取node-fetch@2.6.1库 +需要申请一个tgbot用于提醒 +需要找到你的TGID用于机器人通知指定 +以上 + +祝您使用愉快 \ No newline at end of file diff --git a/Auto-Js/hoyolab/hoyolab.js b/Auto-Js/hoyolab/hoyolab.js new file mode 100644 index 0000000..831f6bc --- /dev/null +++ b/Auto-Js/hoyolab/hoyolab.js @@ -0,0 +1,97 @@ +const fetch = require('node-fetch'); + +const profiles = [ + { + token: "ltoken=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; ltuid=xxxxxx;", + genshin: false, + honkai_star_rail: true, + honkai_3: false, + accountName: "您账户的名字" + } +]; + +const telegram_notify = true; +const myTelegramID = "1351xxxxxx"; +const telegramBotToken = ""; + +const urlDict = { + Genshin: 'https://sg-hk4e-api.hoyolab.com/event/sol/sign?lang=zh-tw&act_id=e202102251931481', + Star_Rail: 'https://sg-public-api.hoyolab.com/event/luna/os/sign?lang=zh-tw&act_id=e202303301540311', + Honkai_3: 'https://sg-public-api.hoyolab.com/event/mani/sign?lang=zh-tw&act_id=e202110291205111' +}; + +function main() { + const messages = Promise.all(profiles.map(autoSignFunction)); + messages.then((messages) => { + const hoyolabResp = `${messages.join('\n\n')}`; + + if (telegram_notify === true) { + if (telegramBotToken && myTelegramID) { + postWebhook(hoyolabResp); + } + } + }); +} + +function autoSignFunction({ token, genshin, honkai_star_rail, honkai_3, accountName }) { + const urls = []; + + if (genshin) urls.push(urlDict.Genshin); + if (honkai_star_rail) urls.push(urlDict.Star_Rail); + if (honkai_3) urls.push(urlDict.Honkai_3); + + const header = { + Cookie: token + }; + + const options = { + method: 'POST', + headers: header + }; + + let response = `${accountName} 的自動簽到作業已完成`; + + return Promise.all( + urls.map(url => + fetch(url, options) + .then(response => response.json()) + .then(jsonResponse => { + const checkInResult = jsonResponse.message; + const enGameName = Object.keys(urlDict).find(key => urlDict[key] === url); + let gameName; + switch (enGameName) { + case 'Genshin': + gameName = '原神'; + break; + case 'Star_Rail': + gameName = '星穹鐵道'; + break; + case 'Honkai_3': + gameName = '崩壞3rd'; + break; + } + response += `\n${gameName}: ${checkInResult}`; + }) + ) + ).then(() => response); +} + +function postWebhook(data) { + const payload = JSON.stringify({ + chat_id: myTelegramID, + text: data, + parse_mode: 'HTML' + }); + + const options = { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: payload + }; + + fetch(`https://api.telegram.org/bot${telegramBotToken}/sendMessage`, options); +} + +main(); diff --git a/README.md b/README.md index 5aae295..9ed2629 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,3 @@ # SASO-Static-API 来自SASO的静态资源API库 -