支持官服uid3开头,去除重复script文件
This commit is contained in:
parent
bef9fb70e9
commit
2f72a05ad2
|
@ -3,7 +3,7 @@ import gsCfg from '../model/gsCfg.js'
|
||||||
import fetch from 'node-fetch'
|
import fetch from 'node-fetch'
|
||||||
|
|
||||||
export class takeBirthdayPhoto extends plugin {
|
export class takeBirthdayPhoto extends plugin {
|
||||||
constructor() {
|
constructor () {
|
||||||
super({
|
super({
|
||||||
name: '留影叙佳期',
|
name: '留影叙佳期',
|
||||||
dsc: '留影叙佳期',
|
dsc: '留影叙佳期',
|
||||||
|
@ -21,7 +21,7 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
async birthdaystar(e) {
|
async birthdaystar (e) {
|
||||||
const { user_id } = e
|
const { user_id } = e
|
||||||
|
|
||||||
const userInfo = await this.getCookie(user_id)
|
const userInfo = await this.getCookie(user_id)
|
||||||
|
@ -32,6 +32,9 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
return true
|
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)
|
const e_hk4e_token = await this.getEHK4EToken(userInfo.ck, userInfo.uid)
|
||||||
if (!e_hk4e_token) {
|
if (!e_hk4e_token) {
|
||||||
e.reply(['获取e-hk4e_token失败,请刷新ck后再试~', this.button], true)
|
e.reply(['获取e-hk4e_token失败,请刷新ck后再试~', this.button], true)
|
||||||
|
@ -48,6 +51,7 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
e.reply(['今天没有生日角色哦~', this.button], true)
|
e.reply(['今天没有生日角色哦~', this.button], true)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const role of birthday_star_list) {
|
for (const role of birthday_star_list) {
|
||||||
await e.reply(`正在获取${role.name}的图片,请稍等~`, true)
|
await e.reply(`正在获取${role.name}的图片,请稍等~`, true)
|
||||||
|
@ -68,29 +72,26 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
async getCookie(user_id) {
|
async getCookie (user_id) {
|
||||||
const userInfo = ((await gsCfg.getBingCk()).ckQQ)[user_id]
|
const userInfo = ((await gsCfg.getBingCk()).ckQQ)[user_id]
|
||||||
return userInfo
|
return userInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
async getEHK4EToken(ck, uid) {
|
async getEHK4EToken (ck, uid) {
|
||||||
const isCN = uid.toString().match(/^[125]/) ? true : false
|
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 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 headers = {
|
const headers = {
|
||||||
'Cookie': ck,
|
Cookie: ck,
|
||||||
'Content-Type': 'application/json;charset=UTF-8',
|
'Content-Type': 'application/json;charset=UTF-8',
|
||||||
'Referer': 'https://webstatic.mihoyo.com/',
|
Referer: 'https://webstatic.mihoyo.com/',
|
||||||
'Origin': 'https://webstatic.mihoyo.com'
|
Origin: 'https://webstatic.mihoyo.com'
|
||||||
}
|
}
|
||||||
const body = JSON.stringify({
|
const body = JSON.stringify({
|
||||||
uid: Number(uid),
|
uid: Number(uid),
|
||||||
game_biz: game_biz,
|
game_biz: this.game_biz,
|
||||||
lang: 'zh-cn',
|
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]
|
const e_hk4e_token = res.headers.get('set-cookie').match(/e_hk4e_token=(.*?);/)[1]
|
||||||
res = await res.json()
|
res = await res.json()
|
||||||
if (res.retcode != 0) {
|
if (res.retcode != 0) {
|
||||||
|
@ -99,7 +100,7 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
return e_hk4e_token
|
return e_hk4e_token
|
||||||
}
|
}
|
||||||
|
|
||||||
async getServer(uid) {
|
async getServer (uid) {
|
||||||
switch (String(uid)[0]) {
|
switch (String(uid)[0]) {
|
||||||
case '1':
|
case '1':
|
||||||
case '2':
|
case '2':
|
||||||
|
@ -118,32 +119,22 @@ export class takeBirthdayPhoto extends plugin {
|
||||||
return 'cn_gf01'
|
return 'cn_gf01'
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBirthdayStar(uid, e_hk4e_token, ck) {
|
async getBirthdayStar (uid, e_hk4e_token, ck) {
|
||||||
const cookie = `e_hk4e_token=${e_hk4e_token};${ck}`
|
const headers = { Cookie: `e_hk4e_token=${e_hk4e_token};${ck}` }
|
||||||
const badge_region = await this.getServer(uid)
|
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`
|
||||||
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`
|
|
||||||
let res = await fetch(url, { headers })
|
let res = await fetch(url, { headers })
|
||||||
res = await res.json()
|
res = await res.json()
|
||||||
return res.data.role
|
return res.data.role
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBirthdayStarImg(uid, e_hk4e_token, ck, role_id) {
|
async getBirthdayStarImg (uid, e_hk4e_token, ck, role_id) {
|
||||||
const cookie = `e_hk4e_token=${e_hk4e_token};${ck}`
|
const headers = { Cookie: `e_hk4e_token=${e_hk4e_token};${ck}` }
|
||||||
const badge_region = await this.getServer(uid)
|
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 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 body = JSON.stringify({ role_id: Number(role_id) })
|
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()
|
res = await res.json()
|
||||||
if (res.retcode != 0) {
|
|
||||||
return res.message
|
if (res.retcode != 0) return res.message
|
||||||
} else {
|
else return 'success'
|
||||||
return 'success'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ export default class MysInfo {
|
||||||
return false
|
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')
|
// e.reply('只支持查询国服uid')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ export default class MysInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
let matchUid = (msg = '') => {
|
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
|
if (!ret) return false
|
||||||
return ret[0]
|
return ret[0]
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
||||||
<link rel="shortcut icon" href="#" />
|
<link rel="shortcut icon" href="#" />
|
||||||
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
|
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
|
||||||
|
<link rel="preload" href="{{pluResPath}}script/qrcode.min.js" as="script"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<svg style="display: none">
|
<svg style="display: none">
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
|
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</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">
|
<script type="text/javascript">
|
||||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||||
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱
|
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
|
||||||
<link rel="shortcut icon" href="#" />
|
<link rel="shortcut icon" href="#" />
|
||||||
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
|
<link rel="stylesheet" type="text/css" href="{{pluResPath}}html/mysNews/mysNews.css"/>
|
||||||
|
<link rel="preload" href="{{pluResPath}}script/qrcode.min.js" as="script"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<svg style="display: none">
|
<svg style="display: none">
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
|
<!-- <div class="logo">Created By Miao-Yunzai</div> -->
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</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">
|
<script type="text/javascript">
|
||||||
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
var qrcode = new QRCode(document.getElementById("qrcode"), {
|
||||||
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱
|
text: "https://bbs.mihoyo.com/ys/article/{{data.post.post_id}}", // 内容可以是文字,链接,邮箱
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue