mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
feat: 快捷设置自动更新
This commit is contained in:
parent
d0e73ff00c
commit
108cc5399b
6 changed files with 74 additions and 85 deletions
14
apps/help.js
14
apps/help.js
|
|
@ -331,6 +331,20 @@ export class Help extends ZZZPlugin {
|
|||
needSK: false,
|
||||
commands: ['设置默认设备'],
|
||||
},
|
||||
{
|
||||
title: '开启/关闭自动更新推送',
|
||||
desc: '开启/关闭自动更新推送,自动更新仅推送给第一个主人',
|
||||
needCK: false,
|
||||
needSK: false,
|
||||
commands: ['开启/关闭自动更新'],
|
||||
},
|
||||
{
|
||||
title: '设置自动更新时间',
|
||||
desc: '设置自动更新时间,cron表达式,如0 0/10 * * * ?',
|
||||
needCK: false,
|
||||
needSK: false,
|
||||
commands: ['设置自动更新时间+cron表达式'],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
|
|
|||
|
|
@ -76,6 +76,14 @@ export class Panel extends ZZZPlugin {
|
|||
reg: `${rulePrefix}设置默认设备`,
|
||||
fnc: 'setDefaultDevice',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}(开启|关闭)自动更新$`,
|
||||
fnc: 'enableAutoUpdatePush',
|
||||
},
|
||||
{
|
||||
reg: `${rulePrefix}设置自动更新时间(.+)$`,
|
||||
fnc: 'setCheckUpdateCron',
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
|
|
@ -94,6 +102,8 @@ export class Panel extends ZZZPlugin {
|
|||
this.getChangeLog = manage.version.getChangeLog;
|
||||
this.getCommitLog = manage.version.getCommitLog;
|
||||
this.hasUpdate = manage.version.hasUpdate;
|
||||
this.enableAutoUpdatePush = manage.version.enableAutoUpdatePush;
|
||||
this.setCheckUpdateCron = manage.version.setCheckUpdateCron;
|
||||
this.setDefaultDevice = manage.device.setDefaultDevice;
|
||||
this.toSetDefaultDevice = manage.device.toSetDefaultDevice;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import version from '../../lib/version.js';
|
||||
import { ZZZUpdate } from '../../lib/update.js';
|
||||
import { pluginName } from '../../lib/path.js';
|
||||
import settings from '../../lib/settings.js';
|
||||
|
||||
export async function getChangeLog() {
|
||||
const versionData = version.changelogs;
|
||||
|
|
@ -49,3 +50,46 @@ export async function hasUpdate() {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/** 开启/关闭自动更新推送 */
|
||||
export async function enableAutoUpdatePush() {
|
||||
if (!this.e.isMaster) {
|
||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
}
|
||||
let enable = true;
|
||||
if (this.e.msg.includes('关闭')) {
|
||||
enable = false;
|
||||
}
|
||||
settings.setSingleConfig('config', 'update', { autoCheck: enable });
|
||||
await this.reply(
|
||||
`[${pluginName}]自动更新推送${enable ? '已开启' : '已关闭'}`,
|
||||
false,
|
||||
{ at: true, recallMsg: 100 }
|
||||
);
|
||||
}
|
||||
|
||||
/** 设置自动更新时间 */
|
||||
export async function setCheckUpdateCron() {
|
||||
if (!this.e.isMaster) {
|
||||
this.reply('仅限主人设置', false, { at: true, recallMsg: 100 });
|
||||
return false;
|
||||
}
|
||||
const cron = this.e.msg.split('时间')[1];
|
||||
if (!cron) {
|
||||
await this.reply(
|
||||
`[${pluginName}]设置自动更新频率失败,无cron表达式`,
|
||||
false,
|
||||
{
|
||||
at: true,
|
||||
recallMsg: 100,
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
settings.setSingleConfig('config', 'update', { cron });
|
||||
await this.reply(`[${pluginName}]自动更新频率已设置为${cron}`, false, {
|
||||
at: true,
|
||||
recallMsg: 100,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,6 +73,7 @@ export class update extends plugin {
|
|||
for (const master of masters) {
|
||||
if (master.toString().length > 11) continue;
|
||||
await Bot.pickFriend(master).sendMsg(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue