Skip to content

feat: handle Telegram document/file uploads#89

Open
Devail1 wants to merge 1 commit into
six-ddc:mainfrom
Devail1:feat/document-uploads
Open

feat: handle Telegram document/file uploads#89
Devail1 wants to merge 1 commit into
six-ddc:mainfrom
Devail1:feat/document-uploads

Conversation

@Devail1

@Devail1 Devail1 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Adds support for forwarding documents/files (PDF, etc.) sent in a bound Telegram topic to the Claude Code session — mirroring how photos and voice messages are already handled.

When a user uploads a file to a topic, the bot downloads it into ~/.ccbot/documents/ and forwards the saved path to Claude Code as (file attached: <path>) (preserving any caption), so Claude can read it directly.

How

  • New self-contained handler handlers/document.py, registered on filters.Document.ALL.
  • Rejects files over Telegram's 20 MB bot-download cap up front, and falls back gracefully if getFile is rejected for an under-reported size.
  • Sanitizes the Telegram-supplied filename before saving.
  • Sends a typing indicator but never lets a transient send_action timeout drop the upload before the path reaches tmux.

Notes

  • bot.py changes are minimal: a docstring bullet, the handler import, the registration line, and the "supported message types" string.
  • The handler reuses existing primitives only (session_manager, tmux_manager, safe_reply, clear_status_msg_info); no new dependencies.
  • Lint (ruff), format, and type-check (pyright) are clean for the added file and changes.

🤖 Generated with Claude Code

Add a handler for documents (PDF, etc.) sent to a bound topic: the file is downloaded into ~/.ccbot/documents/ and its path is forwarded to the Claude Code session as '(file attached: <path>)', mirroring how photos are already forwarded.

- New handler in handlers/document.py (filters.Document.ALL)
- Rejects files over Telegram's 20 MB bot download cap up front, and falls back gracefully if getFile is rejected for an under-reported size
- Sanitizes the Telegram-supplied filename before saving
- Preserves an optional caption alongside the attached path
- Sends a typing indicator but never lets a transient send_action timeout drop the upload before the path reaches tmux

Co-Authored-By: Claude Opus 4.8 (1M context) <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