From 3fef51cdf96a7c3a5bd511a3140f7d7afc36d915 Mon Sep 17 00:00:00 2001 From: bietiaop <1527109126@qq.com> Date: Sun, 4 Aug 2024 16:18:16 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E5=8A=A8=E5=BC=80=E5=90=AF/?= =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=BE=A4=E8=81=8A=E9=80=9A=E8=BF=87=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E5=88=B7=E6=96=B0=E6=8A=BD=E5=8D=A1=E8=AE=B0=E5=BD=95?= =?UTF-8?q?&=E9=93=BE=E6=8E=A5=E5=88=B7=E6=96=B0=E6=8A=BD=E5=8D=A1?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E9=BB=91=E7=99=BD=E5=90=8D=E5=8D=95#38?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/gachalog.js | 88 ++++++++++++++++++++++++++++++++++++++++------- defSet/gacha.yaml | 6 ++++ guoba.support.js | 43 +++++++++++++++++++++++ 3 files changed, 124 insertions(+), 13 deletions(-) diff --git a/apps/gachalog.js b/apps/gachalog.js index a352176..56a4779 100644 --- a/apps/gachalog.js +++ b/apps/gachalog.js @@ -60,22 +60,69 @@ export class GachaLog extends ZZZPlugin { await this.reply(reply_msg); } async startGachaLog() { + const allowGroup = _.get(settings.getConfig('gacha'), 'allow_group', false); + const whiteList = _.get(settings.getConfig('gacha'), 'white_list', []); + const blackList = _.get(settings.getConfig('gacha'), 'black_list', []); if (!this.e.isPrivate) { - await this.reply('请私聊发送抽卡链接', false, { at: true }); - return false; + const currentGroup = this.e?.group_id; + if (!currentGroup) { + await this.reply('获取群聊ID失败,请尝试私聊发送抽卡链接', false, { + at: true, + recallMsg: 100, + }); + return false; + } + if (!allowGroup) { + if (whiteList.length <= 0 || !whiteList?.includes(currentGroup)) { + await this.reply( + '当前群聊未开启链接刷新抽卡记录功能,请私聊发送', + false, + { + at: true, + recallMsg: 100, + } + ); + return false; + } + } else { + if (blackList.length > 0 && blackList?.includes(currentGroup)) { + await this.reply( + '当前群聊未开启链接刷新抽卡记录功能,请私聊发送', + false, + { + at: true, + recallMsg: 100, + } + ); + return false; + } + } + await this.reply( + '请注意,当前在群聊中发送抽卡链接,包含authkey,其他人获取authkey可能导致未知后果,请谨慎操作,请在机器人回复你获取链接成功后及时撤回抽卡链接消息。', + false, + { at: true, recallMsg: 100 } + ); } this.setContext('gachaLog'); - await this.reply('请发送抽卡链接', false, { at: true }); + await this.reply( + '请发送抽卡链接,发送“取消”即可取消本次抽卡链接刷新', + false, + { at: true, recallMsg: 100 } + ); } async gachaLog() { - if (!this.e.isPrivate) { - await this.reply('请私聊发送抽卡链接', false, { at: true }); + const msg = this.e.msg.trim(); + if (msg.includes('取消')) { + await this.reply('已取消', false, { at: true, recallMsg: 100 }); + this.finish('gachaLog'); return false; } - const msg = this.e.msg.trim(); const key = getQueryVariable(msg, 'authkey'); if (!key) { - await this.reply('抽卡链接格式错误,请重新发送'); + await this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, { + at: true, + recallMsg: 100, + }); this.finish('gachaLog'); return false; } @@ -124,6 +171,11 @@ export class GachaLog extends ZZZPlugin { return false; } async getLogWithOutUID(key) { + await this.reply( + '抽卡链接解析成功,正在查询抽卡记录,可能耗费一段时间,请勿重复发送', + false, + { at: true, recallMsg: 100 } + ); /** @type {string} */ let uid; queryLabel: for (const name in gacha_type_meta_data) { @@ -143,10 +195,12 @@ export class GachaLog extends ZZZPlugin { } } if (!uid) { - await this.reply('未查询到uid,请检查链接是否正确'); + await this.reply('未查询到uid,请检查链接是否正确', false, { + at: true, + recallMsg: 100, + }); return false; } - this.reply('抽卡记录获取中请稍等...可能需要一段时间,请耐心等待'); const { data, count } = await updateGachaLog(key, uid); let msg = []; msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`); @@ -167,12 +221,20 @@ export class GachaLog extends ZZZPlugin { return false; } await this.getPlayerInfo(); - await this.reply( - '正在分析抽卡记录,首次下载图片资源可能耗费一些时间,请稍等' - ); + await this.reply('正在分析抽卡记录,请稍等', false, { + at: true, + recallMsg: 100, + }); const data = await anaylizeGachaLog(uid); if (!data) { - await this.reply('未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录'); + await this.reply( + '未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录', + false, + { + at: true, + recallMsg: 100, + } + ); return false; } const result = { diff --git a/defSet/gacha.yaml b/defSet/gacha.yaml index b3957a7..104bcaf 100644 --- a/defSet/gacha.yaml +++ b/defSet/gacha.yaml @@ -1 +1,7 @@ interval: 60 # 刷新抽卡记录的时间间隔(单位:秒) +allow_group: false # 是否允许群组使用刷新抽卡功能 +white_list: # 白名单群组 + - 123456789 +black_list: # 黑名单群组 + - 987654321 +# 如果 allow_group 为 false,则 white_list 会生效,否则 black_list 会生效 \ No newline at end of file diff --git a/guoba.support.js b/guoba.support.js index a1e8481..754c583 100644 --- a/guoba.support.js +++ b/guoba.support.js @@ -67,6 +67,49 @@ export function supportGuoba() { placeholder: '请输入数字', }, }, + { + field: 'gacha.allow_group', + label: '群聊链接刷新', + bottomHelpMessage: '是否允许群聊通过发送链接刷新抽卡记录', + component: 'Switch', + }, + { + field: 'gacha.white_list', + label: '白名单群聊', + bottomHelpMessage: '在关闭群聊链接刷新时,允许通过链接刷新的群聊', + component: 'Select', + componentProps: { + mode: 'multiple', + options: allGroup, + }, + }, + { + field: 'gacha.black_list', + label: '黑名单群聊', + bottomHelpMessage: '在开启群聊链接刷新时,禁止通过链接刷新的群聊', + component: 'Select', + componentProps: { + mode: 'multiple', + options: allGroup, + }, + }, + { + component: 'Divider', + label: '深渊设置', + }, + { + field: 'abyss.interval', + label: '冷却时间', + bottomHelpMessage: + '设置刷新深渊信息的冷却时间,单位为秒,取值范围为0~1000', + component: 'InputNumber', + required: true, + componentProps: { + min: 0, + max: 1000, + placeholder: '请输入数字', + }, + }, { component: 'Divider', label: '面板设置',