#上传深渊使用图片渲染深渊结果,同时可被#喵喵深渊触发

* 可展示本期深渊的全部角色信息,包括组队、天赋及圣遗物
* 数据会上传至胡桃Api进行伤害排名,并展示在页面内
* 可在`#喵喵设置`中启用`#喵喵深渊`作为默认深渊功能,默认关闭
This commit is contained in:
yoimiya-kokomi 2022-08-03 03:12:07 +08:00
parent 3541578ed6
commit 7939de8291
15 changed files with 256 additions and 98 deletions

View File

@ -1,9 +1,11 @@
# 1.9.3
# 1.9.4
* `#上传深渊数据`使用图片渲染深渊结果
* 功能尚未完全稳定,如遇问题可反馈
* `#上传深渊`使用图片渲染深渊结果,同时可被`#喵喵深渊`触发
* 可展示本期深渊的全部角色信息,包括组队、天赋及圣遗物
* 数据会上传至胡桃Api进行伤害排名并展示在页面内
* 可在`#喵喵设置`中启用`#喵喵深渊`作为默认深渊功能,默认关闭
# 1.9.2
# 1.9.1 ~ 1.9.3
* `#更新面板`支持配置更新API适配Enka新校验逻辑
* B服角色使用Enka服务进行面板信息获取

View File

@ -17,6 +17,10 @@ export class miao extends plugin {
})
}
get log () {
return !!this.isDispatch
}
accept () {
this.e.original_msg = this.e.original_msg || this.e.msg
}
@ -41,6 +45,7 @@ export class miao extends plugin {
render
})
if (ret === true) {
this.isDispatch = true
return true
}
}

View File

@ -13,6 +13,7 @@ let cfgMap = {
查他人: 'char.queryOther',
图鉴: 'wiki.wiki',
图片: 'wiki.pic',
统计: 'wiki.stat',
深渊: 'wiki.abyss',
渲染: 'sys.scale',
帮助: 'sys.help'
@ -90,7 +91,8 @@ export async function sysCfg (e, { render }) {
other: getStatus('char.queryOther'),
wiki: getStatus('wiki.wiki'),
pic: getStatus('wiki.pic'),
abyss: getStatus('wiki.abyss'),
stat: getStatus('wiki.stat'),
abyss: getStatus('wiki.abyss', false),
imgPlus: fs.existsSync(plusPath),
help: getStatus('sys.help', false),
scale: Cfg.get('sys.scale', 100)

View File

@ -105,7 +105,7 @@ let rule = {
describe: '【#日历】 活动日历'
},
uploadData: {
reg: '^#上传(深渊|数据)+$'
reg: '^#*[喵喵|上传|本期]*(深渊|深境|深境螺旋)[上期|往期|本期]*[第]*(9|10|11|12|九|十|十一|十二)?层?[ |0-9]*(数据)?$'
},
...adminRule
}

View File

@ -11,7 +11,7 @@ import Abyss from '../components/models/Abyss.js'
import Avatars from '../components/models/Avatars.js'
export async function consStat (e, { render }) {
if (Cfg.isDisable(e, 'wiki.abyss')) {
if (Cfg.isDisable(e, 'wiki.stat')) {
return
}
@ -91,7 +91,7 @@ export async function consStat (e, { render }) {
}
export async function abyssPct (e, { render }) {
if (Cfg.isDisable(e, 'wiki.abyss')) {
if (Cfg.isDisable(e, 'wiki.stat')) {
return
}
@ -395,13 +395,17 @@ export async function abyssTeam (e, { render }) {
}
export async function uploadData (e, { render }) {
let isMatch = /^#(喵喵|上传)深渊(数据)?$/.test(e.original_msg || e.msg || '')
if (!Cfg.get('wiki.abyss', false) && !isMatch) {
return false
}
let MysApi = await e.getMysApi({
auth: 'cookie',
targetType: 'self',
cookieType: 'self',
action: '获取信息'
})
if (!MysApi) return
if (!MysApi) return true
let ret = {}
let uid = e.selfUser.uid
let resDetail, resAbyss
@ -441,7 +445,7 @@ export async function uploadData (e, { render }) {
let char = Character.get(ds.avatarId)
tmp.title = title
tmp.id = char.id
tmp.value = `${(ds.value / 10000).toFixed(1)}W`
tmp.value = `${(ds.value / 10000).toFixed(1)} W`
let msg = []
tmp.msg = msg
let pct = (percent, name) => {
@ -470,7 +474,8 @@ export async function uploadData (e, { render }) {
abyss: abyss.getData(),
avatars: avatarData,
stat,
save_id: uid
save_id: uid,
uid
}, { e, render, scale: 1.8 })
} else {
e.reply('暂未获得本期深渊挑战数据...')

View File

@ -9,6 +9,7 @@ export const render = async function (path, params, cfg) {
let base64 = await render(paths[0], paths[1], {
...params,
_layout_path: layoutPath,
_tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/',
defaultLayout: layoutPath + 'default.html',
elemLayout: layoutPath + 'elem.html',
sys: {

View File

@ -53,10 +53,15 @@ export default class Abyss extends Base {
}, (key, dst) => {
stat[dst] = Data.getData(data[key] ? data[key][0] : [], keys)
})
let st = moment(new Date(data.start_time * 1000))
this.schedule = st.format('M') + '月' + (st.format('D') * 1 > 1 ? '下半' : '上半')
this.maxFloor = data.max_floor
this.total = data.total_battle_times
this.time = moment().format('MM-DD HH:mm:ss')
}
getData (floor) {
return Data.getData(this, 'reveral,stat,floors')
return Data.getData(this, 'reveral,stat,floors,time,schedule,maxFloor,total')
}
getAvatars () {

View File

@ -82,7 +82,7 @@ export default class Avatars extends Base {
lodash.forEach(skillRet, (talent) => {
avatarTalent[talent.id] = talent
})
await redis.set(`genshin:avatar-talent:${this.uid}`, JSON.stringify(avatarTalent), { EX: 3600 * 2 })
await redis.set(`genshin:avatar-talent:${this.uid}`, JSON.stringify(avatarTalent), { EX: 3600 * 6 })
}
let ret = this.getData(ids)
lodash.forEach(ret, (avatar, id) => {

View File

@ -8,9 +8,12 @@ if (isV3) {
index = await Data.importModule('/plugins/miao-plugin/adapter', 'index.js')
}
export const miao = index.miao || {}
Bot.logger.info(`--------------------------`)
Bot.logger.info(`喵喵插件${currentVersion}初始化~`)
Bot.logger.info(`--------------------------`)
if (Bot?.logger?.info) {
Bot.logger.info(`---------^_^---------`)
Bot.logger.info(`喵喵插件${currentVersion}初始化~`)
} else {
console.log(`喵喵插件${currentVersion}初始化~`)
}
setTimeout(async function () {
let msgStr = await redis.get('miao:restart-msg')

View File

@ -64,11 +64,19 @@
</li>
<li class="cfg-li">
<div class="cfg-line">
深渊资料
深渊统计
<span class="cfg-hint"> #喵喵设置统计 + 开启/关闭</span>
{{@stat}}
</div>
<div class="cfg-desc">角色持有率、深渊出场率、深渊配队等统计信息</div>
</li>
<li class="cfg-li">
<div class="cfg-line">
上传深渊
<span class="cfg-hint"> #喵喵设置深渊 + 开启/关闭</span>
{{@abyss}}
</div>
<div class="cfg-desc">角色持有率、深渊出场率、深渊配队等统计信息</div>
<div class="cfg-desc">使用【#上传深渊】功能取代【#深渊】功能,默认关闭</div>
</li>
<li class="cfg-li">
<div class="cfg-line">

View File

@ -162,6 +162,7 @@
.avatar-card {
margin: 3px;
box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.8);
font-size: 13px;
}
.avatar-card .card {
border-radius: 7px;
@ -174,10 +175,11 @@
.avatar-card .avatar-face {
width: 70px;
height: 70px;
border-radius: 7px 7px 20px 0;
border-radius: 7px 7px 15px 0;
background-size: 100%;
background-repeat: no-repeat;
position: relative;
box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.5);
}
.avatar-card .avatar-face .img {
background-position: center bottom;
@ -193,6 +195,7 @@
left: 0;
padding: 2px 5px 2px 3px;
border-radius: 0 4px 0 0;
color: #fff;
}
.avatar-card .avatar-talent {
height: 21px;

View File

@ -26,6 +26,7 @@
.avatar-card {
margin: 3px;
box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.8);
font-size: 13px;
.card {
@ -40,10 +41,11 @@
.avatar-face {
width: 70px;
height: 70px;
border-radius: 7px 7px 20px 0;
border-radius: 7px 7px 15px 0;
background-size: 100%;
background-repeat: no-repeat;
position: relative;
box-shadow: 0 0 2px 0 rgba(0, 0, 0, .5);
.img {
background-position: center bottom;
@ -61,6 +63,7 @@
left: 0;
padding: 2px 5px 2px 3px;
border-radius: 0 4px 0 0;
color: #fff;
}

View File

@ -5,9 +5,20 @@ body,
.container {
padding: 5px 0 10px 5px;
}
.head-box {
margin-top: 0;
padding-top: 0;
}
.head-box .title span {
font-size: 20px;
margin-left: 5px;
}
.abyss-stat-cont {
display: flex;
padding: 25px 5px 5px;
}
.abyss-stat {
display: flex;
padding: 5px;
}
.abyss-stat .cont {
margin: 5px;
@ -44,41 +55,63 @@ body,
}
.abyss-stat .stat-msg .msg {
display: block;
line-height: 22px;
}
.abyss-stat .stat-msg .msg strong {
font-size: 15px;
font-size: 16px;
padding: 0 2px;
font-weight: normal;
color: #d3bc8e;
}
.abyss-stat .abyss-notice {
width: 325px;
}
.abyss-stat .abyss-notice .cont-body {
height: 221px;
}
.abyss-stat .abyss-notice ul {
padding-left: 0;
}
.abyss-stat .abyss-notice ul li {
margin-bottom: 13px;
list-style: none;
margin-left: 0;
font-size: 13px;
}
.avatar-banner {
margin-top: -10px;
margin-top: -20px;
height: 270px;
width: 158px;
width: 175px;
background-repeat: no-repeat;
background-size: 100% auto;
background-position: top center;
}
.cont-title .abyss-star {
.abyss-data {
display: flex;
padding: 0 6px;
}
.abyss-data .abyss-item {
color: #fff;
margin: 5px;
}
.abyss-data .abyss-item .info {
text-align: center;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
}
.abyss-data .abyss-item .info strong {
display: block;
font-weight: normal;
font-family: NZBZ, YS2, sans-serif;
}
.abyss-data .abyss-item .info span {
font-size: 24px;
display: block;
}
.abyss-data .abyss-item .info span:after {
content: "次";
font-size: 15px;
margin-left: 2px;
}
.abyss-title {
margin: -3px 0 8px;
}
.abyss-title strong {
color: #d3bc8e;
font-size: 18px;
font-family: Number, NZBZ, YS2, sans-serif;
font-weight: normal;
margin-right: 10px;
}
.abyss-title .abyss-star {
font-size: 15px;
color: #fff;
}
.cont-title .abyss-star:before {
.abyss-title .abyss-star:before {
content: "";
vertical-align: bottom;
display: inline-block;
@ -181,4 +214,16 @@ body,
height: 20px;
margin: 2px;
}
.avatar-banner.avatar-枫原万叶 {
background-position: 0 60px;
}
.avatar-banner.avatar-九条裟罗 {
background-position: 0 30px;
}
.avatar-banner.avatar-香菱 {
background-position: 0 80px;
}
.avatar-banner.avatar-行秋 {
background-position: 0 70px;
}
/*# sourceMappingURL=abyss-summary.css.map */

View File

@ -9,47 +9,57 @@
{{block 'main'}}
{{ set upDown = {up:'上半', down:'下半'} }}
<div class="info_box">
<div class="head-box type">
<div class="title">上传深渊数据</div>
<img class="genshin_logo" src="{{_res_path}}/common/cont/logo.png"/>
</div>
<div class="abyss-stat">
{{each stat ds}}
{{set avatar = avatars[ds.id]}}
<div class="cont">
<div class="stat-title">
<span>{{ds.title}}</span>
<strong>{{ds.value}}</strong>
<div class="abyss-stat-cont">
<div>
<div class="head-box type">
<div class="title">喵喵深渊<span>{{abyss.schedule}}</span></div>
<div class="label">UID:{{uid}} <span>· {{abyss.total}}次战斗</span></div>
</div>
<div class="avatar-banner"
style="background-image:url({{_res_path}}/meta/character/{{avatar.name}}/gacha_card.png)"></div>
<div class="stat-msg">
{{each ds.msg msg}}
<div class="msg">{{msg.title}}<strong>{{msg.value}}%</strong>的{{msg.name}}</div>
<div class="abyss-data cont">
{{set st = abyss?.stat || {} }}
{{set dataMap = {defeat:"最多击破",e:"元素战技",q:"元素爆发"} }}
{{each dataMap title key}}
<div class="abyss-item">
<div class="info">
<strong>{{title}}</strong>
<span>{{st[key]?.value}}</span>
</div>
<% include(_tpl_path+'/avatar-card.html', [avatars[st[key]?.id],{_res_path}]) %>
</div>
{{/each}}
</div>
</div>
{{/each}}
<div class="cont abyss-notice">
<div class="cont-title">多谢支持,(>ω<*)喵~</div>
<div class="cont-body">
<ul class="cont-msg">
<li>本次深渊记录上传成功</li>
<li>仅会上传您的角色列表及当期深渊挑战数据,<strong>不会上传其他额外信息</strong></li>
<li>上传的数据将会用于<strong>#深渊使用率</strong><strong>#角色持有率</strong>等统计</li>
<li>统计服务由SG团队<strong>胡桃API</strong>提供</li>
<li>排行为本期排行,会随时间而更新,数据仅供娱乐</li>
</ul>
<div class="abyss-stat">
{{each stat ds}}
{{set avatar = avatars[ds.id]}}
<div class="cont">
<div class="stat-title">
<span>{{ds.title}}</span>
<strong>{{ds.value}}</strong>
</div>
<div class="avatar-banner avatar-{{avatar.name}}"
style="background-image:url({{_res_path}}/meta/character/{{avatar.name}}/gacha_card.png)"></div>
<div class="stat-msg">
{{each ds.msg msg}}
<div class="msg">{{msg.title}}<strong>{{msg.value}}%</strong>的{{msg.name}}</div>
{{/each}}
</div>
</div>
{{/each}}
</div>
</div>
{{each abyss?.floors floor}}
<div class="cont">
<div class="cont-title">
第{{floor.index}}层
<span class="abyss-star">{{floor.star}}/9</span>
</div>
<div class="cont-body">
<div class="abyss-title">
<strong>第{{floor.index}}层</strong>
<span class="abyss-star">{{floor.star}}/9</span>
</div>
<div class="abyss-floor-team">
<div class="abyss-team">
{{each floor.display.up.avatars id}}
@ -59,7 +69,7 @@
<div class="line"></div>
<div class="abyss-team">
{{each floor.display.down.avatars id}}
<% include(_layout_path+'../tpl/avatar-card.html', [avatars[id],{_res_path}]) %>
<% include(_tpl_path+'/avatar-card.html', [avatars[id],{_res_path}]) %>
{{/each}}
</div>
</div>
@ -93,6 +103,14 @@
</div>
{{/each}}
<div class="cont abyss-notice">
<div class="cont-body">
<ul class="cont-msg">
<li><strong>#上传深渊</strong>会上传你的角色列表及当期深渊挑战数据,<strong>不会上传其他信息</strong>,感谢支持,喵~</li>
<li>统计服务由SG团队<strong>胡桃API</strong>提供,上传的数据将会用于排名以及<strong>#深渊使用率</strong><strong>#角色持有率</strong>等统计</li>
<li>深渊排行为本期深渊排行,更新时间{{abyss.time}}。排名会随时间而更新,数据排名仅供娱乐~</li>
</ul>
</div>
</div>
</div>
{{/block}}

View File

@ -6,9 +6,25 @@ body, .container {
padding: 5px 0 10px 5px;
}
.head-box {
margin-top: 0;
padding-top: 0;
.title {
span {
font-size: 20px;
margin-left: 5px;
}
}
}
.abyss-stat-cont {
display: flex;
padding: 25px 5px 5px;
}
.abyss-stat {
display: flex;
padding: 5px;
.cont {
margin: 5px;
@ -50,47 +66,71 @@ body, .container {
.msg {
display: block;
line-height: 22px;
strong {
font-size: 15px;
font-size: 16px;
padding: 0 2px;
font-weight: normal;
color: #d3bc8e;
}
}
}
.abyss-notice {
width: 325px;
.cont-body {
height: 221px;
}
ul {
padding-left: 0;
li {
margin-bottom: 13px;
list-style: none;
margin-left: 0;
font-size: 13px;
}
}
}
}
.avatar-banner {
margin-top: -10px;
margin-top: -20px;
height: 270px;
width: 158px;
width: 175px;
background-repeat: no-repeat;
background-size: 100% auto;
background-position: top center;
}
.abyss-data {
display: flex;
padding: 0 6px;
.abyss-item {
color: #fff;
margin: 5px;
.info {
text-align: center;
text-shadow: 0 0 1px #000, 1px 1px 3px #000;
strong {
display: block;
font-weight: normal;
font-family: NZBZ, YS2, sans-serif;
}
span {
font-size: 24px;
display: block;
&:after {
content: "次";
font-size: 15px;
margin-left: 2px;
}
}
}
}
}
.abyss-title {
margin: -3px 0 8px;
strong {
color: #d3bc8e;
font-size: 18px;
font-family: Number, NZBZ, YS2, sans-serif;
font-weight: normal;
margin-right: 10px;
}
.cont-title {
.abyss-star {
font-size: 15px;
color: #fff;
@ -222,4 +262,22 @@ body, .container {
}
}
}
}
.avatar-banner {
&.avatar-枫原万叶 {
background-position: 0 60px;
}
&.avatar-九条裟罗 {
background-position: 0 30px;
}
&.avatar-香菱 {
background-position: 0 80px;
}
&.avatar-行秋 {
background-position: 0 70px;
}
}