calendar: add --alarm flag to send command for custom reminder triggers
Previously the send command hardcoded a 1-day VALARM. Now accepts --alarm with duration format (e.g. 1h, 30m, 2d), defaulting to 1d.
This commit is contained in:
3
TOOLS.md
3
TOOLS.md
@@ -116,7 +116,8 @@ SKILL_DIR=~/.openclaw/workspace/skills/calendar
|
||||
$SKILL_DIR/scripts/calendar.sh send \
|
||||
--to "friend@example.com" \
|
||||
--subject "Lunch" --summary "Lunch at Tartine" \
|
||||
--start "2026-03-20T12:00:00" --end "2026-03-20T13:00:00"
|
||||
--start "2026-03-20T12:00:00" --end "2026-03-20T13:00:00" \
|
||||
--alarm 1h # 提前1小时提醒(默认1d,支持 1d/2h/30m)
|
||||
|
||||
# 发送周期性邀请(--start 必须落在 BYDAY 指定的那天!)
|
||||
$SKILL_DIR/scripts/calendar.sh send \
|
||||
|
||||
@@ -63,7 +63,8 @@ $SKILL_DIR/scripts/calendar.sh send \
|
||||
--summary "Lunch at Tartine" \
|
||||
--start "2026-03-20T12:00:00" \
|
||||
--end "2026-03-20T13:00:00" \
|
||||
--location "Tartine Bakery, SF"
|
||||
--location "Tartine Bakery, SF" \
|
||||
--alarm 1h
|
||||
```
|
||||
|
||||
### Send Options
|
||||
@@ -82,6 +83,7 @@ $SKILL_DIR/scripts/calendar.sh send \
|
||||
| `--organizer` | No | Organizer display name (defaults to `--from`) |
|
||||
| `--rrule` | No | Recurrence rule (e.g. `FREQ=WEEKLY;COUNT=13;BYDAY=TU`) |
|
||||
| `--uid` | No | Custom event UID (auto-generated if omitted) |
|
||||
| `--alarm` | No | Reminder trigger: `1d`, `2h`, `30m` (default: `1d`) |
|
||||
| `--account` | No | Himalaya account name (if not default) |
|
||||
| `--dry-run` | No | Print ICS + MIME without sending |
|
||||
|
||||
|
||||
@@ -18,8 +18,10 @@ Generates the ICS and MIME email without sending. Check that:
|
||||
- MIME has `Content-Type: text/calendar; method=REQUEST`
|
||||
- Only `--to` recipients appear as attendees
|
||||
- Times and timezone look correct
|
||||
- ICS has `BEGIN:VALARM` with correct `TRIGGER` duration
|
||||
|
||||
```bash
|
||||
# Default alarm (1 day before)
|
||||
$SKILL_DIR/scripts/calendar.sh send \
|
||||
--to "mail@luyx.org" \
|
||||
--subject "Test Invite" \
|
||||
@@ -27,6 +29,16 @@ $SKILL_DIR/scripts/calendar.sh send \
|
||||
--start "${TEST_DATE}T15:00:00" \
|
||||
--end "${TEST_DATE}T16:00:00" \
|
||||
--dry-run
|
||||
|
||||
# Custom alarm (1 hour before)
|
||||
$SKILL_DIR/scripts/calendar.sh send \
|
||||
--to "mail@luyx.org" \
|
||||
--subject "Test Invite (1h alarm)" \
|
||||
--summary "Test Event (1h alarm)" \
|
||||
--start "${TEST_DATE}T15:00:00" \
|
||||
--end "${TEST_DATE}T16:00:00" \
|
||||
--alarm 1h \
|
||||
--dry-run
|
||||
```
|
||||
|
||||
## 2. Live Send: Self-Invite
|
||||
|
||||
@@ -210,11 +210,20 @@ def cmd_send(args):
|
||||
_validate_rrule_dtstart(rrule, start)
|
||||
event.add("rrule", rrule)
|
||||
|
||||
# 1-day reminder
|
||||
# Reminder alarm
|
||||
alarm_trigger = timedelta(days=-1) # default
|
||||
if args.alarm:
|
||||
alarm_str = args.alarm
|
||||
if alarm_str.endswith("d"):
|
||||
alarm_trigger = timedelta(days=-int(alarm_str[:-1]))
|
||||
elif alarm_str.endswith("h"):
|
||||
alarm_trigger = timedelta(hours=-int(alarm_str[:-1]))
|
||||
elif alarm_str.endswith("m"):
|
||||
alarm_trigger = timedelta(minutes=-int(alarm_str[:-1]))
|
||||
alarm = Alarm()
|
||||
alarm.add("action", "DISPLAY")
|
||||
alarm.add("description", f"Reminder: {args.summary}")
|
||||
alarm.add("trigger", timedelta(days=-1))
|
||||
alarm.add("trigger", alarm_trigger)
|
||||
event.add_component(alarm)
|
||||
|
||||
cal.add_component(event)
|
||||
@@ -861,6 +870,7 @@ def main():
|
||||
send_p.add_argument("--rrule", default="", help="RRULE string (e.g. FREQ=WEEKLY;COUNT=13;BYDAY=TU)")
|
||||
send_p.add_argument("--uid", default="", help="Custom event UID")
|
||||
send_p.add_argument("--account", default="", help="Himalaya account")
|
||||
send_p.add_argument("--alarm", default="1d", help="Reminder trigger (e.g. 1d, 2h, 30m)")
|
||||
send_p.add_argument("--dry-run", action="store_true", help="Preview without sending")
|
||||
|
||||
# --- reply ---
|
||||
|
||||
Reference in New Issue
Block a user