mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
将不规范的return false删除并替换部分为return null,保留部分return false保证功能正常
This commit is contained in:
parent
0c53e71af6
commit
f8d5c92419
30 changed files with 42 additions and 141 deletions
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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 = /<img.*?src="(.*?)".*?>/g;
|
||||
const imgSrc = imgReg.exec(htmlContent)?.[1];
|
||||
|
|
@ -52,6 +50,5 @@ export class Calendar extends ZZZPlugin {
|
|||
} else {
|
||||
await this.reply('未找到活动日历图片');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 =
|
||||
|
|
|
|||
|
|
@ -22,6 +22,5 @@ export class Code extends ZZZPlugin {
|
|||
async code() {
|
||||
const msg = await getCodeMsg();
|
||||
await this.reply(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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(() => {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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}秒`);
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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, {
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
12
apps/user.js
12
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`);
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -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} 练度分数 */
|
||||
|
|
|
|||
|
|
@ -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)));
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ export class Equip {
|
|||
if (this.score >= 48) {
|
||||
return 'MAX';
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue