mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-16 04:35:42 +00:00
#老婆 卡片样式更新
This commit is contained in:
parent
37dd526065
commit
16d9f5d784
@ -1,79 +0,0 @@
|
||||
export async function userStat(e) {
|
||||
if (!await e.checkAuth({
|
||||
auth: "master"
|
||||
})) return true;
|
||||
|
||||
let ret = /\d+/.exec(e.msg)
|
||||
|
||||
if (ret && ret[0]) {
|
||||
|
||||
if (ret[0] * 1 < 100) {
|
||||
let msg = [];
|
||||
let keys = Object.keys(NoteCookie).reverse().slice(0, ret[0] * 1);
|
||||
for (let idx in keys) {
|
||||
msg.push(`QQ${keys[idx]},UID${NoteCookie[keys[idx]].uid}\n`)
|
||||
}
|
||||
e.reply(msg);
|
||||
} else {
|
||||
if (NoteCookie && NoteCookie[ret[0]]) {
|
||||
e.reply(`QQ${ret[0]}的UID是 ${NoteCookie[ret[0]].uid}`);
|
||||
} else {
|
||||
e.reply(`未查找到${ret[0]}`)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
let count = Object.keys(NoteCookie).length
|
||||
e.reply(`共有 ${count} 个用户`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export async function userStatus(e, { Models }) {
|
||||
if (!await e.checkAuth({
|
||||
auth: "master"
|
||||
})) return true;
|
||||
|
||||
let { MysUser } = Models;
|
||||
let userList = await MysUser.getAll();
|
||||
let ret = [];
|
||||
for (let idx in userList) {
|
||||
let data = userList[idx];
|
||||
ret.push(`UID:${data.uid}, Count:${data.count}`);
|
||||
}
|
||||
e.reply(ret.join("\n"));
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
export async function userCacheRebuild(e, { Models }) {
|
||||
if (!await e.checkAuth({
|
||||
auth: "master"
|
||||
})) return true;
|
||||
|
||||
|
||||
let { MysUser } = Models;
|
||||
await MysUser._delCache();
|
||||
e.reply("用户缓存已清除");
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function mysUserCk(e, { Models }) {
|
||||
if (!await e.checkAuth({
|
||||
auth: "master"
|
||||
})) return true;
|
||||
|
||||
let uid = e.msg.replace("#ck", "");
|
||||
|
||||
let { MysUser } = Models;
|
||||
let user = await MysUser.get(uid);
|
||||
|
||||
let ret = [];
|
||||
|
||||
let cookie = await user.getCookie();
|
||||
|
||||
e.reply("完成");
|
||||
return true;
|
||||
}
|
59
apps/wiki.js
Normal file
59
apps/wiki.js
Normal file
@ -0,0 +1,59 @@
|
||||
import { segment } from "oicq";
|
||||
import fs from "fs";
|
||||
import { Character } from "../components/models.js";
|
||||
|
||||
//import {wikiCharacter} from "../modules/wiki.js";
|
||||
|
||||
export async function wiki(e, { render }) {
|
||||
|
||||
const ret = /^#*(.*)(素材|技能|材料|信息|天赋|wiki|资料|命座)$/.exec(e.msg);
|
||||
|
||||
if (!ret || !ret[1]) {
|
||||
return;
|
||||
}
|
||||
if (ret[1] == "全部" && e.isMaster) {
|
||||
return await wikiCache(e);
|
||||
}
|
||||
|
||||
let char = Character.get(ret[1].trim());
|
||||
|
||||
await char.cacheImg();
|
||||
|
||||
|
||||
console.log(char);
|
||||
|
||||
return true;
|
||||
let base64 = await render("wiki", "character", {
|
||||
save_id: 'wiki-character',
|
||||
cache_id: data.Name,
|
||||
cache_time: 0,
|
||||
char
|
||||
});
|
||||
|
||||
if (base64) {
|
||||
e.reply(segment.image(`base64://${base64}`));
|
||||
}
|
||||
return true; //事件结束不再往下
|
||||
}
|
||||
|
||||
// 生成Wiki图像
|
||||
async function genWikiImg(name) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 更新图像缓存
|
||||
async function wikiCache(e) {
|
||||
const meta = JSON.parse(fs.readFileSync("./data/meta/characters.json", "utf8"));
|
||||
let count = 0;
|
||||
let data;
|
||||
console.log("开始生成角色资料缓存...")
|
||||
for (let idx in meta) {
|
||||
let base64 = await genWikiImg(meta[idx].Name);
|
||||
if (base64) {
|
||||
count++;
|
||||
console.log(`角色资料缓存: ${meta[idx].Name},count:${count}`)
|
||||
}
|
||||
}
|
||||
e.reply(`生成Wiki缓存${count}个`)
|
||||
}
|
@ -6,12 +6,12 @@ let Data = {
|
||||
/*
|
||||
* 根据指定的path依次检查与创建目录
|
||||
* */
|
||||
createDir(rootPath = "", path, includeFile = false) {
|
||||
createDir(rootPath = "", path = "", includeFile = false) {
|
||||
let pathList = path.split("/"),
|
||||
nowPath = rootPath;
|
||||
pathList.forEach((name, idx) => {
|
||||
name = name.trim();
|
||||
if (!includeFile && idx < pathList.length - 1) {
|
||||
if (!includeFile && idx <= pathList.length - 1) {
|
||||
nowPath += name + "/";
|
||||
if (name) {
|
||||
if (!fs.existsSync(nowPath)) {
|
||||
@ -89,6 +89,11 @@ let Data = {
|
||||
|
||||
getVal(target, keyFrom, defaultValue) {
|
||||
return lodash.get(target, keyFrom, defaultValue);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
export default Data;
|
||||
|
@ -1,5 +1,4 @@
|
||||
import Base from "./Base.js";
|
||||
import { roleId, abbr } from "../../../../config/genshin/roleId.js";
|
||||
import lodash from "lodash";
|
||||
import fs from "fs";
|
||||
import Data from "../Data.js";
|
||||
@ -7,6 +6,7 @@ import request from "request";
|
||||
|
||||
|
||||
let characterMap = {};
|
||||
const _path = process.cwd();
|
||||
|
||||
// 读取配置
|
||||
let characterMeta = Data.readJSON("./plugins/miao-plugin/components/meta", "characters.json")// JSON.parse(fs.readFileSync(__dirname + "../meta/characters.json", "utf8"));
|
||||
@ -52,6 +52,22 @@ class Character extends Base {
|
||||
let chcheDir = resDir + "/cache/";
|
||||
}
|
||||
|
||||
async cacheImg() {
|
||||
let cacheDir = `_path/data/cache`;
|
||||
Data.createDir(`${_path}/resources/`, `cache`)
|
||||
|
||||
let fileList = [
|
||||
...lodash.values(this.img),
|
||||
...lodash.map(lodash.values(this.talents), (d) => d.icon),
|
||||
...lodash.map(this.passiveTalents, (d) => d.icon),
|
||||
...lodash.map(lodash.values(this.cons), (d) => d.icon)
|
||||
];
|
||||
|
||||
fileList = lodash.uniq(fileList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let cacheImgFile = async function (url, cacheDir) {
|
||||
@ -105,7 +121,7 @@ let getMetaData = function (name) {
|
||||
// 处理命座信息
|
||||
let cons = {};
|
||||
lodash.forEach(meta.Constellation, (data, key) => {
|
||||
cons[key.replace("Constellation")] = Data.getData(data, "Name,icon:Source,desc:Description", metaCfg);
|
||||
cons[key.replace("Constellation", "")] = Data.getData(data, "Name,icon:Source,desc:Description", metaCfg);
|
||||
})
|
||||
ret.cons = cons;
|
||||
return ret;
|
||||
|
39
index.js
39
index.js
@ -1,7 +1,7 @@
|
||||
import { character, wife, wifeReg } from "./apps/character.js";
|
||||
import { userStat, userStatus, userCacheRebuild, mysUserCk } from "./apps/admin.js";
|
||||
import { wiki } from "./apps/wiki.js";
|
||||
|
||||
export { character, userStat, wife, userStatus, userCacheRebuild, mysUserCk };
|
||||
export { character, wife, wiki };
|
||||
|
||||
|
||||
export const rule = {
|
||||
@ -17,38 +17,9 @@ export const rule = {
|
||||
priority: 203,
|
||||
describe: "【#老婆,#老公,#女儿】角色详情",
|
||||
},
|
||||
/*
|
||||
setCharacterImg: {
|
||||
prehash: true,
|
||||
reg: "^#(添加|更新)(.*)图片(#.*)?(上|右|下|左)?$",
|
||||
priority: 208,
|
||||
},
|
||||
*/
|
||||
userStat: {
|
||||
prehash: true,
|
||||
reg: "^#*user\s*\d*",
|
||||
priority: 200
|
||||
},
|
||||
rebuildCookie: {
|
||||
prehash: true,
|
||||
reg: "#rebuild"
|
||||
},
|
||||
userStatus: {
|
||||
prehash: true,
|
||||
reg: "^#cc$",
|
||||
priority: 200
|
||||
},
|
||||
|
||||
userCacheRebuild: {
|
||||
prehash: true,
|
||||
reg: "^#dd$",
|
||||
priority: 200
|
||||
},
|
||||
mysUserCk: {
|
||||
prehash: true,
|
||||
reg: "^#ck[0-9]+$",
|
||||
priority: 200
|
||||
wiki: {
|
||||
reg: "^#*.*(天赋|技能|命座|命之座|详情)$",
|
||||
priority: 300
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
body {
|
||||
font-size: 16px;
|
||||
color: #fff;
|
||||
transform: scale(1);
|
||||
transform: scale(1.25);
|
||||
transform-origin: 0 0;
|
||||
}
|
||||
|
||||
@ -132,30 +132,42 @@ body {
|
||||
background: #666;
|
||||
}
|
||||
|
||||
|
||||
.cons_0 {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.cons_1 {
|
||||
background-color: #62a8ea;
|
||||
background-color: #71b167;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.cons_2 {
|
||||
background-color: #62a8ea;
|
||||
background-color: #369961;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.cons_3 {
|
||||
background-color: #45b97c;
|
||||
background-color: #4596b9;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.cons_4 {
|
||||
background-color: #45b97c;
|
||||
background-color: #4560b9;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.cons_5 {
|
||||
background-color: #ff5722;
|
||||
background-color: #531ba9cf;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.cons_6 {
|
||||
background-color: #ff5722;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
.crown {
|
||||
width: 30px;
|
||||
height: 30px;
|
||||
@ -183,7 +195,6 @@ body {
|
||||
}
|
||||
|
||||
.detail {
|
||||
|
||||
font-size: 26px;
|
||||
margin: 10px 5px 2px 5px;
|
||||
}
|
||||
@ -384,7 +395,7 @@ body {
|
||||
border-radius: 10px;
|
||||
background: linear-gradient(0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2)), rgba(114, 102, 104, 0.3);
|
||||
margin-left: 5px;
|
||||
margin-top: 5px;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.equiv_info .text {
|
||||
@ -394,12 +405,19 @@ body {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
-webkit-line-clamp: 2;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
body.bottom_mode {
|
||||
width: 500px;
|
||||
}
|
||||
|
||||
.bottom_mode .info {
|
||||
height: 158px;
|
||||
}
|
||||
|
||||
|
||||
.bottom_mode .weapon {
|
||||
left: 0;
|
||||
@ -449,6 +467,7 @@ body.bottom_mode {
|
||||
|
||||
.bottom_mode .detail {
|
||||
font-family: NZBZ;
|
||||
margin-top: 0px;
|
||||
}
|
||||
|
||||
.bottom_mode .for_left {
|
||||
@ -465,20 +484,20 @@ body.bottom_mode {
|
||||
.left_mode .info {
|
||||
right: initial;
|
||||
padding: 10px 10px 5px 10px;
|
||||
border-radius: 20px;
|
||||
border-radius: 8px;
|
||||
left: 10px;
|
||||
bottom: 120px;
|
||||
bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
.left_mode .weapon {
|
||||
top: 155px;
|
||||
top: -110px;
|
||||
width: 270px;
|
||||
height: 100px;
|
||||
padding: 0 0 3px 0;
|
||||
left: 0px;
|
||||
left: 0;
|
||||
background: rgba(0, 0, 0, 0.8);
|
||||
border-radius: 20px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
.left_mode .weapon_cont {
|
||||
@ -528,4 +547,27 @@ body.bottom_mode {
|
||||
.left_mode .equiv_info {
|
||||
padding: 0;
|
||||
background: none;
|
||||
margin-top: 5px;
|
||||
}
|
||||
|
||||
.copyright {
|
||||
position: absolute;
|
||||
|
||||
}
|
||||
|
||||
.left_mode .copyright {
|
||||
bottom: 5px;
|
||||
right: 9px;
|
||||
text-shadow: 1px 1px 1px #000;
|
||||
font-family: tttgbnumber;
|
||||
line-height: 20px;
|
||||
}
|
||||
|
||||
.bottom_mode .copyright {
|
||||
bottom: 1px;
|
||||
right: 7px;
|
||||
text-shadow: 1px 1px 1px #000;
|
||||
font-family: tttgbnumber;
|
||||
line-height: 20px;
|
||||
font-size: 10px;
|
||||
}
|
@ -1,58 +1,59 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<link rel="shortcut icon" href="#"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{_res_path}}/character/card.css?v=1.0"/>
|
||||
</head>
|
||||
<body class="{{bg.mode}}_mode">
|
||||
<div class="container" id="container">
|
||||
<div class="char_name">
|
||||
<div class="uid">ID:{{uid}}</div>
|
||||
<span>{{ds.name}}</span>
|
||||
<span
|
||||
class="cons cons_{{actived_constellation_num}}">{{actived_constellation_num}}命</span>
|
||||
</div>
|
||||
<div class="info">
|
||||
<div class="detail"> Lv.{{level}} ❤{{fetter}}
|
||||
<span class="crown crown_{{crownNum}}"></span>
|
||||
</div>
|
||||
|
||||
<div class="weapon">
|
||||
<div class="weapon_cont">
|
||||
<img title="{{weapon.name}}" src="{{_sys_res_path}}/genshin/logo/weapon/{{weapon.name}}.png"/>
|
||||
|
||||
<p class="weapon_lv">Lv.{{weapon.level}}</p>
|
||||
<p class="weapon_affix">{{weapon.affix_level}}</p>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
|
||||
<link rel="shortcut icon" href="#"/>
|
||||
<link rel="stylesheet" type="text/css" href="{{_res_path}}/character/card.css?v=1.0"/>
|
||||
</head>
|
||||
<body class="{{bg.mode}}_mode">
|
||||
<div class="container" id="container">
|
||||
<div class="char_name">
|
||||
<div class="uid">ID:{{uid}}</div>
|
||||
<span>{{ds.name}}</span>
|
||||
<span
|
||||
class="cons cons_{{actived_constellation_num}}">{{actived_constellation_num}}命</span>
|
||||
</div>
|
||||
<p class="weapon_name">
|
||||
<div class="info">
|
||||
<div class="detail"> Lv.{{level}} ❤{{fetter}}
|
||||
<span class="crown crown_{{crownNum}}"></span>
|
||||
</div>
|
||||
|
||||
<span class="for_left">Lv.{{weapon.level}} 精{{weapon.affix_level}}</span>
|
||||
<span class="for_bottom">精{{weapon.affix_level}} </span>
|
||||
{{weapon.name}}
|
||||
</p>
|
||||
</div>
|
||||
<div class="weapon">
|
||||
<div class="weapon_cont">
|
||||
<img title="{{weapon.name}}" src="{{_sys_res_path}}/genshin/logo/weapon/{{weapon.name}}.png"/>
|
||||
|
||||
{{ if talent.a }}
|
||||
<div class="talent">
|
||||
{{each talentMap name key}}
|
||||
<div class="talent_{{key}}">{{name}}: <span>{{ talent[key].level_current}}</span></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="talent">
|
||||
<div class="talent_{{key}}">暂无天赋信息</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
<p class="weapon_lv">Lv.{{weapon.level}}</p>
|
||||
<p class="weapon_affix">{{weapon.affix_level}}</p>
|
||||
</div>
|
||||
<p class="weapon_name">
|
||||
|
||||
<div class="equiv_info">
|
||||
<div class="text">{{text1|| "-"}}</div>
|
||||
<div class="text">{{text2 || "-"}}</div>
|
||||
<span class="for_left">Lv.{{weapon.level}} 精{{weapon.affix_level}}</span>
|
||||
<span class="for_bottom">精{{weapon.affix_level}} </span>
|
||||
{{weapon.name}}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{{ if talent.a }}
|
||||
<div class="talent">
|
||||
{{each talentMap name key}}
|
||||
<div class="talent_{{key}}">{{name}}: <span>{{ talent[key].level_current}}</span></div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="talent">
|
||||
<div class="talent_{{key}}">暂无天赋信息</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class="equiv_info">
|
||||
<div class="text">{{text1|| "-"}}</div>
|
||||
<div class="text">{{text2 || "-"}}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="copyright">Create By Yunzai-Bot & Miao-Plugin</div>
|
||||
<div>
|
||||
<img src="{{_res_path}}{{bg.img}}" title="{{name}}" class="bg"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<img src="{{_res_path}}{{bg.img}}" title="{{name}}" class="bg"></div>
|
||||
</div>
|
||||
</body>
|
||||
<script type="text/javascript"></script>
|
||||
</body>
|
||||
<script type="text/javascript"></script>
|
||||
</html>
|
||||
|
0
resources/wiki/character.html
Normal file
0
resources/wiki/character.html
Normal file
Loading…
Reference in New Issue
Block a user