支持官服uid3开头,去除重复script文件

This commit is contained in:
Rrrrrrray 2024-01-15 16:17:48 +08:00
parent bef9fb70e9
commit 2f72a05ad2
6 changed files with 33 additions and 41 deletions

View File

@ -32,6 +32,9 @@ export class takeBirthdayPhoto extends plugin {
return true
}
this.region = await this.getServer(userInfo.uid)
this.game_biz = this.region.includes('cn') ? 'hk4e_cn' : 'hk4e_global'
const e_hk4e_token = await this.getEHK4EToken(userInfo.ck, userInfo.uid)
if (!e_hk4e_token) {
e.reply(['获取e-hk4e_token失败请刷新ck后再试~', this.button], true)
@ -48,6 +51,7 @@ export class takeBirthdayPhoto extends plugin {
e.reply(['今天没有生日角色哦~', this.button], true)
return true
}
try {
for (const role of birthday_star_list) {
await e.reply(`正在获取${role.name}的图片,请稍等~`, true)
@ -74,23 +78,20 @@ export class takeBirthdayPhoto extends plugin {
}
async getEHK4EToken (ck, uid) {
const isCN = uid.toString().match(/^[125]/) ? true : false
const url = isCN ? 'https://api-takumi.mihoyo.com/common/badge/v1/login/account' : 'https://api-os-takumi.mihoyo.com/common/badge/v1/login/account'
const game_biz = isCN ? 'hk4e_cn' : 'hk4e_global'
const region = await this.getServer(uid)
const url = this.region.includes('cn') ? 'https://api-takumi.mihoyo.com/common/badge/v1/login/account' : 'https://api-os-takumi.mihoyo.com/common/badge/v1/login/account'
const headers = {
'Cookie': ck,
Cookie: ck,
'Content-Type': 'application/json;charset=UTF-8',
'Referer': 'https://webstatic.mihoyo.com/',
'Origin': 'https://webstatic.mihoyo.com'
Referer: 'https://webstatic.mihoyo.com/',
Origin: 'https://webstatic.mihoyo.com'
}
const body = JSON.stringify({
uid: Number(uid),
game_biz: game_biz,
game_biz: this.game_biz,
lang: 'zh-cn',
region: region
region: this.region
})
let res = await fetch(url, { method: "POST", body, headers })
let res = await fetch(url, { method: 'POST', body, headers })
const e_hk4e_token = res.headers.get('set-cookie').match(/e_hk4e_token=(.*?);/)[1]
res = await res.json()
if (res.retcode != 0) {
@ -119,31 +120,21 @@ export class takeBirthdayPhoto extends plugin {
}
async getBirthdayStar (uid, e_hk4e_token, ck) {
const cookie = `e_hk4e_token=${e_hk4e_token};${ck}`
const badge_region = await this.getServer(uid)
const isCN = uid.toString().match(/^[125]/) ? true : false
const game_biz = isCN ? 'hk4e_cn' : 'hk4e_global'
const headers = { 'Cookie': cookie }
const url = `https://hk4e-api.mihoyo.com/event/birthdaystar/account/index?lang=zh-cn&badge_uid=${uid}&badge_region=${badge_region}&game_biz=${game_biz}&activity_id=20220301153521`
const headers = { Cookie: `e_hk4e_token=${e_hk4e_token};${ck}` }
const url = `https://hk4e-api.mihoyo.com/event/birthdaystar/account/index?lang=zh-cn&badge_uid=${uid}&badge_region=${this.region}&game_biz=${this.game_biz}&activity_id=20220301153521`
let res = await fetch(url, { headers })
res = await res.json()
return res.data.role
}
async getBirthdayStarImg (uid, e_hk4e_token, ck, role_id) {
const cookie = `e_hk4e_token=${e_hk4e_token};${ck}`
const badge_region = await this.getServer(uid)
const isCN = uid.toString().match(/^[125]/) ? true : false
const game_biz = isCN ? 'hk4e_cn' : 'hk4e_global'
const headers = { 'Cookie': cookie }
const url = `https://hk4e-api.mihoyo.com/event/birthdaystar/account/post_my_draw?lang=zh-cn&badge_uid=${uid}&badge_region=${badge_region}&game_biz=${game_biz}&activity_id=20220301153521`
const headers = { Cookie: `e_hk4e_token=${e_hk4e_token};${ck}` }
const url = `https://hk4e-api.mihoyo.com/event/birthdaystar/account/post_my_draw?lang=zh-cn&badge_uid=${uid}&badge_region=${this.region}&game_biz=${this.game_biz}&activity_id=20220301153521`
const body = JSON.stringify({ role_id: Number(role_id) })
let res = await fetch(url, { method: "POST", body, headers })
let res = await fetch(url, { method: 'POST', body, headers })
res = await res.json()
if (res.retcode != 0) {
return res.message
} else {
return 'success'
}
if (res.retcode != 0) return res.message
else return 'success'
}
}

View File

@ -55,7 +55,7 @@ export default class MysInfo {
return false
}
if (!['1', '2', '5', '6', '7', '8', '9'].includes(String(mysInfo.uid)[0])) {
if (!['1', '2', '3', '5', '6', '7', '8', '9'].includes(String(mysInfo.uid)[0])) {
// e.reply('只支持查询国服uid')
return false
}
@ -103,7 +103,7 @@ export default class MysInfo {
}
let matchUid = (msg = '') => {
let ret = /[125-9][0-9]{8}/g.exec(msg)
let ret = /[1235-9][0-9]{8}/g.exec(msg)
if (!ret) return false
return ret[0]
}

View File

@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
<link rel="preload" href="{{pluResPath}}script/qrcode.min.js" as="script"/>
</head>
<body>
<svg style="display: none">
@ -122,7 +123,7 @@
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
</div>
</body>
<script type="text/javascript" src="{{pluResPath}}html/mysNews/qrcode.min.js"></script>
<script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script>
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱

View File

@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<link rel="shortcut icon" href="#" />
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
<link rel="preload" href="{{pluResPath}}script/qrcode.min.js" as="script"/>
</head>
<body>
<svg style="display: none">
@ -122,7 +123,7 @@
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
</div>
</body>
<script type="text/javascript" src="{{pluResPath}}html/mysNews/qrcode.min.js"></script>
<script type="text/javascript" src="{{pluResPath}}script/qrcode.min.js"></script>
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱

File diff suppressed because one or more lines are too long