From f8d5c924198db10e2f5f7d147fb114870a06a29f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E4=B8=9E?= Date: Mon, 28 Jul 2025 00:24:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E4=B8=8D=E8=A7=84=E8=8C=83=E7=9A=84re?= =?UTF-8?q?turn=20false=E5=88=A0=E9=99=A4=E5=B9=B6=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E9=83=A8=E5=88=86=E4=B8=BAreturn=20null=EF=BC=8C=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E9=83=A8=E5=88=86return=20false=E4=BF=9D=E8=AF=81?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=AD=A3=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/abyss.js | 1 - apps/calendar.js | 3 --- apps/card.js | 6 +++--- apps/code.js | 1 - apps/damage.js | 2 +- apps/deadly.js | 1 - apps/gachalog.js | 25 ++++--------------------- apps/guide.js | 11 ++--------- apps/help.js | 2 -- apps/manage/alias.js | 2 -- apps/manage/assets.js | 4 ++-- apps/manage/config.js | 12 ------------ apps/manage/device.js | 5 ----- apps/manage/guides.js | 4 ---- apps/manage/panel.js | 14 -------------- apps/manage/version.js | 8 ++------ apps/monthly.js | 4 ---- apps/note.js | 2 +- apps/panel.js | 16 +++------------- apps/update.js | 4 ++-- apps/user.js | 12 +----------- apps/wiki.js | 6 ++---- lib/avatar.js | 4 ++-- lib/mysapi.js | 4 ++-- lib/score.js | 4 ++-- lib/settings.js | 12 ++++++------ model/avatar.js | 6 +++--- model/damage/avatar.js | 2 +- model/equip.js | 2 +- model/note.js | 4 ++-- 30 files changed, 42 insertions(+), 141 deletions(-) diff --git a/apps/abyss.js b/apps/abyss.js index 09d6acd..7b42254 100644 --- a/apps/abyss.js +++ b/apps/abyss.js @@ -33,7 +33,6 @@ export class Abyss extends ZZZPlugin { }); if (!abyssData?.has_data) { await this.reply('没有式舆防卫战数据'); - return false; } const abyss = new ZZZChallenge(abyssData); const timer = setTimeout(() => { diff --git a/apps/calendar.js b/apps/calendar.js index 5793cf6..56b09ab 100644 --- a/apps/calendar.js +++ b/apps/calendar.js @@ -27,7 +27,6 @@ export class Calendar extends ZZZPlugin { .then(res => res.json()); if (!activityList?.data) { await this.reply('获取活动列表失败'); - return false; } const t = activityList?.data?.t || new Date().getTime().toString(); const activityContent = await request @@ -43,7 +42,6 @@ export class Calendar extends ZZZPlugin { const htmlContent = calendarContent?.content || ''; if (!htmlContent) { await this.reply('未找到活动日历'); - return false; } const imgReg = //g; const imgSrc = imgReg.exec(htmlContent)?.[1]; @@ -52,6 +50,5 @@ export class Calendar extends ZZZPlugin { } else { await this.reply('未找到活动日历图片'); } - return false; } } diff --git a/apps/card.js b/apps/card.js index 62ec20b..5ef2f03 100644 --- a/apps/card.js +++ b/apps/card.js @@ -28,7 +28,7 @@ export class Card extends ZZZPlugin { this.reply(e.message); throw e; }); - if (!indexData) return false; + if (!indexData) return null; let zzzAvatarList = await api.getFinalData('zzzAvatarList', { deviceFp, @@ -36,7 +36,7 @@ export class Card extends ZZZPlugin { this.reply(e.message); throw e; }); - if (!zzzAvatarList) return false; + if (!zzzAvatarList) return null; indexData.avatar_list = zzzAvatarList.avatar_list; let zzzBuddyList = await api.getFinalData('zzzBuddyList', { @@ -45,7 +45,7 @@ export class Card extends ZZZPlugin { this.reply(e.message); throw e; }); - if (!zzzBuddyList) return false; + if (!zzzBuddyList) return null; indexData.buddy_list = zzzBuddyList.list; const finalIndexData = new ZZZIndexResp(indexData); this.e.playerCard.player.region_name = diff --git a/apps/code.js b/apps/code.js index 36dd20f..95c858c 100644 --- a/apps/code.js +++ b/apps/code.js @@ -22,6 +22,5 @@ export class Code extends ZZZPlugin { async code() { const msg = await getCodeMsg(); await this.reply(msg); - return false; } } diff --git a/apps/damage.js b/apps/damage.js index 6e1f043..5d45ee7 100644 --- a/apps/damage.js +++ b/apps/damage.js @@ -27,7 +27,7 @@ export class Damage extends ZZZPlugin { } const reg = new RegExp(`${rulePrefix}(.+)伤害(\\d*)$`) const match = this.e.msg.match(reg) - if (!match) return false + if (!match) return null const name = match[4] const data = getPanelOrigin(uid, name) if (data === false) { diff --git a/apps/deadly.js b/apps/deadly.js index a38317b..80d9f75 100644 --- a/apps/deadly.js +++ b/apps/deadly.js @@ -33,7 +33,6 @@ export class deadly extends ZZZPlugin { }); if (!deadlyData?.has_data) { await this.reply('没有危局强袭战数据'); - return false; } const deadly = new Deadly(deadlyData); const timer = setTimeout(() => { diff --git a/apps/gachalog.js b/apps/gachalog.js index 4c6566e..2360446 100644 --- a/apps/gachalog.js +++ b/apps/gachalog.js @@ -58,7 +58,6 @@ export class GachaLog extends ZZZPlugin { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { await this.reply('抽卡记录相应功能只支持国服'); - return false; } const allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false); const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []); @@ -70,7 +69,6 @@ export class GachaLog extends ZZZPlugin { at: true, recallMsg: 100, }); - return false; } if (!allowGroup) { if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) { @@ -82,7 +80,6 @@ export class GachaLog extends ZZZPlugin { recallMsg: 100, } ); - return false; } } else { if (blackList.length > 0 && blackList?.includes(currentGroup)) { @@ -94,7 +91,6 @@ export class GachaLog extends ZZZPlugin { recallMsg: 100, } ); - return false; } } await this.reply( @@ -115,7 +111,6 @@ export class GachaLog extends ZZZPlugin { if (msg.includes('取消')) { await this.reply('已取消', false, { at: true, recallMsg: 100 }); this.finish('gachaLog'); - return false; } const key = getQueryVariable(msg, 'authkey'); if (!key) { @@ -124,7 +119,6 @@ export class GachaLog extends ZZZPlugin { recallMsg: 100, }); this.finish('gachaLog'); - return false; } this.finish('gachaLog'); this.getLogWithOutUID(key); @@ -133,9 +127,8 @@ export class GachaLog extends ZZZPlugin { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { await this.reply('抽卡记录相应功能只支持国服'); - return false; } - if (!uid) return false; + if (!uid) return null; const lastQueryTime = await redis.get(`ZZZ:GACHA:${uid}:LASTTIME`); const gachaConfig = settings.getConfig('gacha'); const coldTime = _.get(gachaConfig, 'interval', 300); @@ -143,11 +136,9 @@ export class GachaLog extends ZZZPlugin { const key = await getAuthKey(this.e, this.User, uid); if (!key) { await this.reply('authKey获取失败,请检查cookie是否过期'); - return false; } if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) { await this.reply(`${coldTime}秒内只能刷新一次,请稍后再试`); - return false; } await redis.set(`ZZZ:GACHA:${uid}:LASTTIME`, Date.now()); this.getLog(key); @@ -157,7 +148,7 @@ export class GachaLog extends ZZZPlugin { } async getLog(key) { const uid = await this.getUID(); - if (!uid) return false; + if (!uid) return null; this.reply('抽卡记录获取中请稍等...可能需要一段时间,请耐心等待'); const { data, count } = await updateGachaLog(key, uid); let msg = []; @@ -170,7 +161,6 @@ export class GachaLog extends ZZZPlugin { await this.reply( await common.makeForwardMsg(this.e, msg.join('\n'), '抽卡记录更新成功') ); - return false; } async getLogWithOutUID(key) { await this.reply( @@ -201,7 +191,6 @@ export class GachaLog extends ZZZPlugin { at: true, recallMsg: 100, }); - return false; } const { data, count } = await updateGachaLog(key, uid); let msg = []; @@ -214,16 +203,14 @@ export class GachaLog extends ZZZPlugin { await this.reply( await common.makeForwardMsg(this.e, msg, '抽卡记录更新成功') ); - return false; } async gachaLogAnalysis() { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { await this.reply('抽卡记录相应功能只支持国服'); - return false; } - if (!uid) return false; + if (!uid) return null; await this.getPlayerInfo(); await this.reply('正在分析抽卡记录,请稍等', false, { at: true, @@ -239,7 +226,6 @@ export class GachaLog extends ZZZPlugin { recallMsg: 100, } ); - return false; } const result = { data, @@ -250,17 +236,14 @@ export class GachaLog extends ZZZPlugin { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { await this.reply('抽卡记录相应功能只支持国服'); - return false; } - if (!uid) return false; + if (!uid) return null; if (!this.e.isPrivate || this.e.isGroup) { await this.reply('请私聊获取抽卡链接', false, { at: true }); - return false; } const key = await getAuthKey(this.e, this.User, uid); if (!key) { await this.reply('authKey获取失败,请检查cookie是否过期'); - return false; } const link = await getZZZGachaLink(key); await this.reply(link); diff --git a/apps/guide.js b/apps/guide.js index 82fdd1c..33c1773 100644 --- a/apps/guide.js +++ b/apps/guide.js @@ -70,17 +70,14 @@ export class Guide extends ZZZPlugin { group = Number(group); if (group > guides.guideMaxNum) { await this.reply(`超过攻略数量(${guides.guideMaxNum})`); - return false; } if (alias === '设置默认' || alias === '设置所有') { - return false; } const name = char.aliasToName(alias); if (!name) { await this.reply('该角色不存在'); - return false; } if (group === 0) { @@ -102,7 +99,6 @@ export class Guide extends ZZZPlugin { if (msg.length) { await this.reply(await common.makeForwardMsg(this.e, msg)); } - return false; } const guidePath = await this.getGuidePath(group, name, !!isUpdate); @@ -112,10 +108,8 @@ export class Guide extends ZZZPlugin { guides.guideSources[group - 1] })\n请尝试其他的攻略来源查询` ); - return false; } await this.e.reply(segment.image(guidePath)); - return false; } /** 下载攻略图 */ @@ -130,7 +124,6 @@ export class Guide extends ZZZPlugin { } catch (error) { this.e.reply('暂无攻略数据,请稍后再试'); console.log(`米游社接口报错:${error}}`); - return false; } // 搜索时过滤特殊符号,譬如「11号」 @@ -160,7 +153,7 @@ export class Guide extends ZZZPlugin { } } if (!url) { - return false; + return null; } logger.debug( `${this.e.logFnc} 下载${name}攻略图 - ${guides.guideSources[group - 1]}` @@ -181,7 +174,7 @@ export class Guide extends ZZZPlugin { async getData(url) { let response = await fetch(url, { method: 'get' }); if (!response.ok) { - return false; + return null; } return await response.json(); } diff --git a/apps/help.js b/apps/help.js index 69ba16d..cc08162 100644 --- a/apps/help.js +++ b/apps/help.js @@ -412,11 +412,9 @@ export class Help extends ZZZPlugin { await this.render('help/index.html', { helpData: _helpData, }); - return false; } await this.render('help/index.html', { helpData, }); - return false; } } diff --git a/apps/manage/alias.js b/apps/manage/alias.js index 3f92cd5..72b9e15 100644 --- a/apps/manage/alias.js +++ b/apps/manage/alias.js @@ -4,7 +4,6 @@ import settings from '../../lib/settings.js'; export async function addAlias() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /添加(\S+)别名(\S+)$/g.exec(this.e.msg); const key = match[1]; @@ -35,7 +34,6 @@ export async function addAlias() { export async function deleteAlias() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /删除别名(\S+)$/g.exec(this.e.msg); const key = match[1]; diff --git a/apps/manage/assets.js b/apps/manage/assets.js index 98b3fb1..bb0940a 100644 --- a/apps/manage/assets.js +++ b/apps/manage/assets.js @@ -15,7 +15,7 @@ import { getAllWeaponID } from '../../lib/convert/weapon.js'; import * as LocalURI from '../../lib/download/const.js'; export async function downloadAll() { - if (!this.e.isMaster) return false; + if (!this.e.isMaster) return null; const charIDs = char.getAllCharactersID(); const equipSprites = getAllEquipID(); const weaponSprites = getAllWeaponID(); @@ -146,7 +146,7 @@ export async function downloadAll() { await this.reply(messages.join('\n')); } export async function deleteAll() { - if (!this.e.isMaster) return false; + if (!this.e.isMaster) return null; await this.reply( '【注意】正在删除所有资源图片,后续使用需要重新下载!', false, diff --git a/apps/manage/config.js b/apps/manage/config.js index e6a7161..e056e4f 100644 --- a/apps/manage/config.js +++ b/apps/manage/config.js @@ -4,7 +4,6 @@ import settings from '../../lib/settings.js'; export async function setRenderPrecision() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /渲染精度(\d+)$/g.exec(this.e.msg); const render_precision = Number(match[1]); @@ -13,14 +12,12 @@ export async function setRenderPrecision() { at: true, recallMsg: 100, }); - return false; } if (render_precision > 200) { await this.e.reply('渲染精度不能大于200', false, { at: true, recallMsg: 100, }); - return false; } settings.setSingleConfig('config', 'render', { scale: render_precision, @@ -32,7 +29,6 @@ export async function setRenderPrecision() { export async function setRefreshGachaInterval() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /刷新抽卡间隔(\d+)$/g.exec(this.e.msg); const refresh_gacha_interval = Number(match[1]); @@ -41,14 +37,12 @@ export async function setRefreshGachaInterval() { at: true, recallMsg: 100, }); - return false; } if (refresh_gacha_interval > 1000) { await this.e.reply('刷新抽卡间隔不能大于1000秒', false, { at: true, recallMsg: 100, }); - return false; } settings.setSingleConfig('gacha', 'interval', refresh_gacha_interval); await this.e.reply(`绝区零刷新抽卡间隔已设置为: ${refresh_gacha_interval}`); @@ -58,7 +52,6 @@ export async function setRefreshGachaInterval() { export async function setRefreshPanelInterval() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /刷新面板间隔(\d+)$/g.exec(this.e.msg); const refresh_panel_interval = Number(match[1]); @@ -67,14 +60,12 @@ export async function setRefreshPanelInterval() { at: true, recallMsg: 100, }); - return false; } if (refresh_panel_interval > 1000) { await this.e.reply('刷新面板间隔不能大于1000秒', false, { at: true, recallMsg: 100, }); - return false; } settings.setSingleConfig('panel', 'interval', refresh_panel_interval); await this.e.reply( @@ -88,7 +79,6 @@ export async function setRefreshPanelInterval() { export async function setRefreshCharInterval() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /刷新角色间隔(\d+)$/g.exec(this.e.msg); const refresh_char_interval = Number(match[1]); @@ -97,14 +87,12 @@ export async function setRefreshCharInterval() { at: true, recallMsg: 100, }); - return false; } if (refresh_char_interval > 1000) { await this.e.reply('刷新角色间隔不能大于1000秒', false, { at: true, recallMsg: 100, }); - return false; } settings.setSingleConfig('panel', 'roleInterval', refresh_char_interval); await this.e.reply(`绝区零刷新角色间隔已设置为: ${refresh_char_interval}秒`); diff --git a/apps/manage/device.js b/apps/manage/device.js index d65f25c..52111cb 100644 --- a/apps/manage/device.js +++ b/apps/manage/device.js @@ -3,7 +3,6 @@ import settings from '../../lib/settings.js'; export async function setDefaultDevice() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } this.setContext('toSetDefaultDevice'); await this.reply( @@ -16,18 +15,15 @@ export async function toSetDefaultDevice() { const msg = this.e.msg.trim(); if (!msg) { this.reply('请发送设备信息', false, { at: true, recallMsg: 100 }); - return false; } if (msg.includes('取消')) { await this.reply('已取消', false, { at: true, recallMsg: 100 }); this.finish('toSetDefaultDevice'); - return false; } try { const info = JSON.parse(msg); if (!info) { this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); - return false; } if ( !info?.deviceName || @@ -38,7 +34,6 @@ export async function toSetDefaultDevice() { !info?.deviceProduct ) { this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); - return false; } settings.setConfig('device', { productName: info.deviceProduct, diff --git a/apps/manage/guides.js b/apps/manage/guides.js index 05b3fe0..cc15008 100644 --- a/apps/manage/guides.js +++ b/apps/manage/guides.js @@ -5,7 +5,6 @@ import settings from '../../lib/settings.js'; export async function setDefaultGuide() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg); let guide_id = match[1]; @@ -37,7 +36,6 @@ export async function setDefaultGuide() { export async function setMaxForwardGuide() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg); const max_forward_guide = Number(match[1]); @@ -46,14 +44,12 @@ export async function setMaxForwardGuide() { at: true, recallMsg: 100, }); - return false; } if (max_forward_guide > guides.guideMaxNum) { await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, { at: true, recallMsg: 100, }); - return false; } settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide); await this.e.reply( diff --git a/apps/manage/panel.js b/apps/manage/panel.js index dcc45f3..ffbadc1 100644 --- a/apps/manage/panel.js +++ b/apps/manage/panel.js @@ -7,18 +7,15 @@ import path from 'path'; export async function uploadCharacterImg() { if (!this.e.isMaster) { this.reply('只有主人才能添加', false, { at: true, recallMsg: 100 }); - return false; } const reg = /(上传|添加)(.+)(角色|面板)图$/; const match = this.e.msg.match(reg); if (!match) { - return false; } const charName = match[2].trim(); const name = char.aliasToName(charName); if (!name) { this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); - return false; } const images = []; // 下面方法来源于miao-plugin/apps/character/ImgUpload.js @@ -75,7 +72,6 @@ export async function uploadCharacterImg() { false, { at: true, recallMsg: 100 } ); - return false; } const resourcesImagesPath = imageResourcesPath; const panelImagesPath = path.join(resourcesImagesPath, `panel/${name}`); @@ -100,21 +96,18 @@ export async function uploadCharacterImg() { at: true, recallMsg: 100, }); - return false; } export async function getCharacterImages() { const reg = /(获取|查看)(.+)(角色|面板)图(\d+)?$/; const match = this.e.msg.match(reg); if (!match) { - return false; } const charName = match[2].trim(); const name = char.aliasToName(charName); let page = match[4]; if (!name) { this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); - return false; } const pageSize = 5; const resourcesImagesPath = imageResourcesPath; @@ -132,7 +125,6 @@ export async function getCharacterImages() { const end = page * pageSize; if (start >= images.length) { this.reply('哪有这么多图片', false, { at: true, recallMsg: 100 }); - return false; } const imagePaths = images.slice(start, end); const imageMsg = imagePaths.map(imagePath => { @@ -150,25 +142,20 @@ export async function getCharacterImages() { ); if (imageMsg.length) await this.reply(await common.makeForwardMsg(this.e, imageMsg)); - - return false; } export async function deleteCharacterImg() { if (!this.e.isMaster) { this.reply('只有主人才能删除', false, { at: true, recallMsg: 100 }); - return false; } const reg = /(删除)(.+)(角色|面板)图(.+)$/; const match = this.e.msg.match(reg); if (!match) { - return false; } const charName = match[2].trim(); const name = char.aliasToName(charName); if (!name) { this.reply('未找到对应角色', false, { at: true, recallMsg: 100 }); - return false; } const ids = match[4].split(/[,,、\s]+/); const resourcesImagesPath = imageResourcesPath; @@ -196,5 +183,4 @@ export async function deleteCharacterImg() { '删除后会重新排序ID,若想要再次删除,请重新获取图片列表,否则可能会删除错误的图片。', ]; this.reply(common.makeForwardMsg(this.e, msgs)); - return false; } diff --git a/apps/manage/version.js b/apps/manage/version.js index 0c17330..d0ed4b0 100644 --- a/apps/manage/version.js +++ b/apps/manage/version.js @@ -8,11 +8,10 @@ export async function getChangeLog() { await this.render('help/version.html', { versionData, }); - return false; } export async function getCommitLog() { - if (!ZZZUpdate) return false; + if (!ZZZUpdate) return null; let updatePlugin = new ZZZUpdate(); updatePlugin.e = this.e; updatePlugin.reply = this.reply; @@ -33,7 +32,7 @@ export async function getCommitLog() { } export async function hasUpdate() { - if (!ZZZUpdate) return false; + if (!ZZZUpdate) return null; let updatePlugin = new ZZZUpdate(); updatePlugin.e = this.e; updatePlugin.reply = this.reply; @@ -55,7 +54,6 @@ export async function hasUpdate() { export async function enableAutoUpdatePush() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } let enable = true; if (this.e.msg.includes('关闭')) { @@ -73,7 +71,6 @@ export async function enableAutoUpdatePush() { export async function setCheckUpdateCron() { if (!this.e.isMaster) { this.reply('仅限主人设置', false, { at: true, recallMsg: 100 }); - return false; } const cron = this.e.msg.split('时间')[1]; if (!cron) { @@ -85,7 +82,6 @@ export async function setCheckUpdateCron() { recallMsg: 100, } ); - return false; } settings.setSingleConfig('config', 'update', { cron }); await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, { diff --git a/apps/monthly.js b/apps/monthly.js index bbe8e55..eb6dcf8 100644 --- a/apps/monthly.js +++ b/apps/monthly.js @@ -31,7 +31,6 @@ export class monthly extends ZZZPlugin { const match = this.e.msg.match(reg); if (!match) { await this.reply('参数错误,请检查输入'); - return false; } let year = match[3]; let month = match[5]; @@ -47,11 +46,9 @@ export class monthly extends ZZZPlugin { }); if (!monthlyResponse) { await this.reply('获取月报数据失败,请检查日期是否正确'); - return false; } if (!monthlyResponse?.month_data) { await this.reply('月报数据为空'); - return false; } const monthlyData = new Monthly(monthlyResponse); const finalData = { @@ -73,7 +70,6 @@ export class monthly extends ZZZPlugin { if (!collect) { await this.reply('获取月报数据失败'); - return false; } const collectData = collect.map(item => new Monthly(item)); diff --git a/apps/note.js b/apps/note.js index b9d25e3..548f9b0 100644 --- a/apps/note.js +++ b/apps/note.js @@ -28,7 +28,7 @@ export class Note extends ZZZPlugin { this.reply(e.message); throw e; }); - if (!noteResponse) return false; + if (!noteResponse) return null; const noteData = new ZZZNoteResp(noteResponse); const finalData = { note: noteData, diff --git a/apps/panel.js b/apps/panel.js index 2175a9d..7126189 100644 --- a/apps/panel.js +++ b/apps/panel.js @@ -51,7 +51,6 @@ export class Panel extends ZZZPlugin { if (!pre || suf === '列表') return await this.getCharPanelList(); const queryPanelReg = new RegExp(`${rulePrefix}(.*)面板$`); if (queryPanelReg.test(this.e.msg)) return await this.getCharPanel(); - return false; } async refreshPanel() { @@ -61,7 +60,6 @@ export class Panel extends ZZZPlugin { const coldTime = _.get(panelSettings, 'interval', 300); if (lastQueryTime && Date.now() - lastQueryTime < 1000 * coldTime) { await this.reply(`${coldTime}秒内只能更新一次,请稍后再试`); - return false; } const isEnka = this.e.msg.includes('展柜') || !(await getCk(this.e)) let result @@ -102,7 +100,7 @@ export class Panel extends ZZZPlugin { return this.reply(`面板列表更新失败,请稍后再试或尝试%更新展柜面板:\n${errorMsg.trim()}`); } } - if (!result) return false; + if (!result) return; const newChar = result.filter(item => item.isNew); const finalData = { newChar: newChar.length, @@ -116,7 +114,6 @@ export class Panel extends ZZZPlugin { const result = getPanelList(uid); if (!result.length) { await this.reply(`UID:${uid}无本地面板数据,请先%更新面板 或 %更新展柜面板`); - return false; } const hasCk = !!(await getCk(this.e)); await this.getPlayerInfo(hasCk ? undefined : parsePlayerInfo({ uid })); @@ -138,7 +135,7 @@ export class Panel extends ZZZPlugin { async getCharPanelListTool(uid, origin = false) { if (!uid) { - return false; + return null; } if (origin) { const result = getPanelListOrigin(uid); @@ -152,7 +149,7 @@ export class Panel extends ZZZPlugin { const uid = await this.getUID(); const reg = new RegExp(`${rulePrefix}(.+)面板$`); const match = this.e.msg.match(reg); - if (!match) return false; + if (!match) return; const name = match[4]; const data = getPanelOrigin(uid, name); if (data === false) { @@ -169,7 +166,6 @@ export class Panel extends ZZZPlugin { needSave: false, }); } - return false; } async getCharPanelTool(e, _data = {}) { @@ -185,11 +181,9 @@ export class Panel extends ZZZPlugin { } = _data; if (!uid) { await this.reply('UID为空'); - return false; } if (!data) { await this.reply('数据为空'); - return false; } if (needSave) { updatePanelData(uid, [data]); @@ -236,7 +230,6 @@ export class Panel extends ZZZPlugin { const result = getPanelList(uid); if (!result) { await this.reply('未找到面板数据,请先%更新面板 或 %更新展柜面板'); - return false; } await this.getPlayerInfo(); result.sort((a, b) => { @@ -294,14 +287,11 @@ export class Panel extends ZZZPlugin { const id = source?.message_id; if (!id) { await this.reply('未找到消息源,请引用要查看的图片'); - return false; } const image = await redis.get(`ZZZ:PANEL:IMAGE:${id}`); if (!image) { await this.reply('未找到原图'); - return false; } await this.reply(segment.image(image)); - return false; } } diff --git a/apps/update.js b/apps/update.js index 590a67e..fc4034f 100644 --- a/apps/update.js +++ b/apps/update.js @@ -34,7 +34,7 @@ export class update extends plugin { } async update(e = this.e) { - if (!e.isMaster || !ZZZUpdate) return false; + if (!e.isMaster || !ZZZUpdate) return null; e.msg = `#${e.msg.includes('强制') ? '强制' : ''}更新${pluginName}`; const up = new ZZZUpdate(e); up.e = e; @@ -45,7 +45,7 @@ export class update extends plugin { const updateConfig = _.get(settings.getConfig('config'), 'update', {}); const enable = _.get(updateConfig, 'autoCheck', false); if (!enable) return; - if (!ZZZUpdate) return false; + if (!ZZZUpdate) return null; const up = new ZZZUpdate(); const result = await up.hasUpdate(); if (result.hasUpdate) { diff --git a/apps/user.js b/apps/user.js index bb32b7d..0322092 100644 --- a/apps/user.js +++ b/apps/user.js @@ -31,7 +31,6 @@ export class User extends ZZZPlugin { const uid = await this.getUID(); if (/^(1[0-9])[0-9]{8}/i.test(uid)) { await this.reply('国际服不需要绑定设备'); - return false; } //先throw一步( this.setContext('toBindDevice'); @@ -46,30 +45,25 @@ export class User extends ZZZPlugin { if (!ltuid) { this.reply('未绑定UID'); this.finish('toBindDevice'); - return false; } const msg = this.e.msg.trim(); if (!msg) { this.reply('请发送设备信息', false, { at: true, recallMsg: 100 }); - return false; } if (msg.includes('取消')) { await this.reply('已取消', false, { at: true, recallMsg: 100 }); this.finish('toBindDevice'); - return false; } try { const info = JSON.parse(msg); if (!info) { this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); - return false; } 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}:ID`, info.device_id); await this.reply('绑定设备成功', false, { at: true, recallMsg: 100 }); this.finish('toBindDevice'); - return false; } if ( !info?.deviceName || @@ -81,28 +75,24 @@ export class User extends ZZZPlugin { !info?.deviceProduct ) { this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); - return false; } await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`); await redis.set(`ZZZ:DEVICE_FP:${ltuid}:BIND`, JSON.stringify(info)); const { deviceFp } = await this.getAPI(); if (!deviceFp) { await this.reply('绑定设备失败'); - return false; } logger.debug(`[LTUID:${ltuid}]绑定设备成功,deviceFp:${deviceFp}`); await this.reply(`绑定设备成功${this.e.isGroup ? '\n请撤回设备信息' : ''}`, false, { at: true, recallMsg: 100 }); } catch (error) { this.reply('设备信息格式错误', false, { at: true, recallMsg: 100 }); - return false; } finally { this.finish('toBindDevice'); - return false; } } async deleteBind() { 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(); await redis.del(`ZZZ:DEVICE_FP:${ltuid}:FP`); await redis.del(`ZZZ:DEVICE_FP:${ltuid}:BIND`); diff --git a/apps/wiki.js b/apps/wiki.js index 0a8aa80..9c4cb05 100644 --- a/apps/wiki.js +++ b/apps/wiki.js @@ -54,7 +54,7 @@ export class Wiki extends ZZZPlugin { logger.debug('skills'); const reg = new RegExp(`${rulePrefix}(.*)天赋(.*)$`); 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 levels = !!levelsChar ? levelsChar.split('.').map(x => { @@ -81,7 +81,6 @@ export class Wiki extends ZZZPlugin { !isSkillLevelLegal('CoreLevel', CoreLevel) ) { await this.reply(`${charname}天赋等级参数不合法`); - return false; } const charData = await getHakushCharacterData(charname); if (!charData) @@ -104,12 +103,11 @@ export class Wiki extends ZZZPlugin { async cinema() { const reg = new RegExp(`${rulePrefix}(.*)(意象影画|意象|影画|命座)$`); const charname = this.e.msg.match(reg)[4]; - if (!charname) return false; + if (!charname) return null; const charData = await getHakushCharacterData(charname); const cinemaData = charData?.Talent; if (!cinemaData) { await this.reply(`未找到${charname}的数据`); - return false; } await charData.get_assets(); const finalData = { diff --git a/lib/avatar.js b/lib/avatar.js index 3ea10c2..fbe9ea0 100644 --- a/lib/avatar.js +++ b/lib/avatar.js @@ -149,7 +149,7 @@ export const getPanelListOrigin = uid => { export const getPanel = (uid, name) => { // 通过名称(包括别名)获取角色 ID const id = char.aliasToID(name); - if (!id) return false; + if (!id) return null; const _data = getPanelData(uid); // 获取所有面板数据 const data = _data.map(item => new ZZZAvatarInfo(item)); @@ -167,7 +167,7 @@ export const getPanel = (uid, name) => { */ export const getPanelOrigin = (uid, name) => { const id = char.aliasToID(name); - if (!id) return false; + if (!id) return null; const data = getPanelData(uid); // 通过 ID 获取角色数据 const result = data.find(item => item.id === id); diff --git a/lib/mysapi.js b/lib/mysapi.js index 4344640..73308c1 100644 --- a/lib/mysapi.js +++ b/lib/mysapi.js @@ -77,7 +77,7 @@ export default class MysZZZApi extends MysApi { data.deviceId = this._device; // 获取请求地址 const urlMap = this.apiTool.getUrlMap(data); - if (!urlMap[type]) return false; + if (!urlMap[type]) return null; // 获取请求参数(即APITool中默认的请求参数,此参数理应是不可获取的,详细请参照 lib/mysapi/tool.js`) let { url, @@ -381,7 +381,7 @@ export default class MysZZZApi extends MysApi { } const result = await this.getData(type, data, cached); 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; } } diff --git a/lib/score.js b/lib/score.js index e883e69..80ab9a4 100644 --- a/lib/score.js +++ b/lib/score.js @@ -13,8 +13,8 @@ export const scoreWeight = {}; * @returns {{ [propID: string]: number }} */ export function formatScoreWeight(oriScoreWeight) { - if (!oriScoreWeight) return false; - if (typeof oriScoreWeight !== 'object') return false; + if (!oriScoreWeight) return null; + if (typeof oriScoreWeight !== 'object') return null; const weight = {}; for (const propName in oriScoreWeight) { if (!oriScoreWeight[propName]) diff --git a/lib/settings.js b/lib/settings.js index 4ec5dc0..36730b8 100644 --- a/lib/settings.js +++ b/lib/settings.js @@ -75,12 +75,12 @@ class Setting { filepath = path.join(this.dataPath, filepath); try { if (!fs.existsSync(path.join(filepath, filename))) { - return false; + return null; } return YAML.parse(fs.readFileSync(path.join(filepath, filename), 'utf8')); } catch (error) { logger.error(`[${pluginName}] [${filename}] 读取失败 ${error}`); - return false; + return null; } } @@ -107,7 +107,7 @@ class Setting { return true; } catch (error) { logger.error(`[${pluginName}] [${filename}] 写入失败 ${error}`); - return false; + return null; } } @@ -212,7 +212,7 @@ class Setting { const defSet = this.getdefSet(app); const config = this.getConfig(app); if (!config[key]) { - return false; + return null; } config[key] = config[key].filter(item => item !== value); return this.setYaml(app, 'config', { ...defSet, ...config }); @@ -225,7 +225,7 @@ class Setting { fs.writeFileSync(file, YAML.stringify(Object), 'utf8'); } catch (error) { logger.error(`[${app}] 写入失败 ${error}`); - return false; + return null; } } @@ -238,7 +238,7 @@ class Setting { this[type][app] = YAML.parse(fs.readFileSync(file, 'utf8')); } catch (error) { logger.error(`[${app}] 格式错误 ${error}`); - return false; + return null; } this.watch(file, app, type); return this[type][app]; diff --git a/model/avatar.js b/model/avatar.js index bbd0ac5..af03b58 100644 --- a/model/avatar.js +++ b/model/avatar.js @@ -362,7 +362,7 @@ export class ZZZAvatarInfo { /** @type {number|boolean} */ get equip_score() { - if (!this.equip?.length) return false; + if (!this.equip?.length) return null; if (this.scoreWeight) { let score = 0; for (const equip of this.equip) { @@ -370,7 +370,7 @@ export class ZZZAvatarInfo { } return score; } - return false; + return null; } /** @type {'C'|'B'|'A'|'S'|'SS'|'SSS'|'ACE'|'MAX'|false} */ @@ -399,7 +399,7 @@ export class ZZZAvatarInfo { if (this.equip_score >= 280) { return 'MAX'; } - return false; + return null; } /** @type {number} 练度分数 */ diff --git a/model/damage/avatar.js b/model/damage/avatar.js index abb32ff..f9f7eeb 100644 --- a/model/damage/avatar.js +++ b/model/damage/avatar.js @@ -20,7 +20,7 @@ async function init() { return (await import('../../../../lib/config/config.js')).default.bot.log_level === 'debug'; } catch { - return false; + return null; } })(); await Promise.all(fs.readdirSync(path.join(damagePath, 'character')).filter(v => v !== '模板').map(v => importChar(v, isWatch))); diff --git a/model/equip.js b/model/equip.js index 4fb1f6c..9d042d5 100644 --- a/model/equip.js +++ b/model/equip.js @@ -216,7 +216,7 @@ export class Equip { if (this.score >= 48) { return 'MAX'; } - return false; + return null; } } diff --git a/model/note.js b/model/note.js index 7b3126c..ecde961 100644 --- a/model/note.js +++ b/model/note.js @@ -31,7 +31,7 @@ export class VhsSale { if (this.sale_state.includes('Doing')) { return true; } - return false; + return null; } get state_label() { if (this.sale_state.includes('Doing')) { @@ -96,7 +96,7 @@ export class ZZZNoteResp { if (this.card_sign?.includes('Done')) { return true; } - return false; + return null; } get sign_label() {