diff --git a/apps/update.js b/apps/update.js
index 2f9f8d7..ab9bf08 100644
--- a/apps/update.js
+++ b/apps/update.js
@@ -3,6 +3,7 @@ import { rulePrefix } from '../lib/common.js';
import { pluginName } from '../lib/path.js';
import settings from '../lib/settings.js';
import { ZZZUpdate } from '../lib/update.js';
+import config from '../../../lib/config/config.js';
export class update extends plugin {
constructor() {
@@ -18,6 +19,15 @@ export class update extends plugin {
},
],
});
+ const updateConfig = _.get(settings.getConfig('config'), 'update', {});
+ const cron = _.get(updateConfig, 'cron', '0 0/10 * * * ?');
+ this.task = {
+ name: 'ZZZ-Plugin自动检测更新',
+ cron: cron,
+ fnc: () => {
+ this.checkUpdateTask();
+ },
+ };
}
async update(e = this.e) {
@@ -27,4 +37,43 @@ export class update extends plugin {
up.e = e;
return up.update();
}
+
+ async checkUpdateTask() {
+ const updateConfig = _.get(settings.getConfig('config'), 'update', {});
+ const enable = _.get(updateConfig, 'autoCheck', true);
+ if (!enable) return;
+ if (!ZZZUpdate) return false;
+ const up = new ZZZUpdate();
+ const result = await up.hasUpdate();
+ if (result.hasUpdate) {
+ const botInfo = { nickname: 'ZZZ-Plugin更新', user_id: Bot.uin };
+ const msgs = [
+ {
+ message: [`[${pluginName}]有${result.logs.length || 1}个更新`],
+ ...botInfo,
+ },
+ ];
+ for (const log of result.logs) {
+ msgs.push({
+ message: [`[${log.commit}|${log.date}]${log.msg}`],
+ ...botInfo,
+ });
+ }
+ const msg = Bot.makeForwardMsg(msgs);
+ try {
+ ForMsg.data = ForMsg.data
+ .replace(/\n/g, '')
+ .replace(/
(.+?)<\/title>/g, '___')
+ .replace(
+ /___+/,
+ 'ZZZ-Plugin更新'
+ );
+ } catch (err) {}
+ const masters = config.masterQQ;
+ for (const master of masters) {
+ if (master.toString().length > 11) continue;
+ await Bot.pickFriend(master).sendMsg(msg);
+ }
+ }
+ }
}
diff --git a/defSet/config.yaml b/defSet/config.yaml
index 7fe694c..5ad4c5b 100644
--- a/defSet/config.yaml
+++ b/defSet/config.yaml
@@ -2,6 +2,8 @@ render:
scale: 100 # 渲染精度
query:
others: true # 允许查询他人信息
-
+update:
+ autoCheck: true # 自动检查更新
+ cron: 0 0/10 * * * ? # 更新检查时间
# 自定义绑定设备下载url
url: https://ghproxy.mihomo.me/https://raw.githubusercontent.com/forchannot/get_device_info/main/app/build/outputs/apk/debug/app-debug.apk
\ No newline at end of file
diff --git a/guoba.support.js b/guoba.support.js
index a1fee49..621c04e 100644
--- a/guoba.support.js
+++ b/guoba.support.js
@@ -48,10 +48,10 @@ export function supportGuoba() {
field: 'config.url',
label: '绑定设备下载url',
bottomHelpMessage: '设置自定义的绑定绑定设备下载url',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入绑定设备apk下载url',
- }
+ },
},
{
field: 'config.query.others',
@@ -59,6 +59,21 @@ export function supportGuoba() {
bottomHelpMessage: '是否允许查询他人信息',
component: 'Switch',
},
+ {
+ field: 'config.update.autoCheck',
+ label: '自动检查更新',
+ bottomHelpMessage: '是否开启自动检查更新(仅检查,不更新)',
+ component: 'Switch',
+ },
+ {
+ field: 'config.update.cron',
+ label: '自动检查更新时间',
+ bottomHelpMessage: '设置自动检查更新的时间,cron表达式',
+ component: 'Input',
+ componentProps: {
+ placeholder: '请输入cron表达式',
+ },
+ },
{
component: 'Divider',
label: '抽卡分析设置',
@@ -203,55 +218,55 @@ export function supportGuoba() {
field: 'device.productName',
label: 'productName(deviceProduct)',
bottomHelpMessage: '设置默认设备productName字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入productName',
- }
+ },
},
{
field: 'device.productType',
label: 'productType(deviceName)',
bottomHelpMessage: '设置默认设备productType字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入productType',
- }
+ },
},
{
field: 'device.modelName',
label: 'modelName(deviceModel)',
bottomHelpMessage: '设置默认设备modelName字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入modelName',
- }
+ },
},
{
field: 'device.oaid',
label: 'oaid',
bottomHelpMessage: '设置默认设备oaid字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入oaid',
- }
+ },
},
{
field: 'device.deviceInfo',
label: 'deviceInfo(deviceFingerprint)',
bottomHelpMessage: '设置默认设备deviceInfo字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入deviceInfo',
- }
+ },
},
{
field: 'device.board',
label: 'board(deviceBoard)',
bottomHelpMessage: '设置默认设备board字段',
- component:'Input',
+ component: 'Input',
componentProps: {
placeholder: '请输入board',
- }
+ },
},
{
component: 'Divider',