抽卡记录增加颜色,fix 抽卡统计获取uid和暂无抽卡记录提示 (#269)

* 抽卡记录增加颜色
fix 暂无抽卡记录提示

* fix 抽卡统计获取uid

* 星铁抽卡记录增加颜色
This commit is contained in:
story-x 2023-10-09 02:46:03 +08:00 committed by GitHub
parent 990f932ce6
commit ec9d2a6e92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 99 additions and 52 deletions

View File

@ -32,7 +32,7 @@ export class gcLog extends plugin {
fnc: 'logJson' fnc: 'logJson'
}, },
{ {
reg: '^#*(原神|星铁)?(全部)?(抽卡|抽奖|角色|武器|常驻|up|新手|光锥)池*(记录|祈愿|分析)$', reg: '^#*(原神|星铁)?(全部)?(抽卡|抽奖|角色|武器|常驻|up|新手|光锥|全部)池*(记录|祈愿|分析)$',
fnc: 'getLog' fnc: 'getLog'
}, },
{ {

View File

@ -58,7 +58,7 @@ export default class GachaLog extends base {
if (i <= 1) await common.sleep(500) if (i <= 1) await common.sleep(500)
} }
MakeMsg.push(tmpMsg) MakeMsg.push(tmpMsg)
MakeMsg.push(`\n抽卡记录更新完成,您还可回复\n${this?.e?.isSr ? '*' : '#'}全部抽卡记录】展示全部抽卡数据\n${this?.e?.isSr ? '*光锥' : '#武器'}记录】统计${this?.e?.isSr ? '星铁光锥' : '武器'}池数据\n${this?.e?.isSr ? '*' : '#'}角色统计】按卡池统计数据\n【#导出记录】导出记录数据`) MakeMsg.push(`\n抽卡记录更新完成,您还可回复\n${this?.e?.isSr ? '*' : '#'}全部记录】统计全部抽卡数据\n${this?.e?.isSr ? '*光锥' : '#武器'}记录】统计${this?.e?.isSr ? '星铁光锥' : '武器'}池数据\n${this?.e?.isSr ? '*' : '#'}角色统计】按卡池统计数据\n${this?.e?.isSr ? '' : '【#导出记录】导出记录数据'}`)
await this.e.reply(MakeMsg) await this.e.reply(MakeMsg)
this.isLogUrl = true this.isLogUrl = true
@ -471,19 +471,20 @@ export default class GachaLog extends base {
async getUid () { async getUid () {
if (!fs.existsSync(this.path)) { if (!fs.existsSync(this.path)) {
this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true }) this.e.reply(`暂无抽卡记录\n${this.e?.isSr ? '*' : '#'}记录帮助,查看配置说明`, false, { at: true })
return false return false
} }
let logs = fs.readdirSync(this.path) let logs = fs.readdirSync(this.path)
if (lodash.isEmpty(logs)) { if (lodash.isEmpty(logs)) {
this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true }) this.e.reply(`暂无抽卡记录\n${this.e?.isSr ? '*' : '#'}记录帮助,查看配置说明`, false, { at: true })
return false return false
} }
this.uid = this?.e?.isSr ? this.e.user?._games?.sr?.uid : this.e.user?._games?.gs?.uid
if (!this.uid) { if (!this.uid) {
this.uid = await redis.get(this.uidKey) this.e.at = false
this.uid = this?.e?.isSr ? this.e.user?._games?.sr?.uid : this.e.user?._games?.gs?.uid || await this.e.runtime.getUid(this.e) || await redis.get(this.uidKey)
} }
/** 记录有绑定的uid */ /** 记录有绑定的uid */
@ -716,6 +717,7 @@ export default class GachaLog extends base {
/** 渲染数据 */ /** 渲染数据 */
randData (data) { randData (data) {
const max = this.type === 12 || this.type === 302 ? 80 : 90
let line = [] let line = []
let weapon = this.e.isSr ? '光锥' : '武器' let weapon = this.e.isSr ? '光锥' : '武器'
if ([301, 11].includes(this.type)) { if ([301, 11].includes(this.type)) {
@ -790,7 +792,8 @@ export default class GachaLog extends base {
lastTime: data.lastTime, lastTime: data.lastTime,
fiveLog: data.fiveLog, fiveLog: data.fiveLog,
line, line,
hasMore hasMore,
max
} }
} }

View File

@ -104,11 +104,11 @@ export default class LogCount extends base {
this.type = this.e.isSr ? 12 : 302 this.type = this.e.isSr ? 12 : 302
this.typeName = this.e.isSr ? '光锥' : '武器' this.typeName = this.e.isSr ? '光锥' : '武器'
break break
case "光锥": case '光锥':
this.type = 12 this.type = 12
this.typeName = '光锥' this.typeName = '光锥'
break break
case "新手": case '新手':
this.type = this.e.isSr ? 2 : 100 this.type = this.e.isSr ? 2 : 100
this.typeName = '新手' this.typeName = '新手'
break break
@ -117,18 +117,21 @@ export default class LogCount extends base {
async getUid () { async getUid () {
if (!fs.existsSync(this.path)) { if (!fs.existsSync(this.path)) {
this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true }) this.e.reply(`暂无抽卡记录\n${this.e?.isSr ? '*' : '#'}记录帮助,查看配置说明`, false, { at: true })
return false return false
} }
let logs = fs.readdirSync(this.path) let logs = fs.readdirSync(this.path)
if (lodash.isEmpty(logs)) { if (lodash.isEmpty(logs)) {
this.e.reply('暂无抽卡记录\n#记录帮助,查看配置说明', false, { at: true }) this.e.reply(`暂无抽卡记录\n${this.e?.isSr ? '*' : '#'}记录帮助,查看配置说明`, false, { at: true })
return false return false
} }
this.uid = await redis.get(this.uidKey) if (!this.uid) {
this.e.at = false
this.uid = this?.e?.isSr ? this.e.user?._games?.sr?.uid : this.e.user?._games?.gs?.uid || await this.e.runtime.getUid(this.e) || await redis.get(this.uidKey)
}
/** 记录有绑定的uid */ /** 记录有绑定的uid */
if (this.uid && logs.includes(String(this.uid))) { if (this.uid && logs.includes(String(this.uid))) {

View File

@ -353,3 +353,23 @@ body {
margin: 6px 0; margin: 6px 0;
color: #7f858a; color: #7f858a;
} }
.gold {
background: #ffeb73;
color: #6f4b00;
}
.good {
background: #168b2c;
color: #fff;
}
.normal {
background: #6939b7;
color: #fff;
}
.bad {
background: #9d3333;
color: #fff;
}

View File

@ -45,7 +45,7 @@
<div class="card_list"> <div class="card_list">
{{each fiveLog val}} {{each fiveLog val}}
<div class="item star5"> <div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}">
{{ if val.isUp && typeName == '角色' }} {{ if val.isUp && typeName == '角色' }}
<span class="minimum">UP</span> <span class="minimum">UP</span>
{{/if}} {{/if}}
@ -53,7 +53,7 @@
src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.webp" src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.webp"
onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/> onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/>
<!-- <div class="num">{{val.num}}</div>--> <!-- <div class="num">{{val.num}}</div>-->
<div class="num_name">{{val.num}}</div> <div class="num_name {{val.num<=10?'gold': (val.num<log.max*0.5 ? 'good' : (val.num<log.max*0.83) ? 'normal': 'bad')}}" >{{val.num}}</div>
</div> </div>
{{/each}} {{/each}}
</div> </div>

View File

@ -349,3 +349,24 @@ body {
margin: 6px 0; margin: 6px 0;
color: #7f858a; color: #7f858a;
} }
.gold {
background: #ffeb73;
color: #6f4b00;
}
.good {
background: #168b2c;
color: #fff;
}
.normal {
background: #6939b7;
color: #fff;
}
.bad {
background: #9d3333;
color: #fff;
}

View File

@ -46,7 +46,7 @@
<div class="card_list"> <div class="card_list">
{{each fiveLog val}} {{each fiveLog val}}
<div class="item star5"> <div class="item star5 {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}">
{{ if val.isUp && typeName == '角色' }} {{ if val.isUp && typeName == '角色' }}
<span class="minimum">UP</span> <span class="minimum">UP</span>
{{/if}} {{/if}}
@ -54,7 +54,7 @@
src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.png" src="{{pluResPath}}img/{{val.item_type=='角色'?'role':'weapon'}}/{{val.name}}.png"
onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/> onerror="whenError(this,'{{val.item_type=='角色'?'role':'weapon'}}')"/>
<!-- <div class="num">{{val.num}}</div>--> <!-- <div class="num">{{val.num}}</div>-->
<div class="num_name">{{val.num}}</div> <div class="num_name {{val.num<=10?'gold': (val.num<max*0.5 ? 'good' : (num<max*0.83) ? 'normal': 'bad')}}" >{{val.num}}</div>
</div> </div>
{{/each}} {{/each}}
</div> </div>