From 498982b9ea881aacf96d7e78c7c4c407cafa5607 Mon Sep 17 00:00:00 2001 From: yoimiya-kokomi <592981798@qq.com> Date: Mon, 31 Oct 2022 02:22:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E4=B8=8A=E4=BC=A0=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E5=9B=BE=E5=83=8F=E7=9A=84=E6=9D=83=E9=99=90=E6=A3=80?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/character/ImgUpload.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/character/ImgUpload.js b/apps/character/ImgUpload.js index ebd3bec3..8daef0c6 100644 --- a/apps/character/ImgUpload.js +++ b/apps/character/ImgUpload.js @@ -118,31 +118,27 @@ async function isAllowedToUploadCharacterImage (e) { if (!e.msg) { return false } - - // 由于添加角色图是全局,暂时屏蔽非管理员的添加 - if (e.isPrivate) { - if (!e.isMaster) { - e.reply('只有主人才能添加。') - return false - } + // master直接返回true + if (e.isMaster) { return true } - + if (e.isPrivate) { + e.reply('只有主人才能添加...') + return false + } let groupId = e.group_id if (!groupId) { return false } - if (e.groupConfig?.imgAddLimit === 2) { - if (!e.isMaster) { - e.reply('只有主人才能添加。') - return false - } + const addLimit = e.groupConfig?.imgAddLimit || 2 + const isAdmin = ['owner', 'admin'].includes(e.sender.role) + if (addLimit === 2) { + e.reply('只有主人才能添加...') + return false } - if (e.groupConfig?.imgAddLimit === 1 && !e.isMaster) { - if (!(e.sender.role === 'owner' || e.sender.role === 'admin')) { - e.reply('只有管理员才能添加。') - return false - } + if (addLimit === 1 && !isAdmin) { + e.reply('只有管理员才能添加...') + return false } return true }