mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 21:27:47 +00:00
feat: 手动开启/关闭群聊通过链接刷新抽卡记录&链接刷新抽卡记录黑白名单#38
This commit is contained in:
parent
8fd570a442
commit
3fef51cdf9
3 changed files with 124 additions and 13 deletions
|
|
@ -60,22 +60,69 @@ export class GachaLog extends ZZZPlugin {
|
||||||
await this.reply(reply_msg);
|
await this.reply(reply_msg);
|
||||||
}
|
}
|
||||||
async startGachaLog() {
|
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) {
|
if (!this.e.isPrivate) {
|
||||||
await this.reply('请私聊发送抽卡链接', false, { at: true });
|
const currentGroup = this.e?.group_id;
|
||||||
|
if (!currentGroup) {
|
||||||
|
await this.reply('获取群聊ID失败,请尝试私聊发送抽卡链接', false, {
|
||||||
|
at: true,
|
||||||
|
recallMsg: 100,
|
||||||
|
});
|
||||||
return false;
|
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');
|
this.setContext('gachaLog');
|
||||||
await this.reply('请发送抽卡链接', false, { at: true });
|
await this.reply(
|
||||||
|
'请发送抽卡链接,发送“取消”即可取消本次抽卡链接刷新',
|
||||||
|
false,
|
||||||
|
{ at: true, recallMsg: 100 }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
async gachaLog() {
|
async gachaLog() {
|
||||||
if (!this.e.isPrivate) {
|
const msg = this.e.msg.trim();
|
||||||
await this.reply('请私聊发送抽卡链接', false, { at: true });
|
if (msg.includes('取消')) {
|
||||||
|
await this.reply('已取消', false, { at: true, recallMsg: 100 });
|
||||||
|
this.finish('gachaLog');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const msg = this.e.msg.trim();
|
|
||||||
const key = getQueryVariable(msg, 'authkey');
|
const key = getQueryVariable(msg, 'authkey');
|
||||||
if (!key) {
|
if (!key) {
|
||||||
await this.reply('抽卡链接格式错误,请重新发送');
|
await this.reply('抽卡链接格式错误,请重新发起%抽卡链接', false, {
|
||||||
|
at: true,
|
||||||
|
recallMsg: 100,
|
||||||
|
});
|
||||||
this.finish('gachaLog');
|
this.finish('gachaLog');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -124,6 +171,11 @@ export class GachaLog extends ZZZPlugin {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
async getLogWithOutUID(key) {
|
async getLogWithOutUID(key) {
|
||||||
|
await this.reply(
|
||||||
|
'抽卡链接解析成功,正在查询抽卡记录,可能耗费一段时间,请勿重复发送',
|
||||||
|
false,
|
||||||
|
{ at: true, recallMsg: 100 }
|
||||||
|
);
|
||||||
/** @type {string} */
|
/** @type {string} */
|
||||||
let uid;
|
let uid;
|
||||||
queryLabel: for (const name in gacha_type_meta_data) {
|
queryLabel: for (const name in gacha_type_meta_data) {
|
||||||
|
|
@ -143,10 +195,12 @@ export class GachaLog extends ZZZPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
await this.reply('未查询到uid,请检查链接是否正确');
|
await this.reply('未查询到uid,请检查链接是否正确', false, {
|
||||||
|
at: true,
|
||||||
|
recallMsg: 100,
|
||||||
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.reply('抽卡记录获取中请稍等...可能需要一段时间,请耐心等待');
|
|
||||||
const { data, count } = await updateGachaLog(key, uid);
|
const { data, count } = await updateGachaLog(key, uid);
|
||||||
let msg = [];
|
let msg = [];
|
||||||
msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`);
|
msg.push(`抽卡记录更新成功,共${Object.keys(data).length}个卡池`);
|
||||||
|
|
@ -167,12 +221,20 @@ export class GachaLog extends ZZZPlugin {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
await this.getPlayerInfo();
|
await this.getPlayerInfo();
|
||||||
await this.reply(
|
await this.reply('正在分析抽卡记录,请稍等', false, {
|
||||||
'正在分析抽卡记录,首次下载图片资源可能耗费一些时间,请稍等'
|
at: true,
|
||||||
);
|
recallMsg: 100,
|
||||||
|
});
|
||||||
const data = await anaylizeGachaLog(uid);
|
const data = await anaylizeGachaLog(uid);
|
||||||
if (!data) {
|
if (!data) {
|
||||||
await this.reply('未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录');
|
await this.reply(
|
||||||
|
'未查询到抽卡记录,请先发送抽卡链接或%更新抽卡记录',
|
||||||
|
false,
|
||||||
|
{
|
||||||
|
at: true,
|
||||||
|
recallMsg: 100,
|
||||||
|
}
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const result = {
|
const result = {
|
||||||
|
|
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
interval: 60 # 刷新抽卡记录的时间间隔(单位:秒)
|
interval: 60 # 刷新抽卡记录的时间间隔(单位:秒)
|
||||||
|
allow_group: false # 是否允许群组使用刷新抽卡功能
|
||||||
|
white_list: # 白名单群组
|
||||||
|
- 123456789
|
||||||
|
black_list: # 黑名单群组
|
||||||
|
- 987654321
|
||||||
|
# 如果 allow_group 为 false,则 white_list 会生效,否则 black_list 会生效
|
||||||
|
|
@ -67,6 +67,49 @@ export function supportGuoba() {
|
||||||
placeholder: '请输入数字',
|
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',
|
component: 'Divider',
|
||||||
label: '面板设置',
|
label: '面板设置',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue