Skip to content

新增 Bark(iOS) 推送通知支持 + Windows 声音音效化增强#6

Open
PAKingdom wants to merge 6 commits into
2234839:masterfrom
PAKingdom:feat/bark-support
Open

新增 Bark(iOS) 推送通知支持 + Windows 声音音效化增强#6
PAKingdom wants to merge 6 commits into
2234839:masterfrom
PAKingdom:feat/bark-support

Conversation

@PAKingdom

Copy link
Copy Markdown

这个 PR 做了什么

在现有飞书 / Telegram / Windows 声音提醒之外,新增完整的 Bark(iOS) 推送支持,
并把 Windows 声音从「机器人语音」改为音效文件,顺带修复了 hook 环境下的两个发声问题。

Bark(iOS) 推送(新增 bark-notify.js

  • 基础推送:BARK_KEY / BARK_SERVER(默认 api.day.app
  • 端到端加密:AES-CBC/ECB(BARK_ENCRYPT_KEY / BARK_ENCRYPT_IV / BARK_ENCRYPT_MODE),中继服务器只见密文
  • 自定义图标 BARK_ICON、通知级别 BARK_LEVEL(时效性)、重要警告 BARK_CRITICAL
  • 消息分组(按项目名)、通知历史归档(BARK_ARCHIVE_*,Stop 存 / 等待事件不存)、持续响铃 BARK_CALL
  • iOS 预置 / 自定义铃声 BARK_SOUND(内置预置清单)

Windows 声音增强(重构 notify-system.js

  • 机器人语音改为播放 .wav / .mp3 音效(SoundPlayer / MediaPlayer),可配 SOUND_FILE
  • Stop 与 Notification 两类 hook 分别配音效与消息(--event / SOUND_FILE_ASK
  • powershell 用绝对路径 + spawnSync 同步阻塞播放,修复 hook 环境下「PATH 缺 System32」与「子进程被回收」导致的收到通知却不发声
  • 交互式终端下不读 stdin,避免文档里的 --task 测试命令卡死

兼容性

  • 纯增量:所有能力默认可选,不改动现有飞书 / Telegram / 声音行为
  • 未配置 BARK_KEY 时 Bark 自动跳过;未配 SOUND_FILE 用系统默认通知音
  • 不引入新依赖:加密用 Node 内置 crypto,声音用 Windows 自带 PowerShell

用法

.env 里填 BARK_KEY=你的设备key 即可用;扩展项见 .env.exampleSETUP.md

测试

Windows 11 实测通过:Bark 推送(含加密往返,输出与 Bark 官方文档参考密文逐字节一致)、Stop 与 Notification 两类真实 hook 均正常发声。


提交带 Co-Authored-By: Claude Opus 4.8 署名。

PAKingdom and others added 6 commits July 8, 2026 05:04
- 新增 bark-notify.js:BarkNotifier + notifyTaskCompletion,POST JSON 到 ${server}/${key}
- env-config.js 增加 getBarkConfig(),纳入 getAllConfig()
- notification-manager.js 注册 bark 通知器,补全名称/图标/结果汇总
- notify-system.js 将 bark 配置透传给 NotificationManager
- .env.example / README.md / SETUP.md 补充 Bark 配置说明

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- notify-system.js:移除机器人语音,改播 wav/mp3 音效(.wav 走 SoundPlayer,
  mp3/m4a/wma 走 MediaPlayer);新增 --sound 命令行参数覆盖 SOUND_FILE,
  可给不同 hook 配不同音效;静音黑窗、detached 让长音频播完不被打断
- env-config.js:SOUND_FILE 环境变量纳入声音配置
- .env.example / SETUP.md:补充 SOUND_FILE(支持 wav/mp3)说明

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- bark-notify.js:重写 payload 构建,支持 icon(默认 Claude 图标)、level(时效性/重要警告)、
  group(项目名分组)、isArchive(归档)、call(持续响铃);新增 AES-CBC/ECB 端到端加密(crypto),
  支持固定 IV(BARK_ENCRYPT_IV)或每次随机
- env-config.js:getBarkConfig 增加图标/级别/分组/归档/重要警告/响铃/加密(含 IV)等配置项
- notify-system.js:按事件(Stop/ask)解析归档、重要警告、持续响铃;
  修复交互式终端下 --task 读 stdin 卡死(改为仅管道输入时读);
  mp3 缺失/加载失败时蜂鸣兜底,避免静默无声
- notification-manager.js:BarkNotifier 改用配置对象构造
- .env.example / SETUP.md:补充 Bark 扩展功能文档,并标注固定 IV 的隐私权衡

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stop/Notification hook 运行时 PATH 常不含 System32,spawn('powershell')
会 ENOENT,导致「bark 能收到但 Windows 不发声」(连蜂鸣兜底也因同样原因失败)。
改用 %SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe 绝对路径定位。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- bark-notify.js:payload 支持 sound 字段(iOS 预置或自定义音效名)
- env-config.js:getBarkConfig 增加 BARK_SOUND(默认空=不启用)
- .env.example / SETUP.md:列出全部 iOS 预置音效名与用法(默认注释关闭)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stop/Notification hook 触发时,声音原本是 detached 后台进程 + 3 秒定时退出;
hook 进程被回收时该子进程会被一并 kill、还没播完就没了(bark 走 https 不受影响,
故表现为「收到 bark 但 Windows 没声音」)。改为 spawnSync 同步阻塞、播完再退出,
声音在 hook 进程存活期间即播完。实测 Stop 与 Notification 两个 hook status=0 均正常发声。

- notify-system.js:playWindowsSound 拆为 buildSoundPsScript;sendSoundNotification
  改用 spawnSync 阻塞播放(powershell 仍用绝对路径),异常退回蜂鸣;
  sendAllNotifications 播完即退出,移除 detached 与 3 秒定时;删除无用 playBeep

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant