Skip to content

feat: handle text document attachments from Telegram#32

Open
dmitryanchikov wants to merge 2 commits intomoazbuilds:masterfrom
dmitryanchikov:feat/telegram-document-handling
Open

feat: handle text document attachments from Telegram#32
dmitryanchikov wants to merge 2 commits intomoazbuilds:masterfrom
dmitryanchikov:feat/telegram-document-handling

Conversation

@dmitryanchikov
Copy link
Copy Markdown
Contributor

Summary

  • Download and serve text documents (code, configs, logs, etc.) to Claude via file path instead of injecting content into the prompt
  • Follows the same on-demand pattern used for images — safer, no size limit
  • Detects text documents by MIME type and common file extensions
  • Also fixes HEARTBEAT_OK check to strip markdown formatting before comparison

Details

When a user sends a text file (.py, .json, .yaml, .log, etc.) via Telegram, the bot now:

  1. Downloads the file via Telegram's getFile API to inbox/telegram/
  2. Passes the file path, name, and size in the prompt
  3. Claude reads the file on demand via the Read tool

This avoids injecting potentially large file contents directly into the prompt, which is both safer (no prompt injection from file contents) and more flexible (no size limit).

Test plan

  • Tested with .txt file attachment — file downloaded and read correctly
  • Tested with .cookies.txt — recognized as text, processed correctly
  • Verify non-text documents (images, audio) still handled by existing paths
  • Verify empty/missing documents handled gracefully

🤖 Generated with Claude Code

Vesper and others added 2 commits March 13, 2026 16:10
Download and serve text documents (code, configs, logs, etc.) to Claude
via file path instead of injecting content into the prompt. This follows
the same on-demand pattern used for images — safer and no size limit.

- Detect text documents by MIME type and file extension
- Download via Telegram getFile API to inbox/telegram/
- Pass file path, name, and size in the prompt
- Claude reads the file on demand via Read tool

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude sometimes wraps HEARTBEAT_OK in backticks or bold markers.
Strip leading formatting characters before the startsWith check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fenrur added a commit to Fenrur/claudeclaw that referenced this pull request Mar 13, 2026
…zbuilds#35)

- Delegate voice transcription to Claude via file path (no local whisper)
- Parse rate limit reset time from Claude output
- Global rate limit state to pause heartbeats/jobs
- Voice directive [voice:/path] for TTS responses
- Text document download and inline reading
- Rate limit pre-check in Telegram handler

Supersedes PRs moazbuilds#32, moazbuilds#33, moazbuilds#34.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dmitryanchikov dmitryanchikov force-pushed the feat/telegram-document-handling branch from a9afb06 to 765c2cb Compare March 13, 2026 16:13
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