2.1 KiB
2.1 KiB
name, description
| name | description |
|---|---|
| temp-file-upload | Upload files to Telegram by copying them into the macOS temporary directory (e.g., /var/folders/…/T/) so that the `message` tool accepts them; include steps to clean up afterward. Trigger when the user needs us to send images, audio, or other media files via Telegram but the workspace path isn’t accepted. |
Temp File Upload to Telegram
Purpose
Telegram’s message tool refuses files that live in the workspace. The workaround is to copy the file into the Mac system temp directory ($TMPDIR, typically /var/folders/.../T/) before calling message.send. This skill captures that pattern so we can share downloads, exports, or generated assets reliably through Telegram.
Workflow
- Generate or download the file into the workspace or another location (browser download, script output, etc.).
- Copy into the temp directory: use
mktempto create a unique placeholder and copy the file there. Example:tmpfile=$(mktemp "${TMPDIR:-/tmp}/broimg_XXXXXX.png") cp ~/Downloads/my-image.png "$tmpfile" echo "$tmpfile"- Keep the copied path (
$tmpfile) for the next step.
- Keep the copied path (
- Send via Telegram using the
messagetool:{ "action": "send", "channel": "telegram", "media": "/var/folders/.../broimg_XXXXXX.png", "message": "Caption placeholder" }- Set
asVoice: trueonly for voice notes. - Add a caption summarizing what the file is.
- Set
- Cleanup temp files after confirmation:
echo "Removing temp file" && rm -f "$tmpfile"
- This avoids cluttering `/var/folders/...` with stale copies.
5. **Optional: Wrap in a script** when repeating the pattern (save inside `skills/temp-file-upload/scripts/copy-and-send.sh`).
## Notes
- Keep file names descriptive to make debugging easier (e.g., `broimg`, `brovoice`, `brodoc`).
- If the download lands in `~/Downloads`, move it before copying to `$TMPDIR` to avoid permission issues.
- When a user requests multiple files, repeat the copy + send steps for each file (don’t rely on ZIP uploads unless explicitly asked).