mirror of
https://github.com/yoimiya-kokomi/miao-plugin.git
synced 2024-11-21 14:38:30 +00:00
character.js 中使用新版cookie获取逻辑
This commit is contained in:
parent
db7c3de778
commit
6c026a7381
@ -1,9 +1,8 @@
|
||||
export async function userStat(e) {
|
||||
if (await e.checkAuth({
|
||||
auth: "master"
|
||||
})) return true;
|
||||
|
||||
if (!e.isMaster) {
|
||||
// e.reply("暂无权限");
|
||||
return;
|
||||
}
|
||||
let ret = /\d+/.exec(e.msg)
|
||||
|
||||
if (ret && ret[0]) {
|
||||
@ -30,10 +29,10 @@ export async function userStat(e) {
|
||||
}
|
||||
|
||||
export async function rebuildCookie(e) {
|
||||
let MysApi = await e.initMysApi({
|
||||
if (await e.checkAuth({
|
||||
auth: "master"
|
||||
});
|
||||
if (!MysApi) return true;
|
||||
})) return true;
|
||||
|
||||
|
||||
let count = 0;
|
||||
for (let qq in NoteCookie) {
|
||||
@ -49,10 +48,9 @@ export async function rebuildCookie(e) {
|
||||
}
|
||||
|
||||
export async function userStatus(e, { Models }) {
|
||||
let MysApi = await e.initMysApi({
|
||||
if (await e.checkAuth({
|
||||
auth: "master"
|
||||
});
|
||||
if (!MysApi) return true;
|
||||
})) return true;
|
||||
|
||||
let { MysUser } = Models;
|
||||
let userList = await MysUser.getAll();
|
||||
@ -68,10 +66,10 @@ export async function userStatus(e, { Models }) {
|
||||
}
|
||||
|
||||
export async function userCacheRebuild(e, { Models }) {
|
||||
let MysApi = await e.initMysApi({
|
||||
if (await e.checkAuth({
|
||||
auth: "master"
|
||||
});
|
||||
if (!MysApi) return true;
|
||||
})) return true;
|
||||
|
||||
|
||||
let { MysUser } = Models;
|
||||
await MysUser._delCache();
|
||||
@ -80,10 +78,9 @@ export async function userCacheRebuild(e, { Models }) {
|
||||
}
|
||||
|
||||
export async function mysUserCk(e, { Models }) {
|
||||
let MysApi = await e.initMysApi({
|
||||
if (await e.checkAuth({
|
||||
auth: "master"
|
||||
});
|
||||
if (!MysApi) return true;
|
||||
})) return true;
|
||||
|
||||
let uid = e.msg.replace("#ck", "");
|
||||
|
||||
@ -91,9 +88,9 @@ export async function mysUserCk(e, { Models }) {
|
||||
let user = await MysUser.get(uid);
|
||||
|
||||
let ret = [];
|
||||
console.log(user);
|
||||
|
||||
let cookie = await user.getCookie();
|
||||
console.log(cookie)
|
||||
|
||||
e.reply("完成");
|
||||
return true;
|
||||
}
|
@ -45,7 +45,7 @@ export async function character(e, { render, User }) {
|
||||
|
||||
let roleId = char.id, uid = e.targetUser.uid;
|
||||
|
||||
let charData = await MysApi.getData('character');
|
||||
let charData = await MysApi.getCharacter();
|
||||
if (!charData) return true;
|
||||
|
||||
|
||||
@ -81,7 +81,6 @@ export async function character(e, { render, User }) {
|
||||
return true; //事件结束不再往下
|
||||
}
|
||||
|
||||
|
||||
//#老婆
|
||||
export async function wife(e, { render, User }) {
|
||||
let msg = e.msg;
|
||||
@ -112,7 +111,7 @@ export async function wife(e, { render, User }) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let data = await MysApi.getData("character");
|
||||
let data = await MysApi.getCharacter();
|
||||
if (!data) return true;
|
||||
|
||||
let avatars = data.avatars;
|
||||
@ -179,9 +178,7 @@ async function getTalent(e, avatars, MysApi) {
|
||||
|
||||
let skill = {};
|
||||
|
||||
let skillres = await MysApi.getData("detail", {
|
||||
avatar_id: avatars.id,
|
||||
});
|
||||
let skillres = await MysApi.getAvatar(avatars.id);
|
||||
|
||||
if (skillres.retcode == 0 && skillres.data && skillres.data.skill_list) {
|
||||
skill.id = avatars.id;
|
||||
@ -220,7 +217,6 @@ async function getTalent(e, avatars, MysApi) {
|
||||
return skill;
|
||||
}
|
||||
|
||||
|
||||
// 获取角色数据
|
||||
function getCharacterData(avatars) {
|
||||
let list = [];
|
||||
@ -296,67 +292,6 @@ function getCharacterData(avatars) {
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
export function roleIdToName(keyword, search_val = false) {
|
||||
if (!keyword) {
|
||||
return false;
|
||||
}
|
||||
if (search_val) {
|
||||
return genshin.roleId[keyword][0] ? genshin.roleId[keyword][0] : "";
|
||||
}
|
||||
|
||||
if (!nameID) {
|
||||
nameID = new Map();
|
||||
for (let i in genshin.roleId) {
|
||||
for (let val of genshin.roleId[i]) {
|
||||
nameID.set(val, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
let name = nameID.get(keyword);
|
||||
return name ? name : "";
|
||||
}
|
||||
|
||||
async function limitGet(e) {
|
||||
if (!e.isGroup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e.isMaster) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let key = `genshin:limit:${e.user_id}`;
|
||||
let num = await redis.get(key);
|
||||
|
||||
if (num && num >= e.groupConfig.mysDayLimit - 1) {
|
||||
let name = lodash.truncate(e.sender.card, { length: 8 });
|
||||
e.reply([segment.at(e.user_id, name), "\n今日查询已达上限"]);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
async function limitSet(e) {
|
||||
if (!e.isGroup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
let key = `genshin:limit:${e.user_id}`;
|
||||
let dayEnd = getDayEnd();
|
||||
|
||||
await redis.incr(key);
|
||||
redis.expire(key, dayEnd);
|
||||
}
|
||||
|
||||
function getDayEnd() {
|
||||
let now = new Date();
|
||||
let dayEnd = new Date(now.getFullYear(), now.getMonth(), now.getDate(), "23", "59", "59").getTime() / 1000;
|
||||
|
||||
return dayEnd - parseInt(now.getTime() / 1000);
|
||||
}
|
||||
|
||||
function getCharacterImg(name) {
|
||||
|
||||
if (!fs.existsSync(`./plugins/miao-plugin/resources/characterImg/${name}/`)) {
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 577 KiB |
Binary file not shown.
Before Width: | Height: | Size: 888 KiB |
Binary file not shown.
Before Width: | Height: | Size: 240 KiB |
Binary file not shown.
Before Width: | Height: | Size: 577 KiB |
Loading…
Reference in New Issue
Block a user