--- name: temp-file-upload description: 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 1. **Generate or download the file** into the workspace or another location (browser download, script output, etc.). 2. **Copy into the temp directory**: use `mktemp` to create a unique placeholder and copy the file there. Example: ```bash tmpfile=$(mktemp "${TMPDIR:-/tmp}/broimg_XXXXXX.png") cp ~/Downloads/my-image.png "$tmpfile" echo "$tmpfile" ``` - Keep the copied path (`$tmpfile`) for the next step. 3. **Send via Telegram** using the `message` tool: ```json { "action": "send", "channel": "telegram", "media": "/var/folders/.../broimg_XXXXXX.png", "message": "Caption placeholder" } ``` - Set `asVoice: true` only for voice notes. - Add a caption summarizing what the file is. 4. **Cleanup temp files** after confirmation: ```bash 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).