fix: 主人权限,消息撤回

This commit is contained in:
bietiaop 2024-08-20 15:06:57 +08:00
parent eacea6e902
commit 18f24f87bb
7 changed files with 107 additions and 35 deletions

View file

@ -4,7 +4,7 @@ import settings from '../../lib/settings.js';
/** 设置默认攻略 */
export async function setDefaultGuide() {
if (!this.e.isMaster) {
this.reply('仅限主人设置');
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
}
const match = /设置默认攻略(\d+|all)$/g.exec(this.e.msg);
@ -26,25 +26,39 @@ export async function setDefaultGuide() {
settings.setSingleConfig('guide', 'default_guide', guide_id);
const source_name = guide_id == 0 ? 'all' : this.source[guide_id - 1];
await this.e.reply(`绝区零默认攻略已设置为: ${guide_id} (${source_name})`);
await this.e.reply(
`绝区零默认攻略已设置为: ${guide_id} (${source_name})`,
false,
{ at: true, recallMsg: 100 }
);
}
/** 设置所有攻略显示个数 */
export async function setMaxForwardGuide() {
if (!this.e.isMaster) {
this.reply('仅限主人设置');
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
return false;
}
const match = /设置所有攻略显示个数(\d+)$/g.exec(this.e.msg);
const max_forward_guide = Number(match[1]);
if (max_forward_guide < 1) {
await this.e.reply('所有攻略显示个数不能小于1');
await this.e.reply('所有攻略显示个数不能小于1', false, {
at: true,
recallMsg: 100,
});
return false;
}
if (max_forward_guide > guides.guideMaxNum) {
await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`);
await this.e.reply(`所有攻略显示个数不能大于${guides.guideMaxNum}`, false, {
at: true,
recallMsg: 100,
});
return false;
}
settings.setSingleConfig('guide', 'max_forward_guides', max_forward_guide);
await this.e.reply(`绝区零所有攻略显示个数已设置为: ${max_forward_guide}`);
await this.e.reply(
`绝区零所有攻略显示个数已设置为: ${max_forward_guide}`,
false,
{ at: true, recallMsg: 100 }
);
}