Focus Break Reminder
Implement a lightweight per-user/session state machine that triggers rest reminders without spamming.
Configure
Create or load references/config.example.json as the default schema.
Required settings:
- - INLINECODE1
- INLINECODE2
- INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
- INLINECODE7
- INLINECODE8
- INLINECODE9
Prefer defaults that are practical and non-intrusive:
- - work interval: 50 minutes
- cooldown: 30 minutes
- idle reset: 15 minutes
- daily cap: 4
Track state
Maintain minimal state per user (or per DM/chat for first version):
- - INLINECODE10
- INLINECODE11
- INLINECODE12
- INLINECODE13
- INLINECODE14
Persist to a small JSON file so reminders survive restarts.
Update activity
On each inbound user message:
- 1. If date changed in configured timezone, reset
remind_count_today and today_key. - If idle time since
last_active_at >= idle_reset_minutes, reset session_start_at to now. - Set
last_active_at to now.
Evaluate reminder eligibility
Only remind when all conditions pass:
- 1.
enabled is true. - Not in quiet hours.
- Not snoozed (
now < snooze_until means skip). - Daily cap not exceeded.
- Active duration (
now - session_start_at) >= work_minutes. - Cooldown passed (
now - last_remind_at) >= cooldown_minutes.
If all pass, send one reminder and set:
- - INLINECODE27
- INLINECODE28
Reminder delivery
Use one short template per reminder. Keep copy practical and non-medical.
Example template:
- - “你已经连续工作一段时间了。现在起身 2 分钟、喝口水,再看 20 秒远处 👀”
Commands
Support these chat commands:
- -
/break on → enable reminders - INLINECODE30 → disable reminders
- INLINECODE31 → show current config + next eligible reminder window
- INLINECODE32 → update INLINECODE33
- INLINECODE34 → set INLINECODE35
Validate numeric ranges (e.g., 15–180 for work interval).
Heartbeat integration
Use heartbeat polling to run eligibility checks when there is recent activity. Avoid noisy polling loops.
Recommended behavior:
- - If no user activity for a long period, skip checks.
- If reminder was just sent, honor cooldown and return quickly.
Safety and UX boundaries
- - Do not provide medical diagnosis or treatment advice.
- Keep reminders optional and easy to disable.
- Store only minimum timestamps and settings needed for reminder logic.
- Use clear language when data is missing: “待补充”.
Testing checklist
Use references/test-cases.md.
At minimum verify:
- - triggers at/after work interval
- cooldown suppresses duplicates
- idle reset restarts session timer
- quiet hours suppress reminders
- snooze suppresses reminders until expiry
- daily cap blocks additional reminders
专注休息提醒
实现一个轻量级的按用户/会话的状态机,在不造成骚扰的前提下触发休息提醒。
配置
创建或加载 references/config.example.json 作为默认模式。
必需设置:
- - enabled(启用)
- timezone(时区)
- workminutes(工作时长)
- cooldownminutes(冷却时长)
- idleresetminutes(空闲重置时长)
- dailymaxreminders(每日最大提醒次数)
- quiethours(免打扰时段)
- snoozeuntil(暂缓提醒截止时间)
- templates(模板)
推荐使用实用且不具侵入性的默认值:
- - 工作间隔:50分钟
- 冷却时间:30分钟
- 空闲重置:15分钟
- 每日上限:4次
状态追踪
为每个用户(或初版中的每个私信/聊天)维护最小状态:
- - sessionstartat(会话开始时间)
- lastactiveat(最后活跃时间)
- lastremindat(最后提醒时间)
- remindcounttoday(今日提醒次数)
- today_key(今日标识键)
将状态持久化到小型JSON文件中,确保重启后提醒功能仍能正常工作。
更新活跃状态
每次收到用户消息时:
- 1. 如果配置的时区中日期已变更,重置 remindcounttoday 和 todaykey。
- 如果自 lastactiveat 以来的空闲时间 >= idleresetminutes,将 sessionstartat 重置为当前时间。
- 将 lastactive_at 设置为当前时间。
评估提醒资格
仅当所有条件均满足时才触发提醒:
- 1. enabled 为 true。
- 不在免打扰时段内。
- 未暂缓提醒(now < snoozeuntil 表示跳过)。
- 未超过每日上限。
- 活跃时长(now - sessionstartat)>= workminutes。
- 冷却时间已过(now - lastremindat)>= cooldown_minutes。
如果全部满足,发送一条提醒并设置:
- - lastremindat = now
- remindcounttoday += 1
提醒发送
每次提醒使用一个简短模板。文案保持实用,不涉及医疗建议。
示例模板:
- - 你已经连续工作一段时间了。现在起身 2 分钟、喝口水,再看 20 秒远处 👀
命令
支持以下聊天命令:
- - /break on → 启用提醒
- /break off → 禁用提醒
- /break status → 显示当前配置及下一个符合条件的提醒窗口
- /break set <分钟数> → 更新 workminutes
- /break snooze <分钟数> → 设置 snoozeuntil = now + minutes
验证数值范围(例如工作间隔为15–180分钟)。
心跳集成
使用心跳轮询在近期有活跃活动时运行资格检查。避免频繁的轮询循环。
推荐行为:
- - 如果长时间没有用户活动,跳过检查。
- 如果刚刚发送了提醒,遵守冷却时间并快速返回。
安全与用户体验边界
- - 不提供医疗诊断或治疗建议。
- 保持提醒为可选功能,且易于禁用。
- 仅存储提醒逻辑所需的最小时间戳和设置。
- 数据缺失时使用清晰的语言:待补充。
测试清单
使用 references/test-cases.md。
至少验证:
- - 在工作间隔时间或之后触发提醒
- 冷却时间抑制重复提醒
- 空闲重置重新启动会话计时器
- 免打扰时段抑制提醒
- 暂缓提醒在到期前抑制提醒
- 每日上限阻止额外提醒