mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
refactor: 重构lib代码(无实质性功能更新,可不更新)
This commit is contained in:
parent
a7f06d404b
commit
aa3b7928ec
26 changed files with 547 additions and 483 deletions
|
|
@ -25,7 +25,10 @@ export class Abyss extends ZZZPlugin {
|
|||
const method = this.e.msg.match(`(上期|往期)`)
|
||||
? 'zzzChallengePeriod'
|
||||
: 'zzzChallenge';
|
||||
const abyssData = await api.getFinalData(this.e, method);
|
||||
const abyssData = await api.getFinalData(method).catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!abyssData?.has_data) {
|
||||
await this.reply('没有式舆防卫战数据');
|
||||
return false;
|
||||
|
|
|
|||
15
apps/card.js
15
apps/card.js
|
|
@ -22,14 +22,23 @@ export class Card extends ZZZPlugin {
|
|||
async card() {
|
||||
const { api } = await this.getAPI();
|
||||
await this.getPlayerInfo();
|
||||
const indexData = await api.getFinalData(this.e, 'zzzIndex');
|
||||
const indexData = await api.getFinalData('zzzIndex').catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!indexData) return false;
|
||||
|
||||
let zzzAvatarList = await api.getFinalData(this.e, 'zzzAvatarList');
|
||||
let zzzAvatarList = await api.getFinalData('zzzAvatarList').catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!zzzAvatarList) return false;
|
||||
indexData.avatar_list = zzzAvatarList.avatar_list;
|
||||
|
||||
let zzzBuddyList = await api.getFinalData(this.e, 'zzzBuddyList');
|
||||
let zzzBuddyList = await api.getFinalData('zzzBuddyList').catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!zzzBuddyList) return false;
|
||||
indexData.buddy_list = zzzBuddyList.list;
|
||||
const finalIndexData = new ZZZIndexResp(indexData);
|
||||
|
|
|
|||
|
|
@ -3,13 +3,9 @@ import { getAuthKey } from '../lib/authkey.js';
|
|||
import settings from '../lib/settings.js';
|
||||
import _ from 'lodash';
|
||||
import common from '../../../lib/common/common.js';
|
||||
import {
|
||||
anaylizeGachaLog,
|
||||
updateGachaLog,
|
||||
getZZZGachaLink,
|
||||
gacha_type_meta_data,
|
||||
getZZZGachaLogByAuthkey,
|
||||
} from '../lib/gacha.js';
|
||||
import { anaylizeGachaLog, updateGachaLog } from '../lib/gacha.js';
|
||||
import { getZZZGachaLink, getZZZGachaLogByAuthkey } from '../lib/gacha/core.js';
|
||||
import { gacha_type_meta_data } from '../lib/gacha/const.js';
|
||||
import { getQueryVariable } from '../utils/network.js';
|
||||
import { rulePrefix } from '../lib/common.js';
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ import { ZZZPlugin } from '../lib/plugin.js';
|
|||
import { imageResourcesPath } from '../lib/path.js';
|
||||
import _ from 'lodash';
|
||||
import settings from '../lib/settings.js';
|
||||
import { downloadFile } from '../lib/download.js';
|
||||
import { downloadFile } from '../lib/download/core.js';
|
||||
import { char } from '../lib/convert.js';
|
||||
import guides from '../lib/guides.js';
|
||||
import { rulePrefix } from '../lib/common.js';
|
||||
|
|
|
|||
|
|
@ -251,7 +251,7 @@ export class Help extends ZZZPlugin {
|
|||
},
|
||||
{
|
||||
title: '删除资源(需注意)',
|
||||
desc: '请注意,此命令会删除自定义面板图,请确认做好备份后再执行!!!删除已经下载的资源,查询时需要再次下载(用于删除错误下载缓存)。',
|
||||
desc: '删除已经下载的资源,查询时需要再次下载(用于删除错误下载缓存)。',
|
||||
needCK: false,
|
||||
needSK: false,
|
||||
commands: ['删除全部/所有资源'],
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import {
|
|||
import { char } from '../../lib/convert.js';
|
||||
import { getAllEquipID } from '../../lib/convert/equip.js';
|
||||
import { getAllWeaponID } from '../../lib/convert/weapon.js';
|
||||
import { imageResourcesPath } from '../../lib/path.js';
|
||||
import * as LocalURI from '../../lib/download/const.js';
|
||||
|
||||
export async function downloadAll() {
|
||||
if (!this.e.isMaster) return false;
|
||||
|
|
@ -91,34 +91,11 @@ export async function downloadAll() {
|
|||
}
|
||||
const messages = [
|
||||
'资源下载完成(成功的包含先前下载的图片)',
|
||||
'角色图需下载' +
|
||||
charIDs.length +
|
||||
'张,成功' +
|
||||
result.char.success +
|
||||
'张,失败' +
|
||||
result.char.failed +
|
||||
'张',
|
||||
'角色头像图需下载' +
|
||||
charIDs.length +
|
||||
'张,成功' +
|
||||
result.charSquare.success +
|
||||
'张,失败' +
|
||||
result.charSquare.failed +
|
||||
'张',
|
||||
'套装图需下载' +
|
||||
equipSprites.length +
|
||||
'张,成功' +
|
||||
result.equip.success +
|
||||
'张,失败' +
|
||||
result.equip.failed +
|
||||
'张',
|
||||
'武器图需下载' +
|
||||
weaponSprites.length +
|
||||
'张,成功' +
|
||||
result.weapon.success +
|
||||
'张,失败' +
|
||||
result.weapon.failed +
|
||||
'张',
|
||||
`角色图需下载${charIDs.length}张,成功${result.char.success}张,失败${result.char.failed}张`,
|
||||
`角色头像图需下载${charIDs.length}张,成功${esult.charSquare.success}张,失败${result.charSquare.failed}张`,
|
||||
`角色头像图(练度统计)需下载${charIDs.length}张,成功${result.charSmallSquare.success}张,失败${result.charSmallSquare.failed}张`,
|
||||
`驱动盘套装图需下载${equipSprites.length}张,成功${result.equip.success}张,失败${result.equip.failed}张`,
|
||||
`武器图需下载${weaponSprites.length}张,成功${result.weapon.success}张,失败${result.weapon.failed}张`,
|
||||
];
|
||||
await this.reply(messages.join('\n'));
|
||||
}
|
||||
|
|
@ -129,8 +106,10 @@ export async function deleteAll() {
|
|||
false,
|
||||
{ at: true, recallMsg: 100 }
|
||||
);
|
||||
if (fs.existsSync(imageResourcesPath)) {
|
||||
fs.rmSync(imageResourcesPath, { recursive: true });
|
||||
for (const dir of LocalURI) {
|
||||
if (fs.existsSync(dir)) {
|
||||
fs.rmSync(dir, { recursive: true });
|
||||
}
|
||||
}
|
||||
await this.reply('资源图片已删除!', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { char } from '../../lib/convert.js';
|
||||
import { downloadFile } from '../../lib/download.js';
|
||||
import { downloadFile } from '../../lib/download/core.js';
|
||||
import { imageResourcesPath } from '../../lib/path.js';
|
||||
import common from '../../../../lib/common/common.js';
|
||||
import fs from 'fs';
|
||||
|
|
|
|||
|
|
@ -22,7 +22,10 @@ export class Note extends ZZZPlugin {
|
|||
async note() {
|
||||
const { api } = await this.getAPI();
|
||||
await this.getPlayerInfo();
|
||||
const noteResponse = await api.getFinalData(this.e, 'zzzNote');
|
||||
const noteResponse = await api.getFinalData('zzzNote').catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!noteResponse) return false;
|
||||
const noteData = new ZZZNoteResp(noteResponse);
|
||||
const finalData = {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,10 @@ export class Panel extends ZZZPlugin {
|
|||
await redis.set(`ZZZ:PANEL:${uid}:LASTTIME`, Date.now());
|
||||
await this.reply('正在刷新面板列表,请稍候...');
|
||||
await this.getPlayerInfo();
|
||||
const result = await refreshPanel(this.e, api, uid);
|
||||
const result = await refreshPanel(api, uid).catch(e => {
|
||||
this.reply(e.message);
|
||||
throw e;
|
||||
});
|
||||
if (!result) {
|
||||
await this.reply('面板列表刷新失败,请稍后再试');
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue