Skip to content

fix: pass schedule Date to mtcute so --schedule really schedules - #40

Merged
dapi merged 1 commit into
mainfrom
fix/native-scheduled-send
Nov 2, 2026
Merged

dapi merged 1 commit into
mainfrom
fix/native-scheduled-send

Conversation

@dapi

@dapi dapi commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Problem

tgcli send text|photo|file --schedule <iso> returned a message id but delivered the message immediately. Found on 2026-11-02: a message meant for 09:00 next day went out at once (also reproduced with Saved Messages).

Cause

mtcute's high-level sendText / sendMedia read schedule (Date, or a number in milliseconds), not scheduleDate. buildTextSendParams / buildMediaSendParams set params.scheduleDate, which mtcute ignores. The raw TL messages.sendMedia request legitimately uses scheduleDate and is unchanged.

Fix

params.schedule = new Date(scheduleDate * 1000) (resolveScheduleDate yields unix seconds; a bare number would be read as ms and land in 1970).

The existing tests asserted the wrong param name ({ scheduleDate }), which is why this was never caught; they now expect { schedule: Date }.

Verification

  • npx vitest run tests/send-messages.test.js: 54 passed.
  • End-to-end on a real account: see the comment below.

🤖 Generated with Claude Code

mtcute's high-level sendText/sendMedia read `schedule` (Date, or a number in
milliseconds). tgcli passed `scheduleDate`, which is ignored, so scheduled
messages were delivered immediately while still returning a message id.
resolveScheduleDate() yields unix seconds, so convert to a Date. The
low-level messages.sendMedia request keeps `scheduleDate` (raw TL name).
Tests asserted the wrong param name; fixed to `schedule: Date`.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@dapi

dapi commented Nov 2, 2026

Copy link
Copy Markdown
Owner Author

End-to-end check on a real account (owner on office3 running this branch, release 2.11.0-local-091ecc51613d): send text --to me --schedule <now+2min> returned scheduled id 3 and the message was absent from regular history; it was delivered at 18:13:46 UTC, i.e. at the scheduled time. Before the fix the same command delivered at once.

@dapi
dapi merged commit c55b0a2 into main Nov 2, 2026
1 of 2 checks passed
dapi added a commit that referenced this pull request Nov 2, 2026
Fixes --schedule on send text/photo/file: scheduled messages are now really
scheduled by Telegram instead of being delivered immediately (#40).

Co-Authored-By: Claude Sonnet 5.5 <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