@zifeng1023/dsh-bot 0.3.5 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dsh-plugin.json +1 -1
- package/lib/client.js +36 -4
- package/package.json +1 -1
package/dsh-plugin.json
CHANGED
package/lib/client.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
'use strict';
|
|
22
22
|
|
|
23
23
|
// 构建时由 tsdown 替换为 package.json.version(见 tsdown.config.ts)
|
|
24
|
-
const BOT_BUILD = '0.3.
|
|
24
|
+
const BOT_BUILD = '0.3.6';
|
|
25
25
|
|
|
26
26
|
// ============================================================
|
|
27
27
|
// 设计令牌
|
|
@@ -4255,15 +4255,29 @@ window.__ModuleLoader__.load({
|
|
|
4255
4255
|
};
|
|
4256
4256
|
|
|
4257
4257
|
let notifying = false;
|
|
4258
|
+
|
|
4259
|
+
/** 取某个 Bot 的生效设置;失败时回退全局。 */
|
|
4260
|
+
const policyOf = async (botId) => {
|
|
4261
|
+
try {
|
|
4262
|
+
const r = await fetch(
|
|
4263
|
+
`/_dsh-bot/settings?botId=${encodeURIComponent(botId)}`,
|
|
4264
|
+
{ headers: { accept: 'application/json' } },
|
|
4265
|
+
);
|
|
4266
|
+
const j = await r.json();
|
|
4267
|
+
if (j?.ok && j.value?.effective) return j.value.effective;
|
|
4268
|
+
} catch {
|
|
4269
|
+
/* 回退全局 */
|
|
4270
|
+
}
|
|
4271
|
+
return null;
|
|
4272
|
+
};
|
|
4273
|
+
|
|
4258
4274
|
const notifyTick = async () => {
|
|
4259
4275
|
if (notifying) return;
|
|
4260
4276
|
notifying = true;
|
|
4261
4277
|
try {
|
|
4262
4278
|
const sRes = await fetch('/_dsh-bot/settings', { headers: { accept: 'application/json' } });
|
|
4263
4279
|
const sJson = await sRes.json();
|
|
4264
|
-
const
|
|
4265
|
-
if (!settings?.notifySystem) return;
|
|
4266
|
-
if (inQuietHours(settings.quietHours)) return;
|
|
4280
|
+
const globalSettings = sJson?.ok ? sJson.value?.effective : null;
|
|
4267
4281
|
|
|
4268
4282
|
const oRes = await fetch('/_dsh-bot/overview', { headers: { accept: 'application/json' } });
|
|
4269
4283
|
const oJson = await oRes.json();
|
|
@@ -4275,6 +4289,11 @@ window.__ModuleLoader__.load({
|
|
|
4275
4289
|
let newest = lastSeen;
|
|
4276
4290
|
// 每个新完成运行都要看;为控制请求量只拉每 Bot 最近 5 条
|
|
4277
4291
|
for (const b of bots) {
|
|
4292
|
+
// ⭐ 单 Bot 设置要覆盖全局:0.3.5 及之前这里只看全局 settings,
|
|
4293
|
+
// 导致「某个 Bot 关闭仅异常打扰」永远不生效(0.3.6 修复)。
|
|
4294
|
+
const settings = (await policyOf(b.id)) ?? globalSettings;
|
|
4295
|
+
if (!settings?.notifySystem) continue;
|
|
4296
|
+
if (inQuietHours(settings.quietHours)) continue;
|
|
4278
4297
|
const rRes = await fetch(`/_dsh-bot/runs/list?botId=${encodeURIComponent(b.id)}&limit=5`, {
|
|
4279
4298
|
headers: { accept: 'application/json' },
|
|
4280
4299
|
});
|
|
@@ -4329,6 +4348,19 @@ window.__ModuleLoader__.load({
|
|
|
4329
4348
|
setInterval(() => void notifyTick(), NOTIFY_POLL_MS);
|
|
4330
4349
|
}, 15_000);
|
|
4331
4350
|
report('ok', 'notify poller armed');
|
|
4351
|
+
// 通知能力自证:没有它,「收不到通知」只能靠猜
|
|
4352
|
+
try {
|
|
4353
|
+
if (typeof Notification === 'undefined') {
|
|
4354
|
+
report('notify-unavailable', 'Notification API 不存在');
|
|
4355
|
+
} else {
|
|
4356
|
+
report('notify-capability', `permission=${Notification.permission}`);
|
|
4357
|
+
if (Notification.permission === 'default') {
|
|
4358
|
+
try { void Notification.requestPermission?.(); } catch {}
|
|
4359
|
+
}
|
|
4360
|
+
}
|
|
4361
|
+
} catch {
|
|
4362
|
+
/* 能力探测失败不影响轮询 */
|
|
4363
|
+
}
|
|
4332
4364
|
} catch (e) {
|
|
4333
4365
|
report('notify-poller-error', String(e?.message ?? e));
|
|
4334
4366
|
}
|