2022-05-06 21:20:14 +00:00
|
|
|
import { segment } from "oicq";
|
|
|
|
import { Character } from "../components/models.js";
|
2022-04-05 19:49:37 +00:00
|
|
|
import lodash from "lodash";
|
2022-05-22 13:10:10 +00:00
|
|
|
import Calendar from "../components/Calendar.js";
|
|
|
|
import Common from "../components/Common.js";
|
2022-06-16 20:19:27 +00:00
|
|
|
import { Cfg } from "../components/index.js";
|
2022-04-03 22:06:03 +00:00
|
|
|
|
|
|
|
|
2022-04-05 19:49:37 +00:00
|
|
|
let action = {
|
|
|
|
wiki: {
|
2022-04-08 21:52:05 +00:00
|
|
|
keyword: "命座|天赋|技能|资料|照片|写真|图片|插画"
|
2022-04-05 19:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-03 22:06:03 +00:00
|
|
|
|
|
|
|
|
2022-05-06 21:20:14 +00:00
|
|
|
export async function wiki(e, { render }) {
|
2022-04-05 19:49:37 +00:00
|
|
|
|
|
|
|
if (!e.msg) {
|
|
|
|
return false;
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
|
|
|
|
2022-04-08 21:52:05 +00:00
|
|
|
let reg = /#?(.+)(命座|命之座|天赋|技能|资料|照片|写真|图片|插画)$/, msg = e.msg;
|
2022-04-05 19:49:37 +00:00
|
|
|
let ret = reg.exec(msg);
|
|
|
|
|
2022-04-08 21:52:05 +00:00
|
|
|
if (!ret || !ret[1] || !ret[2]) {
|
2022-04-05 19:49:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
2022-04-03 22:06:03 +00:00
|
|
|
|
2022-04-07 19:39:43 +00:00
|
|
|
let mode = "talent";
|
|
|
|
if (/命/.test(ret[2])) {
|
|
|
|
mode = "cons";
|
2022-04-08 21:52:05 +00:00
|
|
|
} else if (/图|画|写真|照片/.test(ret[2])) {
|
|
|
|
mode = "pic";
|
2022-04-07 19:39:43 +00:00
|
|
|
}
|
2022-04-03 22:06:03 +00:00
|
|
|
|
2022-05-22 13:10:10 +00:00
|
|
|
if ((mode === "pic" && Common.isDisable(e, "wiki.pic"))
|
|
|
|
|| (mode !== "pic" && Common.isDisable("wiki.wiki"))) {
|
2022-04-09 21:33:21 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-04-07 19:39:43 +00:00
|
|
|
let char = Character.get(ret[1]);
|
2022-04-11 20:26:28 +00:00
|
|
|
if (!char) {
|
|
|
|
return false;
|
|
|
|
}
|
2022-04-08 21:52:05 +00:00
|
|
|
|
|
|
|
if (mode === "pic") {
|
2022-06-16 20:19:27 +00:00
|
|
|
let img = char.getCardImg(Cfg.get("char.se", false),false);
|
2022-04-08 21:52:05 +00:00
|
|
|
if (img && img.img) {
|
|
|
|
e.reply(segment.image(process.cwd() + "/plugins/miao-plugin/resources/" + img.img));
|
|
|
|
} else {
|
|
|
|
e.reply("暂无图片");
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2022-05-22 13:10:10 +00:00
|
|
|
return await Common.render("wiki/character", {
|
2022-04-05 19:49:37 +00:00
|
|
|
save_id: "天赋" + char.name,
|
|
|
|
...char,
|
2022-04-07 19:39:43 +00:00
|
|
|
mode,
|
2022-04-05 19:49:37 +00:00
|
|
|
line: getLineData(char),
|
2022-04-09 21:33:21 +00:00
|
|
|
_char: `/meta/character/${char.name}/`,
|
2022-05-22 13:10:10 +00:00
|
|
|
}, { e, render, scale: 1 });
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
|
|
|
|
2022-04-05 19:49:37 +00:00
|
|
|
const getLineData = function (data) {
|
|
|
|
let ret = [];
|
2022-04-07 21:47:05 +00:00
|
|
|
lodash.forEach(data.lvStat.detail["90"], (num, idx) => {
|
2022-04-05 19:49:37 +00:00
|
|
|
ret.push({
|
2022-04-07 21:47:05 +00:00
|
|
|
num,
|
|
|
|
label: data.lvStat.stat[idx]
|
2022-04-05 19:49:37 +00:00
|
|
|
})
|
|
|
|
})
|
2022-04-03 22:06:03 +00:00
|
|
|
|
2022-04-05 19:49:37 +00:00
|
|
|
return ret;
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 21:20:14 +00:00
|
|
|
export async function calendar(e, { render }) {
|
2022-05-22 13:10:10 +00:00
|
|
|
let calData = await Calendar.get();
|
2022-05-16 21:32:31 +00:00
|
|
|
let mode = "calendar";
|
|
|
|
if (/(日历列表|活动)$/.test(e.msg)) {
|
|
|
|
mode = "list";
|
|
|
|
}
|
2022-05-06 21:20:14 +00:00
|
|
|
|
2022-05-22 13:10:10 +00:00
|
|
|
return await Common.render("wiki/calendar", {
|
2022-05-07 21:01:18 +00:00
|
|
|
...calData,
|
2022-05-16 21:32:31 +00:00
|
|
|
displayMode: mode,
|
2022-05-22 13:10:10 +00:00
|
|
|
}, { e, render, scale: 1.1 });
|
2022-04-03 22:06:03 +00:00
|
|
|
}
|