将不规范的return false删除并替换部分为return null,保留部分return false保证功能正常

This commit is contained in:
小丞 2025-07-28 00:24:31 +08:00
parent 0c53e71af6
commit f8d5c92419
30 changed files with 42 additions and 141 deletions

View file

@ -33,7 +33,6 @@ export class Abyss extends ZZZPlugin {
}); });
if (!abyssData?.has_data) { if (!abyssData?.has_data) {
await this.reply('没有式舆防卫战数据'); await this.reply('没有式舆防卫战数据');
return false;
} }
const abyss = new ZZZChallenge(abyssData); const abyss = new ZZZChallenge(abyssData);
const timer = setTimeout(() => { const timer = setTimeout(() => {

View file

@ -27,7 +27,6 @@ export class Calendar extends ZZZPlugin {
.then(res => res.json()); .then(res => res.json());
if (!activityList?.data) { if (!activityList?.data) {
await this.reply('获取活动列表失败'); await this.reply('获取活动列表失败');
return false;
} }
const t = activityList?.data?.t || new Date().getTime().toString(); const t = activityList?.data?.t || new Date().getTime().toString();
const activityContent = await request const activityContent = await request
@ -43,7 +42,6 @@ export class Calendar extends ZZZPlugin {
const htmlContent = calendarContent?.content || ''; const htmlContent = calendarContent?.content || '';
if (!htmlContent) { if (!htmlContent) {
await this.reply('未找到活动日历'); await this.reply('未找到活动日历');
return false;
} }
const imgReg = /<img.*?src="(.*?)".*?>/g; const imgReg = /<img.*?src="(.*?)".*?>/g;
const imgSrc = imgReg.exec(htmlContent)?.[1]; const imgSrc = imgReg.exec(htmlContent)?.[1];
@ -52,6 +50,5 @@ export class Calendar extends ZZZPlugin {
} else { } else {
await this.reply('未找到活动日历图片'); await this.reply('未找到活动日历图片');
} }
return false;
} }
} }

View file

@ -28,7 +28,7 @@ export class Card extends ZZZPlugin {
this.reply(e.message); this.reply(e.message);
throw e; throw e;
}); });
if (!indexData) return false; if (!indexData) return null;
let zzzAvatarList = await api.getFinalData('zzzAvatarList', { let zzzAvatarList = await api.getFinalData('zzzAvatarList', {
deviceFp, deviceFp,
@ -36,7 +36,7 @@ export class Card extends ZZZPlugin {
this.reply(e.message); this.reply(e.message);
throw e; throw e;
}); });
if (!zzzAvatarList) return false; if (!zzzAvatarList) return null;
indexData.avatar_list = zzzAvatarList.avatar_list; indexData.avatar_list = zzzAvatarList.avatar_list;
let zzzBuddyList = await api.getFinalData('zzzBuddyList', { let zzzBuddyList = await api.getFinalData('zzzBuddyList', {
@ -45,7 +45,7 @@ export class Card extends ZZZPlugin {
this.reply(e.message); this.reply(e.message);
throw e; throw e;
}); });
if (!zzzBuddyList) return false; if (!zzzBuddyList) return null;
indexData.buddy_list = zzzBuddyList.list; indexData.buddy_list = zzzBuddyList.list;
const finalIndexData = new ZZZIndexResp(indexData); const finalIndexData = new ZZZIndexResp(indexData);
this.e.playerCard.player.region_name = this.e.playerCard.player.region_name =

View file

@ -22,6 +22,5 @@ export class Code extends ZZZPlugin {
async code() { async code() {
const msg = await getCodeMsg(); const msg = await getCodeMsg();
await this.reply(msg); await this.reply(msg);
return false;
} }
} }

View file

@ -27,7 +27,7 @@ export class Damage extends ZZZPlugin {
} }
const reg = new RegExp(`${rulePrefix}(.+)伤害(\\d*)$`) const reg = new RegExp(`${rulePrefix}(.+)伤害(\\d*)$`)
const match = this.e.msg.match(reg) const match = this.e.msg.match(reg)
if (!match) return false if (!match) return null
const name = match[4] const name = match[4]
const data = getPanelOrigin(uid, name) const data = getPanelOrigin(uid, name)
if (data === false) { if (data === false) {

View file

@ -33,7 +33,6 @@ export class deadly extends ZZZPlugin {
}); });
if (!deadlyData?.has_data) { if (!deadlyData?.has_data) {
await this.reply('没有危局强袭战数据'); await this.reply('没有危局强袭战数据');
return false;
} }
const deadly = new Deadly(deadlyData); const deadly = new Deadly(deadlyData);
const timer = setTimeout(() => { const timer = setTimeout(() => {

View file

@ -58,7 +58,6 @@ export class GachaLog extends ZZZPlugin {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('抽卡记录相应功能只支持国服');
return false;
} }
const allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false); const allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false);
const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []); const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []);
@ -70,7 +69,6 @@ export class GachaLog extends ZZZPlugin {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (!allowGroup) { if (!allowGroup) {
if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) { if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) {
@ -82,7 +80,6 @@ export class GachaLog extends ZZZPlugin {
recallMsg: 100, recallMsg: 100,
} }
); );
return false;
} }
} else { } else {
if (blackList.length > 0 && blackList?.includes(currentGroup)) { if (blackList.length > 0 && blackList?.includes(currentGroup)) {
@ -94,7 +91,6 @@ export class GachaLog extends ZZZPlugin {
recallMsg: 100, recallMsg: 100,
} }
); );
return false;
} }
} }
await this.reply( await this.reply(
@ -115,7 +111,6 @@ export class GachaLog extends ZZZPlugin {
if (msg.includes('取消')) { if (msg.includes('取消')) {
await this.reply('已取消', false, { at: true, recallMsg: 100 }); await this.reply('已取消', false, { at: true, recallMsg: 100 });
this.finish('gachaLog'); this.finish('gachaLog');
return false;
} }
const key = getQueryVariable(msg, 'authkey'); const key = getQueryVariable(msg, 'authkey');
if (!key) { if (!key) {
@ -124,7 +119,6 @@ export class GachaLog extends ZZZPlugin {
recallMsg: 100, recallMsg: 100,
}); });
this.finish('gachaLog'); this.finish('gachaLog');
return false;
} }
this.finish('gachaLog'); this.finish('gachaLog');
this.getLogWithOutUID(key); this.getLogWithOutUID(key);
@ -133,9 +127,8 @@ export class GachaLog extends ZZZPlugin {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('抽卡记录相应功能只支持国服');
return false;
} }
if (!uid) return false; if (!uid) return null;
const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`); const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`);
const gachaConfig = settings.getConfig('gacha'); const gachaConfig = settings.getConfig('gacha');
const coldTime = _.get(gachaConfig, 'interval', 300); const coldTime = _.get(gachaConfig, 'interval', 300);
@ -143,11 +136,9 @@ export class GachaLog extends ZZZPlugin {
const key = await getAuthKey(this.e, this.User, uid); const key = await getAuthKey(this.e, this.User, uid);
if (!key) { if (!key) {
await this.reply('authKey获取失败请检查cookie是否过期'); await this.reply('authKey获取失败请检查cookie是否过期');
return false;
} }
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) { if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`); await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`);
return false;
} }
await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now()); await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now());
this.getLog(key); this.getLog(key);
@ -157,7 +148,7 @@ export class GachaLog extends ZZZPlugin {
} }
async getLog(key) { async getLog(key) {
const uid = await this.getUID(); const uid = await this.getUID();
if (!uid) return false; if (!uid) return null;
this.reply('抽卡记录获取中请稍等...可能需要一段时间,请耐心等待'); this.reply('抽卡记录获取中请稍等...可能需要一段时间,请耐心等待');
const { data, count } = await updateGachaLog(key, uid); const { data, count } = await updateGachaLog(key, uid);
let msg = []; let msg = [];
@ -170,7 +161,6 @@ export class GachaLog extends ZZZPlugin {
await this.reply( await this.reply(
await common.makeForwardMsg(this.e, msg.join('\n'), '抽卡记录更新成功') await common.makeForwardMsg(this.e, msg.join('\n'), '抽卡记录更新成功')
); );
return false;
} }
async getLogWithOutUID(key) { async getLogWithOutUID(key) {
await this.reply( await this.reply(
@ -201,7 +191,6 @@ export class GachaLog extends ZZZPlugin {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
const { data, count } = await updateGachaLog(key, uid); const { data, count } = await updateGachaLog(key, uid);
let msg = []; let msg = [];
@ -214,16 +203,14 @@ export class GachaLog extends ZZZPlugin {
await this.reply( await this.reply(
await common.makeForwardMsg(this.e, msg, '抽卡记录更新成功') await common.makeForwardMsg(this.e, msg, '抽卡记录更新成功')
); );
return false;
} }
async gachaLogAnalysis() { async gachaLogAnalysis() {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('抽卡记录相应功能只支持国服');
return false;
} }
if (!uid) return false; if (!uid) return null;
await this.getPlayerInfo(); await this.getPlayerInfo();
await this.reply('正在分析抽卡记录,请稍等', false, { await this.reply('正在分析抽卡记录,请稍等', false, {
at: true, at: true,
@ -239,7 +226,6 @@ export class GachaLog extends ZZZPlugin {
recallMsg: 100, recallMsg: 100,
} }
); );
return false;
} }
const result = { const result = {
data, data,
@ -250,17 +236,14 @@ export class GachaLog extends ZZZPlugin {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('抽卡记录相应功能只支持国服'); await this.reply('抽卡记录相应功能只支持国服');
return false;
} }
if (!uid) return false; if (!uid) return null;
if (!this.e.isPrivate || this.e.isGroup) { if (!this.e.isPrivate || this.e.isGroup) {
await this.reply('请私聊获取抽卡链接', false, { at: true }); await this.reply('请私聊获取抽卡链接', false, { at: true });
return false;
} }
const key = await getAuthKey(this.e, this.User, uid); const key = await getAuthKey(this.e, this.User, uid);
if (!key) { if (!key) {
await this.reply('authKey获取失败请检查cookie是否过期'); await this.reply('authKey获取失败请检查cookie是否过期');
return false;
} }
const link = await getZZZGachaLink(key); const link = await getZZZGachaLink(key);
await this.reply(link); await this.reply(link);

View file

@ -70,17 +70,14 @@ export class Guide extends ZZZPlugin {
group = Number(group); group = Number(group);
if (group > guides.guideMaxNum) { if (group > guides.guideMaxNum) {
await this.reply(`超过攻略数量(${guides.guideMaxNum}`); await this.reply(`超过攻略数量(${guides.guideMaxNum}`);
return false;
} }
if (alias === '设置默认' || alias === '设置所有') { if (alias === '设置默认' || alias === '设置所有') {
return false;
} }
const name = char.aliasToName(alias); const name = char.aliasToName(alias);
if (!name) { if (!name) {
await this.reply('该角色不存在'); await this.reply('该角色不存在');
return false;
} }
if (group === 0) { if (group === 0) {
@ -102,7 +99,6 @@ export class Guide extends ZZZPlugin {
if (msg.length) { if (msg.length) {
await this.reply(await common.makeForwardMsg(this.e, msg)); await this.reply(await common.makeForwardMsg(this.e, msg));
} }
return false;
} }
const guidePath = await this.getGuidePath(group, name, !!isUpdate); const guidePath = await this.getGuidePath(group, name, !!isUpdate);
@ -112,10 +108,8 @@ export class Guide extends ZZZPlugin {
guides.guideSources[group - 1] guides.guideSources[group - 1]
})\n请尝试其他的攻略来源查询` })\n请尝试其他的攻略来源查询`
); );
return false;
} }
await this.e.reply(segment.image(guidePath)); await this.e.reply(segment.image(guidePath));
return false;
} }
/** 下载攻略图 */ /** 下载攻略图 */
@ -130,7 +124,6 @@ export class Guide extends ZZZPlugin {
} catch (error) { } catch (error) {
this.e.reply('暂无攻略数据,请稍后再试'); this.e.reply('暂无攻略数据,请稍后再试');
console.log(`米游社接口报错:${error}}`); console.log(`米游社接口报错:${error}}`);
return false;
} }
// 搜索时过滤特殊符号譬如「11号」 // 搜索时过滤特殊符号譬如「11号」
@ -160,7 +153,7 @@ export class Guide extends ZZZPlugin {
} }
} }
if (!url) { if (!url) {
return false; return null;
} }
logger.debug( logger.debug(
`${this.e.logFnc} 下载${name}攻略图 - ${guides.guideSources[group - 1]}` `${this.e.logFnc} 下载${name}攻略图 - ${guides.guideSources[group - 1]}`
@ -181,7 +174,7 @@ export class Guide extends ZZZPlugin {
async getData(url) { async getData(url) {
let response = await fetch(url, { method: 'get' }); let response = await fetch(url, { method: 'get' });
if (!response.ok) { if (!response.ok) {
return false; return null;
} }
return await response.json(); return await response.json();
} }

View file

@ -412,11 +412,9 @@ export class Help extends ZZZPlugin {
await this.render('help/index.html', { await this.render('help/index.html', {
helpData: _helpData, helpData: _helpData,
}); });
return false;
} }
await this.render('help/index.html', { await this.render('help/index.html', {
helpData, helpData,
}); });
return false;
} }
} }

View file

@ -4,7 +4,6 @@ import settings from '../../lib/settings.js';
export async function addAlias() { export async function addAlias() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg); const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg);
const key = match[1]; const key = match[1];
@ -35,7 +34,6 @@ export async function addAlias() {
export async function deleteAlias() { export async function deleteAlias() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /删除别名(\S+)$/g.exec(this.e.msg); const match = /删除别名(\S+)$/g.exec(this.e.msg);
const key = match[1]; const key = match[1];

View file

@ -15,7 +15,7 @@ import { getAllWeaponID } from '../../lib/convert/weapon.js';
import * as LocalURI from '../../lib/download/const.js'; import * as LocalURI from '../../lib/download/const.js';
export async function downloadAll() { export async function downloadAll() {
if (!this.e.isMaster) return false; if (!this.e.isMaster) return null;
const charIDs = char.getAllCharactersID(); const charIDs = char.getAllCharactersID();
const equipSprites = getAllEquipID(); const equipSprites = getAllEquipID();
const weaponSprites = getAllWeaponID(); const weaponSprites = getAllWeaponID();
@ -146,7 +146,7 @@ export async function downloadAll() {
await this.reply(messages.join('\n')); await this.reply(messages.join('\n'));
} }
export async function deleteAll() { export async function deleteAll() {
if (!this.e.isMaster) return false; if (!this.e.isMaster) return null;
await this.reply( await this.reply(
'【注意】正在删除所有资源图片,后续使用需要重新下载!', '【注意】正在删除所有资源图片,后续使用需要重新下载!',
false, false,

View file

@ -4,7 +4,6 @@ import settings from '../../lib/settings.js';
export async function setRenderPrecision() { export async function setRenderPrecision() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /渲染精度(\d+)$/g.exec(this.e.msg); const match = /渲染精度(\d+)$/g.exec(this.e.msg);
const render_precision = Number(match[1]); const render_precision = Number(match[1]);
@ -13,14 +12,12 @@ export async function setRenderPrecision() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (render_precision > 200) { if (render_precision > 200) {
await this.e.reply('渲染精度不能大于200', false, { await this.e.reply('渲染精度不能大于200', false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
settings.setSingleConfig('config', 'render', { settings.setSingleConfig('config', 'render', {
scale: render_precision, scale: render_precision,
@ -32,7 +29,6 @@ export async function setRenderPrecision() {
export async function setRefreshGachaInterval() { export async function setRefreshGachaInterval() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /刷新抽卡间隔(\d+)$/g.exec(this.e.msg); const match = /刷新抽卡间隔(\d+)$/g.exec(this.e.msg);
const refresh_gacha_interval = Number(match[1]); const refresh_gacha_interval = Number(match[1]);
@ -41,14 +37,12 @@ export async function setRefreshGachaInterval() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (refresh_gacha_interval > 1000) { if (refresh_gacha_interval > 1000) {
await this.e.reply('刷新抽卡间隔不能大于1000秒', false, { await this.e.reply('刷新抽卡间隔不能大于1000秒', false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
settings.setSingleConfig('gacha', 'interval', refresh_gacha_interval); settings.setSingleConfig('gacha', 'interval', refresh_gacha_interval);
await this.e.reply(`绝区零刷新抽卡间隔已设置为: ${refresh_gacha_interval}`); await this.e.reply(`绝区零刷新抽卡间隔已设置为: ${refresh_gacha_interval}`);
@ -58,7 +52,6 @@ export async function setRefreshGachaInterval() {
export async function setRefreshPanelInterval() { export async function setRefreshPanelInterval() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /刷新面板间隔(\d+)$/g.exec(this.e.msg); const match = /刷新面板间隔(\d+)$/g.exec(this.e.msg);
const refresh_panel_interval = Number(match[1]); const refresh_panel_interval = Number(match[1]);
@ -67,14 +60,12 @@ export async function setRefreshPanelInterval() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (refresh_panel_interval > 1000) { if (refresh_panel_interval > 1000) {
await this.e.reply('刷新面板间隔不能大于1000秒', false, { await this.e.reply('刷新面板间隔不能大于1000秒', false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
settings.setSingleConfig('panel', 'interval', refresh_panel_interval); settings.setSingleConfig('panel', 'interval', refresh_panel_interval);
await this.e.reply( await this.e.reply(
@ -88,7 +79,6 @@ export async function setRefreshPanelInterval() {
export async function setRefreshCharInterval() { export async function setRefreshCharInterval() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /刷新角色间隔(\d+)$/g.exec(this.e.msg); const match = /刷新角色间隔(\d+)$/g.exec(this.e.msg);
const refresh_char_interval = Number(match[1]); const refresh_char_interval = Number(match[1]);
@ -97,14 +87,12 @@ export async function setRefreshCharInterval() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (refresh_char_interval > 1000) { if (refresh_char_interval > 1000) {
await this.e.reply('刷新角色间隔不能大于1000秒', false, { await this.e.reply('刷新角色间隔不能大于1000秒', false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
settings.setSingleConfig('panel', 'roleInterval', refresh_char_interval); settings.setSingleConfig('panel', 'roleInterval', refresh_char_interval);
await this.e.reply(`绝区零刷新角色间隔已设置为: ${refresh_char_interval}`); await this.e.reply(`绝区零刷新角色间隔已设置为: ${refresh_char_interval}`);

View file

@ -3,7 +3,6 @@ import settings from '../../lib/settings.js';
export async function setDefaultDevice() { export async function setDefaultDevice() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
this.setContext('toSetDefaultDevice'); this.setContext('toSetDefaultDevice');
await this.reply( await this.reply(
@ -16,18 +15,15 @@ export async function toSetDefaultDevice() {
const msg = this.e.msg.trim(); const msg = this.e.msg.trim();
if (!msg) { if (!msg) {
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 }); this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
return false;
} }
if (msg.includes('取消')) { if (msg.includes('取消')) {
await this.reply('已取消', false, { at: true, recallMsg: 100 }); await this.reply('已取消', false, { at: true, recallMsg: 100 });
this.finish('toSetDefaultDevice'); this.finish('toSetDefaultDevice');
return false;
} }
try { try {
const info = JSON.parse(msg); const info = JSON.parse(msg);
if (!info) { if (!info) {
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
return false;
} }
if ( if (
!info?.deviceName || !info?.deviceName ||
@ -38,7 +34,6 @@ export async function toSetDefaultDevice() {
!info?.deviceProduct !info?.deviceProduct
) { ) {
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
return false;
} }
settings.setConfig('device', { settings.setConfig('device', {
productName: info.deviceProduct, productName: info.deviceProduct,

View file

@ -5,7 +5,6 @@ import settings from '../../lib/settings.js';
export async function setDefaultGuide() { export async function setDefaultGuide() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg); const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg);
let guide_id = match[1]; let guide_id = match[1];
@ -37,7 +36,6 @@ export async function setDefaultGuide() {
export async function setMaxForwardGuide() { export async function setMaxForwardGuide() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg); const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg);
const max_forward_guide = Number(match[1]); const max_forward_guide = Number(match[1]);
@ -46,14 +44,12 @@ export async function setMaxForwardGuide() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
if (max_forward_guide > guides.guideMaxNum) { if (max_forward_guide > guides.guideMaxNum) {
await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, { await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide); settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide);
await this.e.reply( await this.e.reply(

View file

@ -7,18 +7,15 @@ import path from 'path';
export async function uploadCharacterImg() { export async function uploadCharacterImg() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('只有主人才能添加', false, { at: true, recallMsg: 100 }); this.reply('只有主人才能添加', false, { at: true, recallMsg: 100 });
return false;
} }
const reg = /(上传|添加)(.+)(角色|面板)图$/; const reg = /(上传|添加)(.+)(角色|面板)图$/;
const match = this.e.msg.match(reg); const match = this.e.msg.match(reg);
if (!match) { if (!match) {
return false;
} }
const charName = match[2].trim(); const charName = match[2].trim();
const name = char.aliasToName(charName); const name = char.aliasToName(charName);
if (!name) { if (!name) {
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
return false;
} }
const images = []; const images = [];
// 下面方法来源于miao-plugin/apps/character/ImgUpload.js // 下面方法来源于miao-plugin/apps/character/ImgUpload.js
@ -75,7 +72,6 @@ export async function uploadCharacterImg() {
false, false,
{ at: true, recallMsg: 100 } { at: true, recallMsg: 100 }
); );
return false;
} }
const resourcesImagesPath = imageResourcesPath; const resourcesImagesPath = imageResourcesPath;
const panelImagesPath = path.join(resourcesImagesPath, `panel/${name}`); const panelImagesPath = path.join(resourcesImagesPath, `panel/${name}`);
@ -100,21 +96,18 @@ export async function uploadCharacterImg() {
at: true, at: true,
recallMsg: 100, recallMsg: 100,
}); });
return false;
} }
export async function getCharacterImages() { export async function getCharacterImages() {
const reg = /(获取|查看)(.+)(角色|面板)图(\d+)?$/; const reg = /(获取|查看)(.+)(角色|面板)图(\d+)?$/;
const match = this.e.msg.match(reg); const match = this.e.msg.match(reg);
if (!match) { if (!match) {
return false;
} }
const charName = match[2].trim(); const charName = match[2].trim();
const name = char.aliasToName(charName); const name = char.aliasToName(charName);
let page = match[4]; let page = match[4];
if (!name) { if (!name) {
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
return false;
} }
const pageSize = 5; const pageSize = 5;
const resourcesImagesPath = imageResourcesPath; const resourcesImagesPath = imageResourcesPath;
@ -132,7 +125,6 @@ export async function getCharacterImages() {
const end = page * pageSize; const end = page * pageSize;
if (start >= images.length) { if (start >= images.length) {
this.reply('哪有这么多图片', false, { at: true, recallMsg: 100 }); this.reply('哪有这么多图片', false, { at: true, recallMsg: 100 });
return false;
} }
const imagePaths = images.slice(start, end); const imagePaths = images.slice(start, end);
const imageMsg = imagePaths.map(imagePath => { const imageMsg = imagePaths.map(imagePath => {
@ -150,25 +142,20 @@ export async function getCharacterImages() {
); );
if (imageMsg.length) if (imageMsg.length)
await this.reply(await common.makeForwardMsg(this.e, imageMsg)); await this.reply(await common.makeForwardMsg(this.e, imageMsg));
return false;
} }
export async function deleteCharacterImg() { export async function deleteCharacterImg() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('只有主人才能删除', false, { at: true, recallMsg: 100 }); this.reply('只有主人才能删除', false, { at: true, recallMsg: 100 });
return false;
} }
const reg = /(删除)(.+)(角色|面板)图(.+)$/; const reg = /(删除)(.+)(角色|面板)图(.+)$/;
const match = this.e.msg.match(reg); const match = this.e.msg.match(reg);
if (!match) { if (!match) {
return false;
} }
const charName = match[2].trim(); const charName = match[2].trim();
const name = char.aliasToName(charName); const name = char.aliasToName(charName);
if (!name) { if (!name) {
this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); this.reply('未找到对应角色', false, { at: true, recallMsg: 100 });
return false;
} }
const ids = match[4].split(/[,,、\s]+/); const ids = match[4].split(/[,,、\s]+/);
const resourcesImagesPath = imageResourcesPath; const resourcesImagesPath = imageResourcesPath;
@ -196,5 +183,4 @@ export async function deleteCharacterImg() {
'删除后会重新排序ID若想要再次删除请重新获取图片列表否则可能会删除错误的图片。', '删除后会重新排序ID若想要再次删除请重新获取图片列表否则可能会删除错误的图片。',
]; ];
this.reply(common.makeForwardMsg(this.e, msgs)); this.reply(common.makeForwardMsg(this.e, msgs));
return false;
} }

View file

@ -8,11 +8,10 @@ export async function getChangeLog() {
await this.render('help/version.html', { await this.render('help/version.html', {
versionData, versionData,
}); });
return false;
} }
export async function getCommitLog() { export async function getCommitLog() {
if (!ZZZUpdate) return false; if (!ZZZUpdate) return null;
let updatePlugin = new ZZZUpdate(); let updatePlugin = new ZZZUpdate();
updatePlugin.e = this.e; updatePlugin.e = this.e;
updatePlugin.reply = this.reply; updatePlugin.reply = this.reply;
@ -33,7 +32,7 @@ export async function getCommitLog() {
} }
export async function hasUpdate() { export async function hasUpdate() {
if (!ZZZUpdate) return false; if (!ZZZUpdate) return null;
let updatePlugin = new ZZZUpdate(); let updatePlugin = new ZZZUpdate();
updatePlugin.e = this.e; updatePlugin.e = this.e;
updatePlugin.reply = this.reply; updatePlugin.reply = this.reply;
@ -55,7 +54,6 @@ export async function hasUpdate() {
export async function enableAutoUpdatePush() { export async function enableAutoUpdatePush() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
let enable = true; let enable = true;
if (this.e.msg.includes('关闭')) { if (this.e.msg.includes('关闭')) {
@ -73,7 +71,6 @@ export async function enableAutoUpdatePush() {
export async function setCheckUpdateCron() { export async function setCheckUpdateCron() {
if (!this.e.isMaster) { if (!this.e.isMaster) {
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
} }
const cron = this.e.msg.split('时间')[1]; const cron = this.e.msg.split('时间')[1];
if (!cron) { if (!cron) {
@ -85,7 +82,6 @@ export async function setCheckUpdateCron() {
recallMsg: 100, recallMsg: 100,
} }
); );
return false;
} }
settings.setSingleConfig('config', 'update', { cron }); settings.setSingleConfig('config', 'update', { cron });
await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, { await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, {

View file

@ -31,7 +31,6 @@ export class monthly extends ZZZPlugin {
const match = this.e.msg.match(reg); const match = this.e.msg.match(reg);
if (!match) { if (!match) {
await this.reply('参数错误,请检查输入'); await this.reply('参数错误,请检查输入');
return false;
} }
let year = match[3]; let year = match[3];
let month = match[5]; let month = match[5];
@ -47,11 +46,9 @@ export class monthly extends ZZZPlugin {
}); });
if (!monthlyResponse) { if (!monthlyResponse) {
await this.reply('获取月报数据失败,请检查日期是否正确'); await this.reply('获取月报数据失败,请检查日期是否正确');
return false;
} }
if (!monthlyResponse?.month_data) { if (!monthlyResponse?.month_data) {
await this.reply('月报数据为空'); await this.reply('月报数据为空');
return false;
} }
const monthlyData = new Monthly(monthlyResponse); const monthlyData = new Monthly(monthlyResponse);
const finalData = { const finalData = {
@ -73,7 +70,6 @@ export class monthly extends ZZZPlugin {
if (!collect) { if (!collect) {
await this.reply('获取月报数据失败'); await this.reply('获取月报数据失败');
return false;
} }
const collectData = collect.map(item => new Monthly(item)); const collectData = collect.map(item => new Monthly(item));

View file

@ -28,7 +28,7 @@ export class Note extends ZZZPlugin {
this.reply(e.message); this.reply(e.message);
throw e; throw e;
}); });
if (!noteResponse) return false; if (!noteResponse) return null;
const noteData = new ZZZNoteResp(noteResponse); const noteData = new ZZZNoteResp(noteResponse);
const finalData = { const finalData = {
note: noteData, note: noteData,

View file

@ -51,7 +51,6 @@ export class Panel extends ZZZPlugin {
if (!pre || suf === '列表') return await this.getCharPanelList(); if (!pre || suf === '列表') return await this.getCharPanelList();
const queryPanelReg = new RegExp(`${rulePrefix}(.*)面板$`); const queryPanelReg = new RegExp(`${rulePrefix}(.*)面板$`);
if (queryPanelReg.test(this.e.msg)) return await this.getCharPanel(); if (queryPanelReg.test(this.e.msg)) return await this.getCharPanel();
return false;
} }
async refreshPanel() { async refreshPanel() {
@ -61,7 +60,6 @@ export class Panel extends ZZZPlugin {
const coldTime = _.get(panelSettings, 'interval', 300); const coldTime = _.get(panelSettings, 'interval', 300);
if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) { if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) {
await this.reply(`${coldTime}秒内只能更新一次,请稍后再试`); await this.reply(`${coldTime}秒内只能更新一次,请稍后再试`);
return false;
} }
const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e)) const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e))
let result let result
@ -102,7 +100,7 @@ export class Panel extends ZZZPlugin {
return this.reply(`面板列表更新失败,请稍后再试或尝试%更新展柜面板:\n${errorMsg.trim()}`); return this.reply(`面板列表更新失败,请稍后再试或尝试%更新展柜面板:\n${errorMsg.trim()}`);
} }
} }
if (!result) return false; if (!result) return;
const newChar = result.filter(item => item.isNew); const newChar = result.filter(item => item.isNew);
const finalData = { const finalData = {
newChar: newChar.length, newChar: newChar.length,
@ -116,7 +114,6 @@ export class Panel extends ZZZPlugin {
const result = getPanelList(uid); const result = getPanelList(uid);
if (!result.length) { if (!result.length) {
await this.reply(`UID:${uid}无本地面板数据,请先%更新面板 或 %更新展柜面板`); await this.reply(`UID:${uid}无本地面板数据,请先%更新面板 或 %更新展柜面板`);
return false;
} }
const hasCk = !!(await getCk(this.e)); const hasCk = !!(await getCk(this.e));
await this.getPlayerInfo(hasCk ? undefined : parsePlayerInfo({ uid })); await this.getPlayerInfo(hasCk ? undefined : parsePlayerInfo({ uid }));
@ -138,7 +135,7 @@ export class Panel extends ZZZPlugin {
async getCharPanelListTool(uid, origin = false) { async getCharPanelListTool(uid, origin = false) {
if (!uid) { if (!uid) {
return false; return null;
} }
if (origin) { if (origin) {
const result = getPanelListOrigin(uid); const result = getPanelListOrigin(uid);
@ -152,7 +149,7 @@ export class Panel extends ZZZPlugin {
const uid = await this.getUID(); const uid = await this.getUID();
const reg = new RegExp(`${rulePrefix}(.+)面板$`); const reg = new RegExp(`${rulePrefix}(.+)面板$`);
const match = this.e.msg.match(reg); const match = this.e.msg.match(reg);
if (!match) return false; if (!match) return;
const name = match[4]; const name = match[4];
const data = getPanelOrigin(uid, name); const data = getPanelOrigin(uid, name);
if (data === false) { if (data === false) {
@ -169,7 +166,6 @@ export class Panel extends ZZZPlugin {
needSave: false, needSave: false,
}); });
} }
return false;
} }
async getCharPanelTool(e, _data = {}) { async getCharPanelTool(e, _data = {}) {
@ -185,11 +181,9 @@ export class Panel extends ZZZPlugin {
} = _data; } = _data;
if (!uid) { if (!uid) {
await this.reply('UID为空'); await this.reply('UID为空');
return false;
} }
if (!data) { if (!data) {
await this.reply('数据为空'); await this.reply('数据为空');
return false;
} }
if (needSave) { if (needSave) {
updatePanelData(uid, [data]); updatePanelData(uid, [data]);
@ -236,7 +230,6 @@ export class Panel extends ZZZPlugin {
const result = getPanelList(uid); const result = getPanelList(uid);
if (!result) { if (!result) {
await this.reply('未找到面板数据,请先%更新面板 或 %更新展柜面板'); await this.reply('未找到面板数据,请先%更新面板 或 %更新展柜面板');
return false;
} }
await this.getPlayerInfo(); await this.getPlayerInfo();
result.sort((a, b) => { result.sort((a, b) => {
@ -294,14 +287,11 @@ export class Panel extends ZZZPlugin {
const id = source?.message_id; const id = source?.message_id;
if (!id) { if (!id) {
await this.reply('未找到消息源,请引用要查看的图片'); await this.reply('未找到消息源,请引用要查看的图片');
return false;
} }
const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`); const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`);
if (!image) { if (!image) {
await this.reply('未找到原图'); await this.reply('未找到原图');
return false;
} }
await this.reply(segment.image(image)); await this.reply(segment.image(image));
return false;
} }
} }

View file

@ -34,7 +34,7 @@ export class update extends plugin {
} }
async update(e = this.e) { async update(e = this.e) {
if (!e.isMaster || !ZZZUpdate) return false; if (!e.isMaster || !ZZZUpdate) return null;
e.msg = `#${e.msg.includes('强制') ? '强制' : ''}更新${pluginName}`; e.msg = `#${e.msg.includes('强制') ? '强制' : ''}更新${pluginName}`;
const up = new ZZZUpdate(e); const up = new ZZZUpdate(e);
up.e = e; up.e = e;
@ -45,7 +45,7 @@ export class update extends plugin {
const updateConfig = _.get(settings.getConfig('config'), 'update', {}); const updateConfig = _.get(settings.getConfig('config'), 'update', {});
const enable = _.get(updateConfig, 'autoCheck', false); const enable = _.get(updateConfig, 'autoCheck', false);
if (!enable) return; if (!enable) return;
if (!ZZZUpdate) return false; if (!ZZZUpdate) return null;
const up = new ZZZUpdate(); const up = new ZZZUpdate();
const result = await up.hasUpdate(); const result = await up.hasUpdate();
if (result.hasUpdate) { if (result.hasUpdate) {

View file

@ -31,7 +31,6 @@ export class User extends ZZZPlugin {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) { if (/^(1[0-9])[0-9]{8}/i.test(uid)) {
await this.reply('国际服不需要绑定设备'); await this.reply('国际服不需要绑定设备');
return false;
} }
//先throw一步 //先throw一步
this.setContext('toBindDevice'); this.setContext('toBindDevice');
@ -46,30 +45,25 @@ export class User extends ZZZPlugin {
if (!ltuid) { if (!ltuid) {
this.reply('未绑定UID'); this.reply('未绑定UID');
this.finish('toBindDevice'); this.finish('toBindDevice');
return false;
} }
const msg = this.e.msg.trim(); const msg = this.e.msg.trim();
if (!msg) { if (!msg) {
this.reply('请发送设备信息', false, { at: true, recallMsg: 100 }); this.reply('请发送设备信息', false, { at: true, recallMsg: 100 });
return false;
} }
if (msg.includes('取消')) { if (msg.includes('取消')) {
await this.reply('已取消', false, { at: true, recallMsg: 100 }); await this.reply('已取消', false, { at: true, recallMsg: 100 });
this.finish('toBindDevice'); this.finish('toBindDevice');
return false;
} }
try { try {
const info = JSON.parse(msg); const info = JSON.parse(msg);
if (!info) { if (!info) {
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
return false;
} }
if (!!info?.device_id && !!info.device_fp) { if (!!info?.device_id && !!info.device_fp) {
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, info.device_fp); await redis.set(`ZZZ:DEVICE_FP:${ltuid}:FP`, info.device_fp);
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:ID`, info.device_id); await redis.set(`ZZZ:DEVICE_FP:${ltuid}:ID`, info.device_id);
await this.reply('绑定设备成功', false, { at: true, recallMsg: 100 }); await this.reply('绑定设备成功', false, { at: true, recallMsg: 100 });
this.finish('toBindDevice'); this.finish('toBindDevice');
return false;
} }
if ( if (
!info?.deviceName || !info?.deviceName ||
@ -81,28 +75,24 @@ export class User extends ZZZPlugin {
!info?.deviceProduct !info?.deviceProduct
) { ) {
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
return false;
} }
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`); await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info)); await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info));
const { deviceFp } = await this.getAPI(); const { deviceFp } = await this.getAPI();
if (!deviceFp) { if (!deviceFp) {
await this.reply('绑定设备失败'); await this.reply('绑定设备失败');
return false;
} }
logger.debug(`[LTUID:${ltuid}]绑定设备成功deviceFp:${deviceFp}`); logger.debug(`[LTUID:${ltuid}]绑定设备成功deviceFp:${deviceFp}`);
await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 }); await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 });
} catch (error) { } catch (error) {
this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 });
return false;
} finally { } finally {
this.finish('toBindDevice'); this.finish('toBindDevice');
return false;
} }
} }
async deleteBind() { async deleteBind() {
const uid = await this.getUID(); const uid = await this.getUID();
if (/^(1[0-9])[0-9]{8}/i.test(uid)) return false; if (/^(1[0-9])[0-9]{8}/i.test(uid)) return null;
const ltuid = await this.getLtuid(); const ltuid = await this.getLtuid();
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`); await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`);
await redis.del(`ZZZ:DEVICE_FP:${ltuid}:BIND`); await redis.del(`ZZZ:DEVICE_FP:${ltuid}:BIND`);

View file

@ -54,7 +54,7 @@ export class Wiki extends ZZZPlugin {
logger.debug('skills'); logger.debug('skills');
const reg = new RegExp(`${rulePrefix}(.*)天赋(.*)$`); const reg = new RegExp(`${rulePrefix}(.*)天赋(.*)$`);
const charname = this.e.msg.match(reg)[4]; const charname = this.e.msg.match(reg)[4];
if (!charname) return false; if (!charname) return null;
const levelsChar = this.e.msg.match(reg)[5]; const levelsChar = this.e.msg.match(reg)[5];
const levels = !!levelsChar const levels = !!levelsChar
? levelsChar.split('.').map(x => { ? levelsChar.split('.').map(x => {
@ -81,7 +81,6 @@ export class Wiki extends ZZZPlugin {
!isSkillLevelLegal('CoreLevel', CoreLevel) !isSkillLevelLegal('CoreLevel', CoreLevel)
) { ) {
await this.reply(`${charname}天赋等级参数不合法`); await this.reply(`${charname}天赋等级参数不合法`);
return false;
} }
const charData = await getHakushCharacterData(charname); const charData = await getHakushCharacterData(charname);
if (!charData) if (!charData)
@ -104,12 +103,11 @@ export class Wiki extends ZZZPlugin {
async cinema() { async cinema() {
const reg = new RegExp(`${rulePrefix}(.*)(意象影画|意象|影画|命座)$`); const reg = new RegExp(`${rulePrefix}(.*)(意象影画|意象|影画|命座)$`);
const charname = this.e.msg.match(reg)[4]; const charname = this.e.msg.match(reg)[4];
if (!charname) return false; if (!charname) return null;
const charData = await getHakushCharacterData(charname); const charData = await getHakushCharacterData(charname);
const cinemaData = charData?.Talent; const cinemaData = charData?.Talent;
if (!cinemaData) { if (!cinemaData) {
await this.reply(`未找到${charname}的数据`); await this.reply(`未找到${charname}的数据`);
return false;
} }
await charData.get_assets(); await charData.get_assets();
const finalData = { const finalData = {

View file

@ -149,7 +149,7 @@ export const getPanelListOrigin = uid => {
export const getPanel = (uid, name) => { export const getPanel = (uid, name) => {
// 通过名称(包括别名)获取角色 ID // 通过名称(包括别名)获取角色 ID
const id = char.aliasToID(name); const id = char.aliasToID(name);
if (!id) return false; if (!id) return null;
const _data = getPanelData(uid); const _data = getPanelData(uid);
// 获取所有面板数据 // 获取所有面板数据
const data = _data.map(item => new ZZZAvatarInfo(item)); const data = _data.map(item => new ZZZAvatarInfo(item));
@ -167,7 +167,7 @@ export const getPanel = (uid, name) => {
*/ */
export const getPanelOrigin = (uid, name) => { export const getPanelOrigin = (uid, name) => {
const id = char.aliasToID(name); const id = char.aliasToID(name);
if (!id) return false; if (!id) return null;
const data = getPanelData(uid); const data = getPanelData(uid);
// 通过 ID 获取角色数据 // 通过 ID 获取角色数据
const result = data.find(item => item.id === id); const result = data.find(item => item.id === id);

View file

@ -77,7 +77,7 @@ export default class MysZZZApi extends MysApi {
data.deviceId = this._device; data.deviceId = this._device;
// 获取请求地址 // 获取请求地址
const urlMap = this.apiTool.getUrlMap(data); const urlMap = this.apiTool.getUrlMap(data);
if (!urlMap[type]) return false; if (!urlMap[type]) return null;
// 获取请求参数即APITool中默认的请求参数此参数理应是不可获取的详细请参照 lib/mysapi/tool.js` // 获取请求参数即APITool中默认的请求参数此参数理应是不可获取的详细请参照 lib/mysapi/tool.js`
let { let {
url, url,
@ -381,7 +381,7 @@ export default class MysZZZApi extends MysApi {
} }
const result = await this.getData(type, data, cached); const result = await this.getData(type, data, cached);
const _data = await this.checkCode(result, type, data); const _data = await this.checkCode(result, type, data);
if (!_data || _data.retcode !== 0) return false; if (!_data || _data.retcode !== 0) return null;
return _data.data; return _data.data;
} }
} }

View file

@ -13,8 +13,8 @@ export const scoreWeight = {};
* @returns {{ [propID: string]: number }} * @returns {{ [propID: string]: number }}
*/ */
export function formatScoreWeight(oriScoreWeight) { export function formatScoreWeight(oriScoreWeight) {
if (!oriScoreWeight) return false; if (!oriScoreWeight) return null;
if (typeof oriScoreWeight !== 'object') return false; if (typeof oriScoreWeight !== 'object') return null;
const weight = {}; const weight = {};
for (const propName in oriScoreWeight) { for (const propName in oriScoreWeight) {
if (!oriScoreWeight[propName]) if (!oriScoreWeight[propName])

View file

@ -75,12 +75,12 @@ class Setting {
filepath = path.join(this.dataPath, filepath); filepath = path.join(this.dataPath, filepath);
try { try {
if (!fs.existsSync(path.join(filepath, filename))) { if (!fs.existsSync(path.join(filepath, filename))) {
return false; return null;
} }
return YAML.parse(fs.readFileSync(path.join(filepath, filename), 'utf8')); return YAML.parse(fs.readFileSync(path.join(filepath, filename), 'utf8'));
} catch (error) { } catch (error) {
logger.error(`[${pluginName}] [${filename}] 读取失败 ${error}`); logger.error(`[${pluginName}] [${filename}] 读取失败 ${error}`);
return false; return null;
} }
} }
@ -107,7 +107,7 @@ class Setting {
return true; return true;
} catch (error) { } catch (error) {
logger.error(`[${pluginName}] [${filename}] 写入失败 ${error}`); logger.error(`[${pluginName}] [${filename}] 写入失败 ${error}`);
return false; return null;
} }
} }
@ -212,7 +212,7 @@ class Setting {
const defSet = this.getdefSet(app); const defSet = this.getdefSet(app);
const config = this.getConfig(app); const config = this.getConfig(app);
if (!config[key]) { if (!config[key]) {
return false; return null;
} }
config[key] = config[key].filter(item => item !== value); config[key] = config[key].filter(item => item !== value);
return this.setYaml(app, 'config', { ...defSet, ...config }); return this.setYaml(app, 'config', { ...defSet, ...config });
@ -225,7 +225,7 @@ class Setting {
fs.writeFileSync(file, YAML.stringify(Object), 'utf8'); fs.writeFileSync(file, YAML.stringify(Object), 'utf8');
} catch (error) { } catch (error) {
logger.error(`[${app}] 写入失败 ${error}`); logger.error(`[${app}] 写入失败 ${error}`);
return false; return null;
} }
} }
@ -238,7 +238,7 @@ class Setting {
this[type][app] = YAML.parse(fs.readFileSync(file, 'utf8')); this[type][app] = YAML.parse(fs.readFileSync(file, 'utf8'));
} catch (error) { } catch (error) {
logger.error(`[${app}] 格式错误 ${error}`); logger.error(`[${app}] 格式错误 ${error}`);
return false; return null;
} }
this.watch(file, app, type); this.watch(file, app, type);
return this[type][app]; return this[type][app];

View file

@ -362,7 +362,7 @@ export class ZZZAvatarInfo {
/** @type {number|boolean} */ /** @type {number|boolean} */
get equip_score() { get equip_score() {
if (!this.equip?.length) return false; if (!this.equip?.length) return null;
if (this.scoreWeight) { if (this.scoreWeight) {
let score = 0; let score = 0;
for (const equip of this.equip) { for (const equip of this.equip) {
@ -370,7 +370,7 @@ export class ZZZAvatarInfo {
} }
return score; return score;
} }
return false; return null;
} }
/** @type {'C'|'B'|'A'|'S'|'SS'|'SSS'|'ACE'|'MAX'|false} */ /** @type {'C'|'B'|'A'|'S'|'SS'|'SSS'|'ACE'|'MAX'|false} */
@ -399,7 +399,7 @@ export class ZZZAvatarInfo {
if (this.equip_score >= 280) { if (this.equip_score >= 280) {
return 'MAX'; return 'MAX';
} }
return false; return null;
} }
/** @type {number} 练度分数 */ /** @type {number} 练度分数 */

View file

@ -20,7 +20,7 @@ async function init() {
return (await import('../../../../lib/config/config.js')).default.bot.log_level === 'debug'; return (await import('../../../../lib/config/config.js')).default.bot.log_level === 'debug';
} }
catch { catch {
return false; return null;
} }
})(); })();
await Promise.all(fs.readdirSync(path.join(damagePath, 'character')).filter(v => v !== '模板').map(v => importChar(v, isWatch))); await Promise.all(fs.readdirSync(path.join(damagePath, 'character')).filter(v => v !== '模板').map(v => importChar(v, isWatch)));

View file

@ -216,7 +216,7 @@ export class Equip {
if (this.score >= 48) { if (this.score >= 48) {
return 'MAX'; return 'MAX';
} }
return false; return null;
} }
} }

View file

@ -31,7 +31,7 @@ export class VhsSale {
if (this.sale_state.includes('Doing')) { if (this.sale_state.includes('Doing')) {
return true; return true;
} }
return false; return null;
} }
get state_label() { get state_label() {
if (this.sale_state.includes('Doing')) { if (this.sale_state.includes('Doing')) {
@ -96,7 +96,7 @@ export class ZZZNoteResp {
if (this.card_sign?.includes('Done')) { if (this.card_sign?.includes('Done')) {
return true; return true;
} }
return false; return null;
} }
get sign_label() { get sign_label() {