mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-17 13:47:44 +00:00
好友、启用状态判断;指令修改全局式舆/危局阈值;删除部分return false;调整帮助图
This commit is contained in:
parent
5a6024b1f5
commit
20af0deb68
2 changed files with 127 additions and 75 deletions
60
apps/help.js
60
apps/help.js
|
|
@ -188,32 +188,39 @@ const helpData = [
|
|||
icon: 'dungeon',
|
||||
items: [
|
||||
{
|
||||
title: '开启/关闭挑战提醒',
|
||||
title: '开关挑战提醒',
|
||||
desc: '开启或关闭式舆防卫战/危局强袭战未完成提醒功能',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['开启挑战提醒', '关闭挑战提醒'],
|
||||
},
|
||||
{
|
||||
title: '开关全局挑战提醒',
|
||||
desc: '开启或关闭全局式舆防卫战/危局强袭战未完成提醒功能',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['开启全局挑战提醒', '关闭全局挑战提醒'],
|
||||
},
|
||||
{
|
||||
title: '设置全局提醒时间',
|
||||
desc: '设置全局提醒时间,所有未单独设置个人提醒时间的用户将使用此时间。格式同上,仅限主人可用。',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['设置全局提醒时间+时间'],
|
||||
},
|
||||
{
|
||||
title: '设置全局提醒阈值',
|
||||
desc: '设置全局默认防卫战检查层数阈值(1~7),或全局默认危局强袭战星星阈值(1~9)',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['设置全局式舆阈值+数字', '设置全局危局阈值+数字'],
|
||||
},
|
||||
{
|
||||
title: '设置提醒阈值',
|
||||
desc: '设置式舆防卫战检查层数阈值(1~7),或危局强袭战星星阈值。例如:设置式舆阈值7',
|
||||
desc: '设置防卫战检查层数阈值(1~7),或危局强袭战星星阈值(1~9)。例如:设置危局阈值6',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['设置式舆阈值+数字', '设置防卫战阈值+数字', '设置强袭阈值+数字', '设置危局强袭战阈值+数字'],
|
||||
},
|
||||
{
|
||||
title: '查询挑战状态',
|
||||
desc: '主动查询当前式舆防卫战/危局强袭战完成情况',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['查询挑战状态'],
|
||||
},
|
||||
{
|
||||
title: '查看提醒时间',
|
||||
desc: '查看个人提醒时间或全局提醒时间',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['个人提醒时间', '全局提醒时间']
|
||||
commands: ['设置防卫战阈值+数字', '设置危局阈值+数字'],
|
||||
},
|
||||
{
|
||||
title: '设置个人提醒时间',
|
||||
|
|
@ -223,18 +230,25 @@ const helpData = [
|
|||
commands: ['设置个人提醒时间+时间'],
|
||||
},
|
||||
{
|
||||
title: '取消个人提醒时间',
|
||||
desc: '取消已设置的个人提醒时间',
|
||||
title: '查看提醒时间',
|
||||
desc: '查看个人或全局提醒时间',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['取消个人提醒时间'],
|
||||
commands: ['个人提醒时间', '全局提醒时间']
|
||||
},
|
||||
{
|
||||
title: '设置全局提醒时间',
|
||||
desc: '设置全局提醒时间,所有未单独设置个人提醒时间的用户将使用此时间。格式同上,仅限主人可用。',
|
||||
title: '重置个人提醒时间',
|
||||
desc: '重置已设置的个人提醒时间为全局默认时间',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['设置全局提醒时间+时间'],
|
||||
commands: ['重置个人提醒时间'],
|
||||
},
|
||||
{
|
||||
title: '查询挑战状态',
|
||||
desc: '主动查询当前式舆防卫战/危局强袭战完成情况',
|
||||
needCK: true,
|
||||
needSK: false,
|
||||
commands: ['查询挑战状态'],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
100
apps/remind.js
100
apps/remind.js
|
|
@ -33,17 +33,17 @@ export class Remind extends ZZZPlugin {
|
|||
fnc: 'setSubscribeEnable',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}(开启|关闭)全局挑战提醒$`,
|
||||
reg: `${rulePrefix}(开启|启用|关闭|禁用)全局挑战提醒$`,
|
||||
fnc: 'setGlobalRemindEnable',
|
||||
permission: 'master',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}设置式舆阈值\\s*(\\d+)`,
|
||||
fnc: 'setMyAbyssThreshold',
|
||||
reg: `${rulePrefix}设置(全局)?式舆阈值\\s*(\\d+)`,
|
||||
fnc: 'setAbyssThreshold',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}设置危局阈值\\s*(\\d+)`,
|
||||
fnc: 'setMyDeadlyThreshold',
|
||||
reg: `${rulePrefix}设置(全局)?危局阈值\\s*(\\d+)`,
|
||||
fnc: 'setDeadlyThreshold',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}查询挑战状态$`,
|
||||
|
|
@ -58,7 +58,7 @@ export class Remind extends ZZZPlugin {
|
|||
fnc: 'viewMyRemindTime',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}取消个人提醒时间`,
|
||||
reg: `${rulePrefix}(重置|删除|取消)个人提醒时间`,
|
||||
fnc: 'deleteMyRemindTime',
|
||||
},
|
||||
{
|
||||
|
|
@ -132,16 +132,28 @@ export class Remind extends ZZZPlugin {
|
|||
return false;
|
||||
}
|
||||
|
||||
checkEnableAndFriend() {
|
||||
if (!settings.getConfig('remind').enable) {
|
||||
this.reply('当前未启用防卫战/危局挑战提醒功能');
|
||||
return false;
|
||||
}
|
||||
if (!(this.e.bot ?? Bot).fl.get(this.e.user_id)) {
|
||||
this.reply('请添加好友后重试');
|
||||
return false;
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
async setSubscribeEnable() {
|
||||
if (!this.checkEnableAndFriend()) return;
|
||||
const enable = /开启挑战提醒$/.test(this.e.msg);
|
||||
const uid = await this.getUID();
|
||||
if (enable && !uid) {
|
||||
await this.reply('未绑定UID,请先绑定');
|
||||
return false;
|
||||
return this.reply('未绑定UID,请先绑定');
|
||||
}
|
||||
let userConfig = await this.getUserConfig(this.e.user_id);
|
||||
if (!userConfig) {
|
||||
const defaultConfig = settings.getConfig('remind');
|
||||
if (!userConfig) {
|
||||
userConfig = {
|
||||
enable: false,
|
||||
abyssCheckLevel: defaultConfig.abyssCheckLevel,
|
||||
|
|
@ -149,34 +161,42 @@ export class Remind extends ZZZPlugin {
|
|||
};
|
||||
}
|
||||
if (userConfig.enable === enable) {
|
||||
await this.reply(enable ? '提醒已开启,请勿重复操作' : '提醒功能尚未开启');
|
||||
return false;
|
||||
return this.reply(enable ? '提醒已开启,请勿重复操作' : '提醒功能尚未开启');
|
||||
}
|
||||
userConfig.enable = enable;
|
||||
await this.setUserConfig(this.e.user_id, userConfig);
|
||||
await this.reply(`提醒功能已${enable ? '开启' : '关闭'}`);
|
||||
await this.reply(`提醒功能已${enable ? '开启' : '关闭'}${enable ? `,将在${userConfig.remindTime || defaultConfig.globalRemindTime}对防卫战<${userConfig.abyssCheckLevel}层或危局<${userConfig.deadlyStars}星进行提醒` : ''}`);
|
||||
}
|
||||
|
||||
async setGlobalRemindEnable() {
|
||||
if (!this.e.isMaster) {
|
||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
const enable = /(开启|启用)全局挑战提醒$/.test(this.e.msg);
|
||||
if (settings.getConfig('remind').enable === enable) {
|
||||
return this.reply(enable ? '全局防卫战/危局挑战提醒功能已启用,请勿重复操作' : '全局防卫战/危局挑战提醒功能已禁用,请勿重复操作');
|
||||
}
|
||||
const enable = /开启全局挑战提醒$/.test(this.e.msg);
|
||||
settings.setSingleConfig('remind', 'enable', enable);
|
||||
await this.reply(`全局提醒功能已${enable ? '开启' : '关闭'}`);
|
||||
await this.reply(`全局防卫战/危局挑战提醒功能已${enable ? '启用' : '禁用'}`);
|
||||
}
|
||||
|
||||
async setMyAbyssThreshold() {
|
||||
const match = this.e.msg.match(/设置(?:式舆防卫战|式舆|深渊|防卫战|防卫)阈值\s*(\d+)/);
|
||||
async setAbyssThreshold() {
|
||||
const isGlobal = this.e.msg.includes('全局');
|
||||
if (isGlobal && !this.e.isMaster) {
|
||||
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
if (!isGlobal && !this.checkEnableAndFriend()) return;
|
||||
const match = this.e.msg.match(/设置(?:全局)?(?:式舆防卫战|式舆|深渊|防卫战|防卫)阈值\s*(\d+)/);
|
||||
if (!match) return;
|
||||
const threshold = Number(match[1]);
|
||||
|
||||
if (threshold < 1 || threshold > 7) {
|
||||
await this.reply('阈值必须在1到7之间');
|
||||
return false;
|
||||
return this.reply('防卫战阈值必须在1到7之间');
|
||||
}
|
||||
|
||||
if (isGlobal) {
|
||||
settings.setSingleConfig('remind', 'abyssCheckLevel', threshold);
|
||||
} else {
|
||||
let userConfig = await this.getUserConfig(this.e.user_id);
|
||||
if (!userConfig) {
|
||||
const defaultConfig = settings.getConfig('remind');
|
||||
|
|
@ -186,17 +206,30 @@ export class Remind extends ZZZPlugin {
|
|||
deadlyStars: defaultConfig.deadlyStars,
|
||||
};
|
||||
}
|
||||
|
||||
userConfig.abyssCheckLevel = threshold;
|
||||
await this.setUserConfig(this.e.user_id, userConfig);
|
||||
await this.reply(`式舆防卫战提醒阈值已设为: 检查前 ${threshold} 层`);
|
||||
};
|
||||
|
||||
await this.reply(`${isGlobal ? '全局默认' : ''}式舆防卫战阈值已设为: <${threshold}层时提醒`);
|
||||
}
|
||||
|
||||
async setMyDeadlyThreshold() {
|
||||
const match = this.e.msg.match(/设置(?:危局强袭战|危局|强袭|强袭战)阈值\s*(\d+)/);
|
||||
async setDeadlyThreshold() {
|
||||
const isGlobal = this.e.msg.includes('全局');
|
||||
if (isGlobal && !this.e.isMaster) {
|
||||
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
if (!isGlobal && !this.checkEnableAndFriend()) return;
|
||||
const match = this.e.msg.match(/设置(?:全局)?(?:危局强袭战|危局|强袭|强袭战)阈值\s*(\d+)/);
|
||||
if (!match) return;
|
||||
const threshold = Number(match[1]);
|
||||
|
||||
if (threshold < 1 || threshold > 9) {
|
||||
return this.reply('危局阈值必须在1到9之间');
|
||||
}
|
||||
|
||||
if (isGlobal) {
|
||||
settings.setSingleConfig('remind', 'deadlyStars', threshold);
|
||||
} else {
|
||||
let userConfig = await this.getUserConfig(this.e.user_id);
|
||||
if (!userConfig) {
|
||||
const defaultConfig = settings.getConfig('remind');
|
||||
|
|
@ -209,7 +242,8 @@ export class Remind extends ZZZPlugin {
|
|||
|
||||
userConfig.deadlyStars = threshold;
|
||||
await this.setUserConfig(this.e.user_id, userConfig);
|
||||
await this.reply(`危局强袭战星星阈值已设为: ${threshold}`);
|
||||
}
|
||||
await this.reply(`${isGlobal ? '全局默认' : ''}危局强袭战阈值已设为: <${threshold}星时提醒`);
|
||||
}
|
||||
|
||||
async checkNow() {
|
||||
|
|
@ -311,6 +345,7 @@ export class Remind extends ZZZPlugin {
|
|||
for (const userId in allUserConfigs) {
|
||||
const userConfig = JSON.parse(allUserConfigs[userId]);
|
||||
if (!userConfig.enable) continue;
|
||||
if (!Bot.fl.get(userId)) continue;
|
||||
|
||||
const remindTime = userConfig.remindTime || globalRemindTime;
|
||||
|
||||
|
|
@ -324,7 +359,9 @@ export class Remind extends ZZZPlugin {
|
|||
|
||||
const messages = await this.checkUser(userId, userConfig, false, mockE);
|
||||
if (messages.length > 0) {
|
||||
await Bot.pickFriend(userId).sendMsg(messages.join('\n'));
|
||||
await Bot.pickFriend(userId).sendMsg('【式舆/危局挑战提醒】\n' + messages.join('\n')).catch(err => {
|
||||
logger.error(`[ZZZ-Plugin] 式舆/危局挑战推送用户 ${userId} 失败`, err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -332,6 +369,7 @@ export class Remind extends ZZZPlugin {
|
|||
}
|
||||
|
||||
async setMyRemindTime() {
|
||||
if (!this.checkEnableAndFriend()) return;
|
||||
const { remindTime, error } = this.parseRemindTimeMessage(this.e.msg);
|
||||
if (!remindTime) return await this.reply(error);
|
||||
|
||||
|
|
@ -353,7 +391,7 @@ export class Remind extends ZZZPlugin {
|
|||
async viewMyRemindTime() {
|
||||
const userConfig = await this.getUserConfig(this.e.user_id);
|
||||
if (userConfig && userConfig.remindTime) {
|
||||
await this.reply(`当前提醒时间: ${userConfig.remindTime}`);
|
||||
await this.reply(`当前个人提醒时间: ${userConfig.remindTime}`);
|
||||
} else {
|
||||
const remindConfig = settings.getConfig('remind');
|
||||
const globalRemindTime = remindConfig.globalRemindTime || '每日20时';
|
||||
|
|
@ -362,11 +400,12 @@ export class Remind extends ZZZPlugin {
|
|||
}
|
||||
|
||||
async deleteMyRemindTime() {
|
||||
if (!this.checkEnableAndFriend()) return;
|
||||
let userConfig = await this.getUserConfig(this.e.user_id);
|
||||
if (userConfig && userConfig.remindTime) {
|
||||
delete userConfig.remindTime;
|
||||
await this.setUserConfig(this.e.user_id, userConfig);
|
||||
await this.reply('个人提醒时间已取消');
|
||||
await this.reply('个人提醒时间已重置为全局默认时间');
|
||||
} else {
|
||||
await this.reply('个人提醒时间尚未设置');
|
||||
}
|
||||
|
|
@ -374,14 +413,13 @@ export class Remind extends ZZZPlugin {
|
|||
|
||||
async setGlobalRemindTime() {
|
||||
if (!this.e.isMaster) {
|
||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
return this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
}
|
||||
|
||||
const { remindTime: globalRemindTime, error } = this.parseRemindTimeMessage(this.e.msg);
|
||||
if (!globalRemindTime) return await this.reply(error);
|
||||
settings.setSingleConfig('remind', 'globalRemindTime', globalRemindTime);
|
||||
await this.reply(`全局提醒时间已更新为: ${globalRemindTime}。`);
|
||||
await this.reply(`全局提醒时间已更新为: ${globalRemindTime}`);
|
||||
}
|
||||
|
||||
async viewGlobalRemindTime() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue