补充绑定ck方法。

This commit is contained in:
Ctrlcvs 2023-05-04 10:37:13 +08:00
parent 64c61372f5
commit 973d10cda6
3 changed files with 34 additions and 27 deletions

View File

@ -98,12 +98,7 @@ export class gcLog extends plugin {
let data = await new GachaLog(this.e).logUrl() let data = await new GachaLog(this.e).logUrl()
if (!data) return if (!data) return
let url='gachaLog' let url = this.srHead('gachaLog', data)
if(this.e.isSr){
url ='StarRail/gachaLog'
data.tplFile = './plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.html'
data.headStyle = `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/StarRail/img/worldcard/星穹列车.png) #fff; background-repeat: no-repeat; background-position-x: -10px; background-size: 500px; background-position-y: -90px; }</style>`
}
let img = await puppeteer.screenshot(url, data) let img = await puppeteer.screenshot(url, data)
if (img) await this.reply(img) if (img) await this.reply(img)
} }
@ -140,12 +135,7 @@ export class gcLog extends plugin {
async getLog () { async getLog () {
let data = await new GachaLog(this.e).getLogData() let data = await new GachaLog(this.e).getLogData()
if (!data) return if (!data) return
let url='gachaLog' let url = this.srHead('gachaLog', data)
if(this.e.isSr){
url ='StarRail/gachaLog'
data.tplFile = './plugins/genshin/resources/StarRail/html/gachaLog/gachaLog.html'
data.headStyle = `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/StarRail/img/worldcard/星穹列车.png) #fff; background-repeat: no-repeat; background-position-x: -10px; background-size: 500px; background-position-y: -90px; }</style>`
}
let img = await puppeteer.screenshot(url, data) let img = await puppeteer.screenshot(url, data)
if (img) await this.reply(img) if (img) await this.reply(img)
} }
@ -215,16 +205,19 @@ export class gcLog extends plugin {
await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助-苹果.png`)) await this.e.reply(segment.image(`file:///${_path}/resources/logHelp/记录帮助-苹果.png`))
} }
} }
srHead = (url, data) => {
let name = url
if (this.e.isSr) {
name = `StarRail/${url}`
data.tplFile = `./plugins/genshin/resources/StarRail/html/${url}/${url}.html`
data.headStyle = `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/StarRail/img/worldcard/星穹列车.png) #fff; background-position-x: -10px; background-repeat: no-repeat; background-size: 540px; background-position-y: -100px; </style>`
}
return name
}
async logCount () { async logCount () {
let data = await new LogCount(this.e).count() let data = await new LogCount(this.e).count()
if (!data) return if (!data) return
let url='logCount' let url = this.srHead('logCount', data)
if(this.e.isSr){
url='StarRail/logCount'
data.tplFile = './plugins/genshin/resources/StarRail/html/logCount/logCount.html'
data.headStyle = `<style> .head_box { background: url(${this._path}/plugins/genshin/resources/StarRail/img/worldcard/星穹列车.png) #fff; background-position-x: -10px; background-repeat: no-repeat; background-size: 540px; background-position-y: -100px; }</style>`
}
let img = await puppeteer.screenshot(url, data) let img = await puppeteer.screenshot(url, data)
if (img) await this.reply(img) if (img) await this.reply(img)
} }

View File

@ -55,7 +55,7 @@ export default class GachaLog extends base {
if (i <= 1) await common.sleep(500) if (i <= 1) await common.sleep(500)
} }
await this.e.reply(`抽卡记录更新完成,您还可回复\n【#${this?.e?.isSr?'光锥':'武器'}记录】统计武器池数据\n【#角色统计】按卡池统计数据\n【#导出记录】导出记录数据`) await this.e.reply(`抽卡记录更新完成,您还可回复\n【#${this?.e?.isSr?'光锥':'武器'}记录】统计${this?.e?.isSr?'光锥':'武器'}池数据\n【#角色统计】按卡池统计数据\n【#导出记录】导出记录数据`)
this.isLogUrl = true this.isLogUrl = true

View File

@ -374,16 +374,30 @@ export default class MysUser extends BaseModel {
} }
static async getGameRole (ck, serv = 'mys') { static async getGameRole (ck, serv = 'mys') {
let biz=['hk4e_cn','hkrpg_cn']
let url = { let url = {
mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_cn', mys: 'https://api-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=',
hoyolab: 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global' hoyolab: 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz=hk4e_global'
} }
let list=[];
let res = await fetch(url[serv], { method: 'get', headers: { Cookie: ck } }) let result;
if (!res.ok) return false if(serv=='mys'){
res = await res.json() for(let item of biz){
result=await fetch(url[serv]+item, { method: 'get', headers: { Cookie: ck } })
return res if(result.ok){
result=await result.json()
if(result?.data?.list.length>0){
list.push(...result.data.list)
}
}
}
result.data.list=list
}else{
let res = await fetch(url[serv], { method: 'get', headers: { Cookie: ck } })
if (!res.ok) return false
result = await res.json()
}
return result
} }
// 获取米游社通行证id // 获取米游社通行证id