一些查询逻辑优化及bug修复

微调部分角色圣遗物评分权重
This commit is contained in:
yoimiya-kokomi 2022-10-27 04:28:44 +08:00
parent 98282e3741
commit ed21546e82
6 changed files with 57 additions and 25 deletions

View File

@ -34,21 +34,22 @@ export async function uploadCharacterImg (e) {
imageMessages.push(val) imageMessages.push(val)
} }
} }
let source if (imageMessages.length === 0) {
if (e.isGroup) { let source
// 支持at图片添加以及支持后发送 if (e.isGroup) {
source = (await e.group.getChatHistory(e.source?.seq, 1)).pop() // 支持at图片添加以及支持后发送
} else { source = (await e.group.getChatHistory(e.source?.seq, 1)).pop()
source = (await e.friend.getChatHistory((e.source?.time + 1), 1)).pop() } else {
} source = (await e.friend.getChatHistory((e.source?.time + 1), 1)).pop()
if (source) { }
for (let val of source.message) { if (source) {
if (val.type === 'image') { for (let val of source.message) {
imageMessages.push(val) if (val.type === 'image') {
imageMessages.push(val)
}
} }
} }
} }
if (imageMessages.length <= 0) { if (imageMessages.length <= 0) {
e.reply('消息中未找到图片,请将要发送的图片与消息一同发送或引用要添加的图像..') e.reply('消息中未找到图片,请将要发送的图片与消息一同发送或引用要添加的图像..')
return true return true

View File

@ -51,13 +51,12 @@ export async function getTargetUid (e) {
} }
try { try {
let mys = await MysApi.init(e) let user = await MysApi.initUser(e)
if (!mys || !mys.uid) { if (!user || !user.uid) {
return false return false
} }
uid = user.uid
uid = mys.uid
if (!uid || !uidReg.test(uid)) { if (!uid || !uidReg.test(uid)) {
e.reply('请先发送【#绑定+你的UID】来绑定查询目标') e.reply('请先发送【#绑定+你的UID】来绑定查询目标')
return false return false

View File

@ -396,7 +396,7 @@ async function uploadData (e) {
if (!Cfg.get('wiki.abyss', false) && !isMatch) { if (!Cfg.get('wiki.abyss', false) && !isMatch) {
return false return false
} }
let mys = await MysApi.init(e, { auth: 'cookie' }) let mys = await MysApi.init(e, { auth: 'all' })
if (!mys || !mys.uid) { if (!mys || !mys.uid) {
if (isMatch) { if (isMatch) {
e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`) e.reply(`请绑定ck后再使用${e.original_msg || e.msg}`)

View File

@ -6,9 +6,35 @@ import { puppeteer } from '../../adapter/index.js'
const plugin = 'miao-plugin' const plugin = 'miao-plugin'
const _path = process.cwd() const _path = process.cwd()
// 尝试性接入,待稳定后替换
let runtimeRender = async function (e, path, params, cfg) {
return e.runtime.render('miao-plugin', path, params, {
retType: cfg.retMsgId ? 'msgId' : 'default',
beforeRender ({ data }) {
let resPath = data.pluResPath
const layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/'
return {
...data,
_res_path: resPath,
_layout_path: layoutPath,
_tpl_path: process.cwd() + '/plugins/miao-plugin/resources/common/tpl/',
defaultLayout: layoutPath + 'default.html',
elemLayout: layoutPath + 'elem.html',
sys: {
scale: Cfg.scale(cfg.scale || 1),
copyright: `Created By Yunzai-Bot<span class="version">${Version.yunzai}</span> & Miao-Plugin<span class="version">${Version.version}</span>`
}
}
}
})
}
export default async function (path, params, cfg) { export default async function (path, params, cfg) {
let [app, tpl] = path.split('/')
let { e } = cfg let { e } = cfg
if (e.runtime) {
return runtimeRender(e, path, params, cfg)
}
let [app, tpl] = path.split('/')
let layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/' let layoutPath = process.cwd() + '/plugins/miao-plugin/resources/common/layout/'
let resPath = `../../../../../plugins/${plugin}/resources/` let resPath = `../../../../../plugins/${plugin}/resources/`
Data.createDir(`data/html/${plugin}/${app}/${tpl}`, 'root') Data.createDir(`data/html/${plugin}/${app}/${tpl}`, 'root')

View File

@ -18,7 +18,12 @@ export default class MysApi {
cfg = { auth: cfg } cfg = { auth: cfg }
} }
let { auth = 'all' } = cfg let { auth = 'all' } = cfg
let mys = await YzMysInfo.init(e, auth === 'cookie' ? 'detail' : 'roleIndex') let mys = false
if (e.runtime) {
mys = await e.runtime.getMysInfo(auth)
} else {
mys = await YzMysInfo.init(e, auth === 'cookie' ? 'detail' : 'roleIndex')
}
if (!mys) { if (!mys) {
return false return false
} }

View File

@ -47,7 +47,7 @@ export const usefulAttr = {
申鹤: { hp: 0, atk: 100, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 申鹤: { hp: 0, atk: 100, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 },
云堇: { hp: 0, atk: 0, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 40, phy: 0, recharge: 90, heal: 0 }, 云堇: { hp: 0, atk: 0, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 40, phy: 0, recharge: 90, heal: 0 },
荒泷一斗: { hp: 0, atk: 50, def: 100, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 荒泷一斗: { hp: 0, atk: 50, def: 100, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 },
五郎: { hp: 0, atk: 50, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 25, phy: 0, recharge: 90, heal: 0 }, 五郎: { hp: 0, atk: 75, def: 100, cp: 50, cd: 50, mastery: 0, dmg: 100, phy: 0, recharge: 75, heal: 0 },
班尼特: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 80, phy: 0, recharge: 55, heal: 100 }, 班尼特: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 80, phy: 0, recharge: 55, heal: 100 },
枫原万叶: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 枫原万叶: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 },
行秋: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 75, heal: 0 }, 行秋: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 75, heal: 0 },
@ -72,21 +72,21 @@ export const usefulAttr = {
凝光: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 凝光: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 30, heal: 0 },
北斗: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 北斗: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 },
刻晴: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 }, 刻晴: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 },
托马: { hp: 100, atk: 50, def: 0, cp: 50, cd: 50, mastery: 0, dmg: 75, phy: 0, recharge: 90, heal: 0 }, 托马: { hp: 90, atk: 55, def: 0, cp: 90, cd: 90, mastery: 0, dmg: 90, phy: 0, recharge: 55, heal: 0 },
迪卢克: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 }, 迪卢克: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 },
诺艾尔: { hp: 0, atk: 50, def: 90, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 70, heal: 0 }, 诺艾尔: { hp: 0, atk: 50, def: 90, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 70, heal: 0 },
旅行者: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 旅行者: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 },
重云: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 重云: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 0 },
七七: { hp: 0, atk: 100, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 60, phy: 70, recharge: 55, heal: 100 }, 七七: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 55, heal: 100 },
凯亚: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 30, heal: 0 }, 凯亚: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 30, heal: 0 },
烟绯: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 烟绯: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 },
早柚: { hp: 0, atk: 50, def: 0, cp: 50, cd: 50, mastery: 100, dmg: 80, phy: 0, recharge: 55, heal: 100 }, 早柚: { hp: 0, atk: 50, def: 0, cp: 50, cd: 50, mastery: 100, dmg: 80, phy: 0, recharge: 55, heal: 100 },
安柏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 }, 安柏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 100, recharge: 0, heal: 0 },
丽莎: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 }, 丽莎: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 0, heal: 0 },
埃洛伊: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 0, heal: 0 }, 埃洛伊: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 0, heal: 0 },
辛焱: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 50, phy: 100, recharge: 0, heal: 0 }, 辛焱: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 0, heal: 0 },
砂糖: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 50, phy: 0, recharge: 55, heal: 0 }, 砂糖: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 75, phy: 0, recharge: 55, heal: 0 },
雷泽: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 50, phy: 100, recharge: 0, heal: 0 }, 雷泽: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 100, recharge: 0, heal: 0 },
夜兰: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 夜兰: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 },
久岐忍: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 100 }, 久岐忍: { hp: 100, atk: 50, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 55, heal: 100 },
鹿野院平藏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 }, 鹿野院平藏: { hp: 0, atk: 75, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 100, phy: 0, recharge: 30, heal: 0 },
@ -98,4 +98,5 @@ export const usefulAttr = {
坎蒂丝: { hp: 75, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 坎蒂丝: { hp: 75, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 100, phy: 0, recharge: 55, heal: 0 },
妮露: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 80, phy: 0, recharge: 30, heal: 0 }, 妮露: { hp: 80, atk: 0, def: 0, cp: 100, cd: 100, mastery: 75, dmg: 80, phy: 0, recharge: 30, heal: 0 },
纳西妲: { hp: 0, atk: 55, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 }, 纳西妲: { hp: 0, atk: 55, def: 0, cp: 100, cd: 100, mastery: 100, dmg: 100, phy: 0, recharge: 55, heal: 0 },
多莉: { hp: 75, atk: 75, def: 0, cp: 100, cd: 100, mastery: 0, dmg: 75, phy: 0, recharge: 55, heal: 100 }
} }