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)