From 64c884cddb5cc4b3f16e0ebcf8025242cb97e45f Mon Sep 17 00:00:00 2001 From: leiyilu <1509167646@qq.com> Date: Tue, 26 Jul 2022 08:46:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E4=BA=BA=E6=9D=83=E9=99=90=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3=E5=8F=8A=E6=9B=B4=E6=96=B0=E6=88=90=E5=8A=9F=E5=90=8E?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- adapter/mys.js | 17 ++++++++++++++++- index.js | 40 +++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 16 deletions(-) diff --git a/adapter/mys.js b/adapter/mys.js index fd41d0a..1dbde8e 100644 --- a/adapter/mys.js +++ b/adapter/mys.js @@ -110,5 +110,20 @@ export async function getMysApi (e, cfg) { } export async function checkAuth (e, cfg) { - return new User({ id: e.user_id }) + let { auth = 'all' } = cfg + let uid = await MysInfo.getUid(e) + if (!uid) return false + + if (auth === 'master' && !e.isMaster) { + return false + } + + /* 检查user ck */ + let isCookieUser = await MysInfo.checkUidBing(uid) + if (auth === 'cookie' && !isCookieUser) { + e.reply('尚未绑定Cookie...') + return false + } + e.selfUser = new User({ id: e.user_id, uid }) + return e.selfUser } diff --git a/index.js b/index.js index e99a1ea..b9f961f 100644 --- a/index.js +++ b/index.js @@ -1,26 +1,36 @@ // 适配V3 Yunzai,将index.js移至app/index.js -import { currentVersion, isV3 } from './components/Changelog.js' +import { + currentVersion, + isV3 +} from './components/Changelog.js' import Data from './components/Data.js' export * from './apps/index.js' -let index = { atlas: {} } +let index = { + atlas: {} +} if (isV3) { - index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js') - console.log(index) + index = await Data.importModule('/plugins/xiaoyao-cvs-plugin/adapter', 'index.js') + console.log(index) } export const atlas = index.atlas || {} console.log(`图鉴插件${currentVersion}初始化~`) -setTimeout(async function () { - let msgStr = await redis.get('xiaoyao:restart-msg') - let relpyPrivate = async function () { - } - if (msgStr) { - let msg = JSON.parse(msgStr) - await relpyPrivate(msg.qq, msg.msg) - await redis.del('xiaoyao:restart-msg') - let msgs = [`当前图鉴版本: ${currentVersion}`, '您可使用 #图鉴版本 命令查看更新信息'] - await relpyPrivate(msg.qq, msgs.join('\n')) - } +setTimeout(async function() { + let msgStr = await redis.get('xiaoyao:restart-msg') + let relpyPrivate = async function() {} + if (!isV3) { + let common = await Data.importModule('/lib', 'common.js') + if (common && common.default && common.default.relpyPrivate) { + relpyPrivate = common.default.relpyPrivate + } + } + if (msgStr) { + let msg = JSON.parse(msgStr) + await relpyPrivate(msg.qq, msg.msg) + await redis.del('xiaoyao:restart-msg') + let msgs = [`当前图鉴版本: ${currentVersion}`, '您可使用 #图鉴版本 命令查看更新信息'] + await relpyPrivate(msg.qq, msgs.join('\n')) + } }, 1000)