Updata Script from hoyolab

main
赤月未咲 1 year ago
parent e47c0594bd
commit bf4a2a05d4

@ -0,0 +1,11 @@
<div align="center">
  <img height="100px" alt="logo" src="https://cdn.lolicon.team/i/img/svg/logo.ico"/>
  <p><em>Akatsuki SASO</em></p>
</div>
# SASO-Static-API
来自SASO的静态资源API库
## 说明
hoyolab为国际版米游社的自动签到脚本

@ -0,0 +1,17 @@
<div align="center">
  <img height="100px" alt="logo" src="https://cdn.lolicon.team/i/img/svg/logo.ico"/>
  <p><em>Akatsuki SASO</em></p>
</div>
# SASO-Static-API
来自SASO的静态资源API库
## 脚本说明
本脚本使用node运行
需要拉取node-fetch@2.6.1库
需要申请一个tgbot用于提醒
需要找到你的TGID用于机器人通知指定
以上
祝您使用愉快

@ -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();

@ -6,4 +6,3 @@
# SASO-Static-API
来自SASO的静态资源API库

Loading…
Cancel
Save