miao-plugin/components/profile-data/enka.js
yoimiya-kokomi 67394bf623 增加#添加刻晴图像命令,感谢 **@叶**
* 可通过命令上传添加指定角色图片,上传至 **resources/character-img/刻晴/upload**
* 请将图像与命令一同发送,后续会支持at图像及命令后发送图像
部分功能的页面文案及功能优化
2022-06-28 04:46:49 +08:00

28 lines
845 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import fetch from "node-fetch";
import Data from "./enka-data.js";
let Enka = {
key: "enka",
cd: 5,
async request({ e, uid, avatar, config }) {
let profileApi = config.enkaApi || function ({ uid }) {
return `https://enka.shinshin.moe/u/${uid}/__data.json`
};
let api = profileApi({ uid, avatar });
let req = await fetch(api);
let data = await req.json();
if (!data.playerInfo) {
e.reply(`请求失败:${data.msg || "可能是面板服务并发过高,请稍后重试"}`);
return false;
}
let details = data.avatarInfoList;
if (!details || details.length === 0 || !details[0].propMap) {
e.reply(`请打开游戏内角色展柜的“显示详情”后等待5分钟重新获取面板`);
return false;
}
return Data.getData(uid, data);
}
}
export default Enka;